We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3b28331 commit d42dc66Copy full SHA for d42dc66
torch_np/_ndarray.py
@@ -115,12 +115,18 @@ def flags(self):
115
116
# check if F contiguous
117
from itertools import accumulate
118
- f_strides = tuple(accumulate(list(self._tensor.shape), func=lambda x, y: x*y))
+
119
+ f_strides = tuple(accumulate(list(self._tensor.shape), func=lambda x, y: x * y))
120
f_strides = (1,) + f_strides[:-1]
121
is_f_contiguous = f_strides == self._tensor.stride()
122
- return Flags({"C_CONTIGUOUS": self._tensor.is_contiguous(),
123
- "F_CONTIGUOUS": is_f_contiguous,}
+ return Flags(
124
+ {
125
+ "C_CONTIGUOUS": self._tensor.is_contiguous(),
126
+ "F_CONTIGUOUS": is_f_contiguous,
127
+ "OWNDATA": self._tensor._base is None,
128
+ "WRITEABLE": True, # pytorch does not have readonly tensors
129
+ }
130
)
131
132
@property
0 commit comments