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.SyclKernelBundle from 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 buffer

  • SpecializationConstant(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 NumPy dtype string 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 SpecializationConstant copies the input, so modifications made after construction of the SpecializationConstant will not be reflected in the SyclKernelBundle.

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_const struct for this SpecializationConstant cast to size_t.

Attributes

id

Returns the specialization ID for this specialization constant.

size

Returns the size in bytes of the data for this specialization constant.