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

Return default floating point type of the device in dpctl.tensor.astype when newdtype=None #1262

Merged

Conversation

vlad-perevezentsev
Copy link
Collaborator

This PR makes minor changes to dpctl.tensor.astype function by replacing the getting target_dtype.
The old implementation did not consider whether the device where input array is allocated supported double-precision floating point types and returned float64 for None type which raised ValueError.

import dpctl.tensor as dpt

a = dpt.asarray([1, 1, 1], dtype='i4')
dpt.astype(a, None)

ValueError: Device Intel(R) Graphics [0x46a6] does not provide native support 
for double-precision floating point type.

This PR uses _get_dtype function from dpctl.tensor._ctors which fixes wrong behavior.
For None returns default floating point type supported by device.
For all other types returns dpt.dtype(dtype)

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

@vlad-perevezentsev vlad-perevezentsev self-assigned this Jun 23, 2023
@vlad-perevezentsev vlad-perevezentsev changed the title Return default floating point type of the device when new_dtype=None Return default floating point type of the device in dpctl.tensor.astype when newdtype=None Jun 23, 2023
@coveralls
Copy link
Collaborator

coveralls commented Jun 23, 2023

Coverage Status

coverage: 83.256% (+0.002%) from 83.254% when pulling 3d51c48 on vlad-perevezentsev:update_astype into 36a7cd7 on IntelPython:master.

Co-authored-by: Oleksandr Pavlyk <oleksandr.pavlyk@intel.com>
@vlad-perevezentsev vlad-perevezentsev merged commit cc02941 into IntelPython:master Jun 27, 2023
@vlad-perevezentsev vlad-perevezentsev deleted the update_astype branch June 27, 2023 20:25
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.5dev0=py310h7bf5fec_1 ran successfully.
Passed: 386
Failed: 614
Skipped: 119

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.

4 participants