Skip to content

Added Device class representing Data-API notion of device#440

Merged
oleksandr-pavlyk merged 2 commits intomasterfrom
feature/data-api-device
May 13, 2021
Merged

Added Device class representing Data-API notion of device#440
oleksandr-pavlyk merged 2 commits intomasterfrom
feature/data-api-device

Conversation

@oleksandr-pavlyk
Copy link
Copy Markdown
Contributor

Data-API notion of device is higher level abstraction. The class
does allow for public constructor, has class method to create
instance instead.

It typesets as Device(filter_string) for parent devices and
Device(queue) for sub-devices. It can constructed from

  • filter selector string
  • SyclDevice corresponding to a root device
    (attempt at passing sub-device raises and error)
  • SyclQueue
  • Another instance of Device class

It implements sycl_queue, sycl_device, sycl_context attributes.

usm_ndarray adds .device property, and .to_device(device) method.

In [5]: X = dpt.usm_ndarray((4, 5), dtype='d')

In [6]: X.device
Out[6]: Device(level_zero:gpu:0)

In [7]: Y = X.to_device('cpu')

In [8]: Y.device
Out[8]: Device(opencl:cpu:0)

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the feature/data-api-device branch from 4428ac5 to 6cc07d4 Compare May 11, 2021 12:47
Comment thread dpctl/tensor/_device.py
Comment thread dpctl/tensor/_device.py Outdated
Comment thread dpctl/tensor/_device.py Outdated
@oleksandr-pavlyk oleksandr-pavlyk force-pushed the feature/data-api-device branch from 6cc07d4 to ca33bfe Compare May 12, 2021 15:27
Data-API notion of device is higher level abstraction. The class
does allow for public constructor, has class method to create
instance instead.

It typesets as Device(filter_string) for parent devices and
Device(queue) for sub-devices. It can constructed from

   - filter selector string
   - SyclDevice corresponding to a root device
     (attempt at passing sub-device raises and error)
   - SyclQueue
   - Another instance of Device class

It implements sycl_queue, sycl_device, sycl_context attributes.

usm_ndarray adds .device property, and .to_device(device) method.

```
In [5]: X = dpt.usm_ndarray((4, 5), dtype='d')

In [6]: X.device
Out[6]: Device(level_zero:gpu:0)

In [7]: Y = X.to_device('cpu')

In [8]: Y.device
Out[8]: Device(opencl:cpu:0)
```
@oleksandr-pavlyk oleksandr-pavlyk force-pushed the feature/data-api-device branch from ca33bfe to f2c5f18 Compare May 12, 2021 16:38
@oleksandr-pavlyk oleksandr-pavlyk merged commit e68c16e into master May 13, 2021
@oleksandr-pavlyk oleksandr-pavlyk deleted the feature/data-api-device branch May 13, 2021 00:50
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