Skip to content

Commit

Permalink
Adding proper typing for dpctl.SyclQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
chudur-budur committed Mar 15, 2023
1 parent cd66cfd commit 84766b2
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions numba_dpex/core/types/dpctl_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@

from dpctl import SyclQueue
from numba import types
from numba.extending import NativeValue, box, type_callable, unbox
from numba.extending import (
NativeValue,
as_numba_type,
box,
type_callable,
typeof_impl,
unbox,
)


class DpctlSyclQueue(types.Type):
class SyclQueueType(types.Type):
"""A Numba type to represent a dpctl.SyclQueue PyObject.
For now, a dpctl.SyclQueue is represented as a Numba opaque type that allows
Expand All @@ -16,25 +23,33 @@ class DpctlSyclQueue(types.Type):
"""

def __init__(self):
super().__init__(name="DpctlSyclQueueType")
super().__init__(name="SyclQueue")


sycl_queue_ty = DpctlSyclQueue()
sycl_queue_type = SyclQueueType()


@typeof_impl.register(SyclQueue)
def typeof_index(val, c):
return sycl_queue_type


as_numba_type.register(SyclQueue, sycl_queue_type)


@type_callable(SyclQueue)
def type_interval(context):
def typer():
return sycl_queue_ty
return sycl_queue_type

return typer


@unbox(DpctlSyclQueue)
@unbox(SyclQueue)
def unbox_sycl_queue(typ, obj, c):
return NativeValue(obj)


@box(DpctlSyclQueue)
@box(SyclQueue)
def box_pyobject(typ, val, c):
return val

0 comments on commit 84766b2

Please sign in to comment.