Skip to content

Make dpctl tensor device hashable, added equality comparison #1048

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 2 commits into from
Jan 28, 2023

Conversation

oleksandr-pavlyk
Copy link
Contributor

Added dpctl.tensor.Device.__eq__ and dpctl.tensor.Device.__hash__ methods and tests.

import dpctl.tensor as dpt
x = dpt.empty(10)
y = dpt.empty(10)
assert x.device == y.device 

The assertion used to fail, but returns True now.

  • 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?

Array API's Device object must support __eq__ special method.
Addition of __hash__ also allows to use Device object instances
as keys in dictionaries.
@oleksandr-pavlyk oleksandr-pavlyk changed the title Make dpctl tensor device hashable Make dpctl tensor device hashable, added equality comparison Jan 27, 2023
@github-actions
Copy link

@coveralls
Copy link
Collaborator

Coverage Status

Coverage: 82.097% (+0.02%) from 82.076% when pulling 3dda4f4 on make-dpctl-tensor-Device-hashable into 949711e on master.

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_48 ran successfully.
Passed: 33
Failed: 801
Skipped: 280

@oleksandr-pavlyk oleksandr-pavlyk merged commit db8fe2f into master Jan 28, 2023
@github-actions
Copy link

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

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.1dev1=py310h76be34b_50 ran successfully.
Passed: 33
Failed: 801
Skipped: 280

@oleksandr-pavlyk oleksandr-pavlyk deleted the make-dpctl-tensor-Device-hashable branch March 23, 2023 16:28
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.

2 participants