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

Set default dtype of usm_ndarray depending on capabilities of device #1265

Merged

Conversation

vlad-perevezentsev
Copy link
Collaborator

This PR solves the issue of creating usm_ndarray without dtype argument. The default value of dtype in __cinit__ of usm_ndarray is defined as dtype='f8' which raised an exception on Iris Xe which does not support 64-bit precision floating point type.

import dpctl.tensor as dpt

a = dpt.usm_ndarray(())
ValueError: Device Intel(R) Graphics [0x46a6] does not support f8 natively.

Idea of this PR is to change default value dtype="f8" to dtype=None and return default floating point type supported by the device when dtype=None.

import dpctl.tensor as dpt

dpt.usm_ndarray(())
usm_ndarray(0., dtype=float32)

dpt.usm_ndarray((), dtype="f8")
ValueError: Device Intel(R) Graphics [0x46a6] does not support f8 natively.

Note:
I'm not sure if it's correct to get device using dpctl.SyclDevice() when queue is unknown.

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

@coveralls
Copy link
Collaborator

coveralls commented Jun 27, 2023

Coverage Status

coverage: 83.273% (-0.01%) from 83.287% when pulling 2c137e4 on vlad-perevezentsev:flexable_usmarray_type into bc59de9 on IntelPython:master.

@ndgrigorian
Copy link
Collaborator

I think it may be more correct to use dpctl.select_default_device here rather than dpctl.SyclDevice, it makes the intent more clear.

Copy link
Collaborator

@ndgrigorian ndgrigorian left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks @vlad-perevezentsev!

@ndgrigorian ndgrigorian merged commit 5ebd6c3 into IntelPython:master Jul 4, 2023
29 of 32 checks passed
@github-actions
Copy link

github-actions bot commented Jul 4, 2023

Array API standard conformance tests for dpctl=0.14.5dev0=py310h7bf5fec_14 ran successfully.
Passed: 448
Failed: 552
Skipped: 119

Copy link
Collaborator

@oleksandr-pavlyk oleksandr-pavlyk left a comment

Choose a reason for hiding this comment

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

Thank you @vlad-perevezentsev, great addition!

oleksandr-pavlyk added a commit that referenced this pull request Aug 16, 2023
This changes builds up on gh-1265 and takes into account queue
from the pre-allocated buffer, if provided.
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.

None yet

4 participants