Skip to content
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

Implement __usm_ndarray__ protocol #2261

Merged
merged 3 commits into from
Jan 20, 2025

Conversation

antonwolfy
Copy link
Contributor

@antonwolfy antonwolfy commented Jan 14, 2025

The PR is intended to adopt to dpctl changes implemented in dpctl#1959.

It implements support of __usm_ndarray__ protocol for dpnp.ndarray and returns a property with dpctl.tensor.usm_ndarray instance corresponding to the content of the array object.

This property is intended to speed-up conversion from dpnp.ndarray to dpt.usm_ndarray in x=dpt.asarray(dpnp_array_obj).
The input object that implements __usm_ndarray__ is recognized as owner of USM allocation that is managed by a smart pointer, and asynchronous deallocation of x need not involve GIL.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to 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 filing the PR as a draft?

@antonwolfy antonwolfy self-assigned this Jan 14, 2025
@coveralls
Copy link
Collaborator

coveralls commented Jan 14, 2025

Coverage Status

coverage: 70.85% (+0.003%) from 70.847%
when pulling ae97845 on tensor-asarray-support-for-usm-ndarray-protocol
into 6cc2348 on master.

@antonwolfy antonwolfy marked this pull request as ready for review January 19, 2025 09:48
Copy link
Contributor

Array API standard conformance tests for dpnp=0.17.0dev4=py312he4f9c94_9 ran successfully.
Passed: 949
Failed: 1
Skipped: 50

Copy link
Collaborator

@vlad-perevezentsev vlad-perevezentsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
Thank you @antonwolfy

@antonwolfy antonwolfy merged commit 9ad1bb5 into master Jan 20, 2025
46 of 53 checks passed
@antonwolfy antonwolfy deleted the tensor-asarray-support-for-usm-ndarray-protocol branch January 20, 2025 11:29
github-actions bot added a commit that referenced this pull request Jan 20, 2025
The PR is intended to adopt to dpctl changes implemented in
[dpctl#1959](IntelPython/dpctl#1959).

It implements support of `__usm_ndarray__` protocol for `dpnp.ndarray`
and returns a property with `dpctl.tensor.usm_ndarray` instance
corresponding to the content of the array object.

This property is intended to speed-up conversion from `dpnp.ndarray` to
`dpt.usm_ndarray` in `x=dpt.asarray(dpnp_array_obj)`.
The input object that implements `__usm_ndarray__` is recognized as
owner of USM allocation that is managed by a smart pointer, and
asynchronous deallocation of `x` need not involve GIL. 9ad1bb5
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.

3 participants