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

Add __array_namespace__ method #2252

Merged
merged 6 commits into from
Jan 11, 2025
Merged

Add __array_namespace__ method #2252

merged 6 commits into from
Jan 11, 2025

Conversation

antonwolfy
Copy link
Contributor

@antonwolfy antonwolfy commented Jan 8, 2025

The PR proposes to implement __array_namespace__ method of dpnp ndarray, which is required to be compliant with python array API.
The method will return dpnp as an array namespace, member functions of which implement data API.

The array namespace is assumed to be stored inside dpctl tensor. So dpnp ndarray constructor is updated to explicitly pass array_namespace=dpnp into dpt.usm_ndarray call. And also to set the namespace through _set_namespace(dpnp) every time dpnp ndarray is created from usm_ndarray.

  • 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 8, 2025
Copy link
Contributor

github-actions bot commented Jan 8, 2025

View rendered docs @ https://intelpython.github.io/dpnp/index.html

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 65.082% (+0.002%) from 65.08%
when pulling 6ed5822 on add-array_namespace
into 659629d on master.

@antonwolfy antonwolfy marked this pull request as ready for review January 9, 2025 09:55
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 aaf5290 into master Jan 11, 2025
57 of 58 checks passed
@antonwolfy antonwolfy deleted the add-array_namespace branch January 11, 2025 17:04
github-actions bot added a commit that referenced this pull request Jan 11, 2025
The PR proposes to implement `__array_namespace__` method of dpnp
ndarray, which is required to be compliant with python array API.
The method will return dpnp as an array namespace, member functions of
which implement data API.

The array namespace is assumed to be stored inside dpctl tensor. So dpnp
ndarray constructor is updated to explicitly pass `array_namespace=dpnp`
into `dpt.usm_ndarray` call. And also to set the namespace through
`_set_namespace(dpnp)` every time dpnp ndarray is created from
usm_ndarray. aaf5290
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