Skip to content

Conversation

@ndgrigorian
Copy link
Collaborator

This PR proposes accounting for the offset when usm_ndarray constructor is given buffer=x where x is a usm_ndarray.

This means that when a x is a view, and in particular a view on memory which does not start at the same place as its base array, the memory will start from the same displaced position as the view. For example,

import dpctl.tensor as dpt
a = dpt.ones(10)
b = a[5:]
c = dpt.usm_ndarray(b.shape, buffer=b)
c[1] = 0
c
# Out: usm_ndarray([1., 0., 1., 1., 1.])
 
b
# Out: usm_ndarray([1., 0., 1., 1., 1.])
 
a
# Out: usm_ndarray([1., 1., 1., 1., 1., 1., 0., 1., 1., 1.])

where previously, b would not have changed at all and the 0 would have appeared at a[1].

This has also necessitated disallowing views which are not contiguous as arguments to the usm_ndarray constructor, which aligns with NumPy.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?
  • If this PR is a work in progress, are you opening the PR as a draft?

this necessitates restricting the constructor to no longer permit arrays that aren't contiguous
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

Array API standard conformance tests for dpctl=0.22.0dev0=py310h93fe807_104 ran successfully.
Passed: 1111
Failed: 47
Skipped: 82

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant