DType

Module

Implements the DType class.

DType

Represents DType and provides methods for working with it.

Aliases:

  • address = address Represents a pointer type whose bitwidth is the same as the bitwidth of the hardware’s pointer type (32-bit on 32-bit machines and 64-bit on 64-bit machines).
  • bool = bool Represents a boolean data type.
  • f16 = f16 Represents a floating point value whose bitwidth is 16.
  • f32 = f32 Represents a floating point value whose bitwidth is 32.
  • f64 = f64 Represents a floating point value whose bitwidth is 64.
  • f8 = f8 Represents a floating point value whose bitwidth is 8.
  • index = index Represents an integral type whose bitwidth is the maximum integral value on the system.
  • invalid = invalid Represents an invalid or unknown data type.
  • si16 = si16 Represents a signed integer type whose bitwidth is 16.
  • si32 = si32 Represents a signed integer type whose bitwidth is 32.
  • si64 = si64 Represents a signed integer type whose bitwidth is 64.
  • si8 = si8 Represents a signed integer type whose bitwidth is 8.
  • type = dtype
  • ui16 = ui16 Represents an unsigned integer type whose bitwidth is 16.
  • ui32 = ui32 Represents an unsigned integer type whose bitwidth is 32.
  • ui64 = ui64 Represents an unsigned integer type whose bitwidth is 64.
  • ui8 = ui8 Represents an unsigned integer type whose bitwidth is 8.

Fields:

value

The underlying storage for the DType value.

Functions:

__init__

__init__(value: dtype) -> Self

__eq__

__eq__(self: Self, rhs: Self) -> Bool

Compare one DType to another for equality.

Args:

  • rhs (Self): The DType to compare against.

Returns:

True if the DTypes are the same and False otherwise.

__ne__

__ne__(self: Self, rhs: Self) -> Bool

Compare one DType to another for non-equality.

Args:

  • rhs (Self): The DType to compare against.

Returns:

False if the DTypes are the same and True otherwise.

__str__

__str__(self: Self) -> StringLiteral

Get the name of the DType.

Returns:

The name of the dtype.

dispatch_arithmetic

dispatch_arithmetic[func: fn[DType]() capturing -> None](self: Self)

Dispatch a function corresponding to the current DType.

Parameters:

  • func (fn[DType]() capturing -> None): A parametrized on dtype function to dispatch.

dispatch_arithmetic[func: fn[DType]() capturing -> None](self: Self, out_chain: OutputChainPtr)

Dispatch a function corresponding to the current DType.

Parameters:

  • func (fn[DType]() capturing -> None): A parametrized on dtype function to dispatch.

Args:

  • out_chain (OutputChainPtr): The output chain used to report errors.

dispatch_floating

dispatch_floating[func: fn[DType]() capturing -> None](self: Self)

Dispatch a floating-point function corresponding to the current DType.

Constraints:

DType must be floating-point.

Parameters:

  • func (fn[DType]() capturing -> None): A parametrized on dtype function to dispatch.

dispatch_floating[func: fn[DType]() capturing -> None](self: Self, out_chain: OutputChainPtr)

Dispatch a floating-point function corresponding to the current DType.

Constraints:

DType must be floating-point.

Parameters:

  • func (fn[DType]() capturing -> None): A parametrized on dtype function to dispatch.

Args:

  • out_chain (OutputChainPtr): The output chain used to report errors.

dispatch_integral

dispatch_integral[func: fn[DType]() capturing -> None](self: Self)

Dispatch an integral function corresponding to the current DType.

Constraints:

DType must be integral.

Parameters:

  • func (fn[DType]() capturing -> None): A parametrized on dtype function to dispatch.

dispatch_integral[func: fn[DType]() capturing -> None](self: Self, out_chain: OutputChainPtr)

Dispatch an integral function corresponding to the current DType.

Constraints:

DType must be integral.

Parameters:

  • func (fn[DType]() capturing -> None): A parametrized on dtype function to dispatch.

Args:

  • out_chain (OutputChainPtr): The output chain used to report errors.

get_value

get_value(self: Self) -> dtype

Get the associated internal kgen.dtype value.

Returns:

The kgen.dtype value.

is_address

is_address(self: Self) -> Bool

Check if this DType is Address.

Returns:

True if the DType is Address and False otherwise.

is_bool

is_bool(self: Self) -> Bool

Check if this DType is Bool.

Returns:

True if the DType is Bool and False otherwise.

is_f16

is_f16(self: Self) -> Bool

Check if this DType is F16.

Returns:

True if the DType is F16 and False otherwise.

is_f32

is_f32(self: Self) -> Bool

Check if this DType is F32.

Returns:

True if the DType is F32 and False otherwise.

is_f64

is_f64(self: Self) -> Bool

Check if this DType is F64.

Returns:

True if the DType is F64 and False otherwise.

is_floating_point

is_floating_point(self: Self) -> Bool

Returns True if the type parameter is a floating-point and False otherwise.

Returns:

Returns True if the input type parameter is a floating-point.

is_index

is_index(self: Self) -> Bool

Check if this DType is Index.

Returns:

True if the DType is Index and False otherwise.

is_integral

is_integral(self: Self) -> Bool

Returns True if the type parameter is an integer and False otherwise.

Returns:

Returns True if the input type parameter is an integer.

is_si16

is_si16(self: Self) -> Bool

Check if this DType is SI16.

Returns:

True if the DType is SI16 and False otherwise.

is_si32

is_si32(self: Self) -> Bool

Check if this DType is SI32.

Returns:

True if the DType is SI32 and False otherwise.

is_si64

is_si64(self: Self) -> Bool

Check if this DType is SI64.

Returns:

True if the DType is SI64 and False otherwise.

is_si8

is_si8(self: Self) -> Bool

Check if this DType is SI8.

Returns:

True if the DType is SI8 and False otherwise.

is_signed

is_signed(self: Self) -> Bool

Returns True if the type parameter is signed and False otherwise.

Returns:

Returns True if the input type parameter is signed.

is_ui16

is_ui16(self: Self) -> Bool

Check if this DType is UI16.

Returns:

True if the DType is UI16 and False otherwise.

is_ui32

is_ui32(self: Self) -> Bool

Check if this DType is UI32.

Returns:

True if the DType is UI32 and False otherwise.

is_ui64

is_ui64(self: Self) -> Bool

Check if this DType is UI64.

Returns:

True if the DType is UI64 and False otherwise.

is_ui8

is_ui8(self: Self) -> Bool

Check if this DType is UI8.

Returns:

True if the DType is UI8 and False otherwise.

is_unsigned

is_unsigned(self: Self) -> Bool

Returns True if the type parameter is unsigned and False otherwise.

Returns:

Returns True if the input type parameter is unsigned.

isa

isa[other: Self](self: Self) -> Bool

Check if this DType matches the other one, specified as a parameter.

Parameters:

  • other (Self): The DType to compare against.

Returns:

True if the DTypes are the same and False otherwise.