Skip to content

Implement QOL properties of usm_ndarray #1199

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

Merged
merged 1 commit into from
May 5, 2023

Conversation

oleksandr-pavlyk
Copy link
Contributor

@oleksandr-pavlyk oleksandr-pavlyk commented May 4, 2023

This PR implements request for quality-of-life properties of usm_ndarray requested in gh-1192. It adds usm_ndarray._element_offset and usm_ndarray._byte_bounds.

The _element_offset gives the offset of the start of array from the beginning of the start of allocation in elements.

_byte_bounds gives the tuple with addresses of end-points of the array. Not every memory element in between the end-points may be addressed by indexing.


In [1]: import dpctl.tensor as dpt

In [2]: dpt.empty(10)[5:]._element_offset
Out[2]: 5

In [3]: dpt.empty(10)[5:]._byte_bounds
Out[3]: (18446664917462351892, 18446664917462351912)

In [4]: _[1] - _[0]
Out[4]: 20

In [5]: dpt.empty(10)[5:].itemsize
Out[5]: 4

Tests are added. This PR resolves gh-1192

  • 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?
  • If this PR is a work in progress, are you opening the PR as a draft?

This PR implements request for quality-of-life properties of usm_ndarray requested
in gh-1192. It adds usm_ndarray._element_offset and usm_ndarray._byte_bounds

The _element_offset gives the offset of the start of array from the beginning of
the start of allocation in elements.

_byte_bounds gives the tuple with addresses of end-points of the array. Not every
memory element in between the end-points may be addressed by indexing.
@coveralls
Copy link
Collaborator

Coverage Status

Coverage: 83.299% (+0.04%) from 83.259% when pulling 4eb94f4 on qol-usm-ndarray-changes into 2da47aa on master.

@github-actions
Copy link

github-actions bot commented May 4, 2023

@github-actions
Copy link

github-actions bot commented May 4, 2023

Array API standard conformance tests for dpctl=0.14.3dev1=py310h76be34b_40 ran successfully.
Passed: 153
Failed: 847
Skipped: 116

@oleksandr-pavlyk oleksandr-pavlyk merged commit 004e3d9 into master May 5, 2023
@oleksandr-pavlyk oleksandr-pavlyk deleted the qol-usm-ndarray-changes branch May 5, 2023 19:54
@github-actions
Copy link

github-actions bot commented May 5, 2023

Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞

@github-actions
Copy link

github-actions bot commented May 5, 2023

Array API standard conformance tests for dpctl=0.14.3dev1=py310h76be34b_44 ran successfully.
Passed: 153
Failed: 847
Skipped: 116

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.

QOL suggestion for dpctl.tensor.usm_ndarray
3 participants