-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes setting of writable flag for views and writing to read-only arrays with out
keyword
#1527
Conversation
`writable` flag was not being set correctly for indexing, real views, imaginary views, tranposes, and where shape is set directly Also fixes cases where flag could be overridden by functions with `out` kwarg
253c20e
to
87cd798
Compare
Now flags are set based on input regardless of whether a new array is writable per review feedback
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
Array API standard conformance tests for dpctl=0.15.1dev3=py310h15de555_72 ran successfully. |
1 similar comment
Array API standard conformance tests for dpctl=0.15.1dev3=py310h15de555_72 ran successfully. |
Array API standard conformance tests for dpctl=0.15.1dev3=py310h15de555_75 ran successfully. |
Array API standard conformance tests for dpctl=0.15.1dev3=py310h15de555_73 ran successfully. |
out
keyword
Array API standard conformance tests for dpctl=0.15.1dev3=py310h15de555_82 ran successfully. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More tests are needed, and perhaps usm_ndarray._set_writable_flag
could be implemented using newly added _copy_writable
function, but this can be done in a separate PR.
Thanks @ndgrigorian for finding and fixing this bug!
This pull request makes changes to
_usmarray.pyx
to guarantee that the writable flag is handled correctly for views created viareal
,imag
,T
,mT
, and shape-setting and indexing properties.__getitem__
now only adjusts the flag after all writing to the result has been performed, fixing the practice of setting elements to a read-only array.Elementwise functions,
clip
, andmatmul
also now contain early (top-level) checks for the writable flag of a providedout
array, fixing an edge case where the writable flag would be overridden by copying to the original array. This practice also prevents unnecessary computation and memory allocation.