ndstrides: [3] Implement indexing/slicing #513
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Reference: M-Labs/nac3#513
Loading…
Reference in New Issue
No description provided.
Delete Branch "ndstrides-3-indexing"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR implements indexing/slicing with ndarray strides.
Slicing an ndarray no longer copies
ndarray->data
and only creates a new ndarray with different strides but points to the same datandarray->data
, which is very cheap. This is only possible with the addition of strides to NAC3's ndarray definition. This is how NumPy implements ndarrays too....
andnp.newaxis
have been implemented using IRRT, but they are only there to help with implementing other aspects of ndarray with strides (e.g.,NDArrayObject::atleast_nd()
in a later commit, it usesnp.newaxis
internally to prepend 1s to the dimension; or inmatmul
,np.newaxis
and...
are used to deal with 1D matrices). You cannot writemy_array[..., none]
in NAC3 Python as the type inferencer/code generator cannot understand it. I have encountered some problems when trying to implement this into NAC3:...
does not have a concrete type. #486. Probably requires a hack on the typechecker.my_array[..., none]
again;none
has type<class 'Option'>
, but NumPy wants aNoneType
. This causes issues in@portable
.Extra note: After this PR, there is finally a proper way to start developing ndarray with strides with nac3standalone, since now you can print the contents of an ndarray and debug:
40cf1c747f
tofdd5d37490
Rebased.
fdd5d37490
toa40cdde8d2
Rebased to fix some formatting issues.
a40cdde8d2
to0206c3989a
0206c3989a
toc71bd81278
c71bd81278
to3d8e66a54e
3d8e66a54e
to8f9d2d82dd
Step 1:
From your project repository, check out a new branch and test the changes.Step 2:
Merge the changes and update on Gitea.