Skip to content

Commit

Permalink
import SyclDevice directly in _dldevice_conversions
Browse files Browse the repository at this point in the history
Full dpctl namespace is unnecessary, as only SyclDevice is used
  • Loading branch information
ndgrigorian committed Jan 7, 2025
1 parent f125be4 commit ac69747
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions dpctl/tensor/_dldevice_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import dpctl

from ._sycl_device import SyclDevice
from ._usmarray import DLDeviceType


Expand All @@ -29,12 +28,12 @@ def dldevice_to_sycldevice(dl_dev: tuple):
)
if dl_dev[0] != DLDeviceType.kDLOneAPI:
raise ValueError("dldevice type must be kDLOneAPI")
return dpctl.SyclDevice(str(dl_dev[1]))
return SyclDevice(str(dl_dev[1]))


def sycldevice_to_dldevice(dev: dpctl.SyclDevice):
if not isinstance(dev, dpctl.SyclDevice):
def sycldevice_to_dldevice(dev: SyclDevice):
if not isinstance(dev, SyclDevice):
raise TypeError(
"dev is expected to be a dpctl.SyclDevice, got " f"{type(dev)}"
"dev is expected to be a SyclDevice, got " f"{type(dev)}"
)
return (DLDeviceType.kDLOneAPI, dev.get_device_id())

0 comments on commit ac69747

Please sign in to comment.