ndstrides: [9] Implement ndarray subscript assignment #519

Open
lyken wants to merge 2 commits from ndstrides-9-subassign into ndstrides-8-transpose
Collaborator

Implemented general ndarray subscript assignment with referential integrity.

  • For example, you can do funky things like np_transpose(np_transpose(my_array)[::3])[0, 2:100] = 1.0 and my_array would update. This is only possible with ndarray with strides.
  • Solves #411 (Implement subscript-assignment for NDArray) in a different way than described in the issue.

There is no implementation to handle overlapping at the moment. Things like

xs = np_array([1, 2, 3, 4, 5, 6])
xs[::] = xs[::-1]

have undefined behavior at this moment because the current implementation is a naive memcpy from the source to the destination. I think an addition to fix this after ndstrides is completed should be fine.

ScalarOrNDArray is a utility to deal with implementing ndarray-related logics that deals with both scalars and ndarrays simultaneously.

Implemented general ndarray subscript assignment with referential integrity. - For example, you can do funky things like `np_transpose(np_transpose(my_array)[::3])[0, 2:100] = 1.0` and `my_array` would update. This is only possible with ndarray with strides. - Solves https://git.m-labs.hk/M-Labs/nac3/issues/411 (Implement subscript-assignment for NDArray) in a different way than described in the issue. There is ***no*** implementation to handle overlapping at the moment. Things like ```python xs = np_array([1, 2, 3, 4, 5, 6]) xs[::] = xs[::-1] ``` have undefined behavior at this moment because the current implementation is a naive `memcpy` from the source to the destination. I think an addition to fix this after `ndstrides` is completed should be fine. `ScalarOrNDArray` is a utility to deal with implementing ndarray-related logics that deals with both scalars and ndarrays simultaneously.
lyken added 2 commits 2024-08-28 14:08:10 +08:00
lyken added a new dependency 2024-08-28 14:11:36 +08:00
lyken force-pushed ndstrides-9-subassign from ccc8ce5886 to cea512456a 2024-08-30 14:55:09 +08:00 Compare
Author
Collaborator

Rebased.

Rebased.
derppening force-pushed ndstrides-9-subassign from cea512456a to d12d62f078 2024-10-18 13:53:52 +08:00 Compare
derppening force-pushed ndstrides-9-subassign from d12d62f078 to 594977f909 2024-10-18 13:54:34 +08:00 Compare
derppening force-pushed ndstrides-9-subassign from 594977f909 to d3f636fcfa 2024-10-18 14:27:19 +08:00 Compare
derppening force-pushed ndstrides-9-subassign from d3f636fcfa to d0af58769a 2024-10-18 14:27:42 +08:00 Compare
derppening force-pushed ndstrides-9-subassign from d0af58769a to 5bed394ef7 2024-10-18 14:59:32 +08:00 Compare
This pull request can be merged automatically.
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin ndstrides-9-subassign:ndstrides-9-subassign
git checkout ndstrides-9-subassign
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Reference: M-Labs/nac3#519
No description provided.