-
Notifications
You must be signed in to change notification settings - Fork 30
Improve interoperability between SyclDevice
and DLPack devices
#1953
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6781a82
Add get_device_id method to SyclDevice
ndgrigorian ea6e061
Adds conversion functions for dldevice and dpctl.SyclDevice
ndgrigorian d972d07
import SyclDevice directly in _dldevice_conversions
ndgrigorian 2583383
Add tests for dldevice and sycldevice interchange functions
ndgrigorian 7d35624
Add tests for dpctl.SyclDevice.get_device_id method
ndgrigorian f15778e
use sycl_device instead of sycldevice in dldevice conversion functions
ndgrigorian 14c7dc5
Change errors throughout _sycl_device.pyx
ndgrigorian 55944bc
Add docstring for dpctl.SyclDevice.get_device_id
ndgrigorian d3058ac
Fix incorrect SyclDevice docstring
ndgrigorian d5cbe3f
Fix missing line breaks in get_device_id method
ndgrigorian 66d8025
Fix get_device_id example spacing
ndgrigorian cda903b
Adds get_unpartitioned_parent_device method to SyclDevice
ndgrigorian b1a5ecd
Use get_device_id to find DLpack device ID
ndgrigorian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Data Parallel Control (dpctl) | ||
# | ||
# Copyright 2020-2025 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from .._sycl_device import SyclDevice | ||
from ._usmarray import DLDeviceType | ||
|
||
|
||
def dldevice_to_sycl_device(dl_dev: tuple): | ||
if isinstance(dl_dev, tuple): | ||
if len(dl_dev) != 2: | ||
raise ValueError("dldevice tuple must have length 2") | ||
else: | ||
raise TypeError( | ||
f"dl_dev is expected to be a 2-tuple, got " f"{type(dl_dev)}" | ||
) | ||
if dl_dev[0] != DLDeviceType.kDLOneAPI: | ||
raise ValueError("dldevice type must be kDLOneAPI") | ||
return SyclDevice(str(dl_dev[1])) | ||
|
||
|
||
def sycl_device_to_dldevice(dev: SyclDevice): | ||
if not isinstance(dev, SyclDevice): | ||
raise TypeError( | ||
"dev is expected to be a SyclDevice, got " f"{type(dev)}" | ||
) | ||
return (DLDeviceType.kDLOneAPI, dev.get_device_id()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.