You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Design support for reduced precision types in dpctl #72
Traceback (most recent call last):
File "<stdin>", line 1, in<module>
AttributeError: class must define a '_type_' attribute which must be
a single character string containing one of 'cbBhHiIlLdfuzZqQPXOv?g'.
The scope of the support matters. The main purpose of supporting in dpctl is to be able to submit kernels that take reduced precision arguments.
In addition to standard C/C++ types, SYCL supports std::byte and sycl::half (assuming device supports it). See tables 4.105 and 5.1 in the SYCL 2020 provisional standard. bfloa16is not presently supported. Reference to an extension proposal would be good to record in this issue.
Anyhow, for dpctl to support any additional type, we need Python class representing the type, say dpctl.types.c_half and dpctl.types.c_bfloat16, whose purpose in life is to hold the value, and designate its type. It should have a constructor to convert from other floating point types, i.e. Python floats, ctypes.c_float, ctypes.c_double, etc., and allow to get the reference to the value.
DPCTL's SyclQueue.submit will then recognize this class, and call KernelSetArg with the proper enum value.
To clarify, the issue is still relevant, because it would be great to submit kernels via dpctl.SyclQueue.submit which take these types from Python/Cython
Activity
PokhodenkoSA commentedon Feb 5, 2021
"e") is supported in modulestructstarting from Python 3.6 (https://docs.python.org/3/library/struct.html#format-characters)Error:
Links:
oleksandr-pavlyk commentedon Feb 5, 2021
The scope of the support matters. The main purpose of supporting in
dpctlis to be able to submit kernels that take reduced precision arguments.In addition to standard C/C++ types, SYCL supports
std::byteandsycl::half(assuming device supports it). See tables 4.105 and 5.1 in the SYCL 2020 provisional standard.bfloa16is not presently supported. Reference to an extension proposal would be good to record in this issue.Anyhow, for
dpctlto support any additional type, we need Python class representing the type, saydpctl.types.c_halfanddpctl.types.c_bfloat16, whose purpose in life is to hold the value, and designate its type. It should have a constructor to convert from other floating point types, i.e. Python floats,ctypes.c_float,ctypes.c_double, etc., and allow to get the reference to the value.DPCTL's
SyclQueue.submitwill then recognize this class, and callKernelSetArgwith the proper enum value.[-]Design support for reduced precision types in dpCtl[/-][+]Design support for reduced precision types in dpctl[/+]oleksandr-pavlyk commentedon Sep 25, 2021
Here is example of using
ctypesto convert a singlectype.c_floatvalue input into actypes.c_shortencoding the bits of the corresponding float16 value. https://gamedev.stackexchange.com/questions/28023/python-float-32bit-to-half-float-16bitI wonder is this could be a start of implementing our own float16 type object.
diptorupd commentedon Mar 1, 2024
@oleksandr-pavlyk Is the issue still relevant? If not I will suggest it to be closed.
ndgrigorian commentedon Apr 12, 2026
To clarify, the issue is still relevant, because it would be great to submit kernels via
dpctl.SyclQueue.submitwhich take these types from Python/Cython