dpctl.program.SpecializationConstant¶
- class dpctl.program.SpecializationConstant(spec_id, *args)¶
Python class representing SYCL specialization constants that can be used when creating a
dpctl.program.SyclKernelBundlefrom SPIR-V.There are multiple ways to create a
SpecializationConstant:SpecializationConstant(spec_id, obj)If the constructor is invoked with a single variadic argument, the argument is expected to either expose the Python buffer protocol or be coercible to a NumPy array. If the argument is coercible to a NumPy array or is one, it must have a supported data type (bool, integral, or floating point). The specialization constant will be constructed from the data in the bufferSpecializationConstant(spec_id, dtype, obj)If the constructor is invoked with two variadic arguments, and the first argument is a string, it is interpreted as a NumPydtypestring and the second argument will be coerced to a NumPy array with that data type. The data type specified by the first argument must be a supported data type (bool, integral, or floating point).SpecializationConstant(spec_id, nbytes, raw_ptr)If the constructor is invoked with two variadic arguments where both are integers, the first argument is interpreted as the number of bytes and the second argument is interpreted as a pointer to the data.
Note that construction of the
SpecializationConstantcopies the input, so modifications made after construction of theSpecializationConstantwill not be reflected in theSyclKernelBundle.- Parameters:
spec_id (int) – The SPIR-V specialization ID.
args – Variadic argument, see class documentation.
- Raises:
TypeError – In case of incorrect arguments given to constructor, failure to coerce to a buffer, or unsupported data type when coercing to a buffer.
ValueError – If the provided object fails to construct a buffer.
Methods
__init__()addressof_ref()Returns the address of the
_spec_conststruct for thisSpecializationConstantcast tosize_t.Attributes
idReturns the specialization ID for this specialization constant.
sizeReturns the size in bytes of the data for this specialization constant.