Skip to content

__array_namespace_info__.dtypes raises AttributeError for device passed as a string #1978

Description

@antonwolfy

Based on dpctl documentation Info.dtypes support a string value of device keyword argument:

device (Optional[:class:dpctl.SyclDevice, :class:dpctl.SyclQueue, :class:dpctl.tensor.Device, str])

but the example below does not work and raises AttributeError exception:

import dpctl, dpctl.tensor as dpt

dpctl.__version__
# Out: '0.19.0dev0+480.g360ce45dc6'

info = dpnp.__array_namespace_info__()
info.dtypes(device="gpu")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 info.dtypes(device="gpu")

File ~/miniforge3/envs/dpnp_dev/lib/python3.11/site-packages/dpctl/tensor/_array_api.py:203, in Info.dtypes(self, device, kind)
    201 elif isinstance(device, dpt.Device):
    202     device = device.sycl_device
--> 203 _fp64 = device.has_aspect_fp64
    204 if kind is None:
    205     return {
    206         key: val
    207         for key, val in self._all_dtypes.items()
    208         if (key != "float64" or _fp64)
    209     }

AttributeError: 'str' object has no attribute 'has_aspect_fp64'

Activity

  1. self-assigned this
    on Jan 23, 2025
  2. ndgrigorian commented on Jan 23, 2025

    @ndgrigorian
    Collaborator

    I believe this is a mistake in the docstring, but also, I am not sure that we support the device keyword anywhere else without permitting a string. So it may make sense to support throughout the array API inspection functions.

  3. antonwolfy commented on Jan 23, 2025

    @antonwolfy
    CollaboratorAuthor

    I believe it would also helpful to improve error handling and to raise a proper exception in case of unsupported device keyword passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions