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
nditer has a per-operand flag contig but it must be used with the global buffered flag:
>>> a = np.arange(6, dtype='i4')[::2]
>>> it = np.nditer(a, [], [['writeonly', 'contig']])
TypeError: Iterator operand required buffering, to be contiguous \
as requested, but buffering is not enabled
The non-buffered contiguous case could be handled by either
Use writebackoncopy semantics to create a copy of the operand before iterating, and write back the results when the iterator is finished
At each iteration, create a local contiguous copy of the relevant data, and write it back at the beginning of each step. Write the final piece back when the iterator is finished.
The first method would be easier, but the second could allocate a smaller copy. This would be useful in, for instance, linalg and matmul ufuncs.
I admit I do not understand how the buffers work. Perhaps that could also provide what I am looking for, but the interface is not very well documented and the examples in the documentation and tests are not very helpful to me.
The text was updated successfully, but these errors were encountered:
👍 But probably good to be even more explicit: currently, in linalg non-contiguous matrices are copied inside the gufunc implementations so that they can be passed on as contiguous blocks of data to blas. Might this be something the iterator could help take care of.
Just to show I (sadly) don't understand buffering either: with contig and buffering enabled, is copying/buffering still done if data is already contiguous? I'll add documentation to the labels since I also did not understand the documentation well...
Hmmm, should look into current buffering again before deciding on adding a second buffering mechanism next to it I guess. I don't remember anymore if the buffer was always used on all operands if active?
The buffer internally has some pretty big complexity because it tries to skip filling the buffer when it already holds the correct data for broadcasting.
nditer
has a per-operand flagcontig
but it must be used with the globalbuffered
flag:The non-buffered contiguous case could be handled by either
The first method would be easier, but the second could allocate a smaller copy. This would be useful in, for instance,
linalg
andmatmul
ufuncs.I admit I do not understand how the buffers work. Perhaps that could also provide what I am looking for, but the interface is not very well documented and the examples in the documentation and tests are not very helpful to me.
The text was updated successfully, but these errors were encountered: