You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In trying to simplify Function.__call__, (see #1024 and #222), I noticed some complicated logic to check if inputs marked as mutable (or borrowable) are not aliasing to the same memory of each other.
# Check for groups of more than one argument that share memory
forgroupinargs_share_memory:
iflen(group) >1:
# copy all but the first
forjingroup[1:]:
self.input_storage[j].storage[0] =copy.copy(
self.input_storage[j].storage[0]
)
To avoid erroneous computation, __call__ tries to copy aliased inputs. However this logic is wrong because it assumes only variables with the same type can be aliased which doesn't make sense. See the example below where a matrix and a vector are aliased, which fails the check and return wrong values and corrupted input y which was not marked as mutable
My suggestion is not to make the check for alias more robust (and therefore increase the Function call overhead), but instead to forego it completely. If users indicated that an input is mutable it shouldn't be too surprising that views of that input (or other variables sharing the same underlying memory) would also be corrupted.
The text was updated successfully, but these errors were encountered:
Description
In trying to simplify
Function.__call__
, (see #1024 and #222), I noticed some complicated logic to check if inputs marked as mutable (or borrowable) are not aliasing to the same memory of each other.pytensor/pytensor/compile/function/types.py
Lines 888 to 933 in be358ed
To avoid erroneous computation,
__call__
tries to copy aliased inputs. However this logic is wrong because it assumes only variables with the same type can be aliased which doesn't make sense. See the example below where a matrix and a vector are aliased, which fails the check and return wrong values and corrupted inputy
which was not marked as mutableMy suggestion is not to make the check for alias more robust (and therefore increase the Function call overhead), but instead to forego it completely. If users indicated that an input is mutable it shouldn't be too surprising that views of that input (or other variables sharing the same underlying memory) would also be corrupted.
The text was updated successfully, but these errors were encountered: