concepts.dsl.dsl_types.VectorValueType#

class VectorValueType[source]#

Bases: TensorValueTypeBase

Methods

assignment_type()

Return the value type for assignment.

downcast_compatible(other[, ...])

Check if the type is downcast-compatible with the other type; that is, if this type is a subtype of the other type.

from_tensor(tensor)

Create a value type from a pytorch tensor.

is_intrinsically_quantized()

Return whether the value type can be quantized.

long_str()

Return the long string representation of the type.

ndim()

Return the number of dimensions of the value type.

short_str()

Return the short string representation of the type.

size()

Return the total size of the value type.

size_tuple()

Return the size of the value type as a tuple.

tensor_dtype()

Return the corresponding PyTorch tensor dtype.

Attributes

alias

An optional alias of the type.

is_list_type

Return whether the type is a list type.

is_object_type

Return whether the type is an object type.

is_pyobj_value_type

Return whether the type is a Python object value type.

is_sequence_type

Return whether the type is a sequence type.

is_tensor_value_type

Return whether the type is a tensor value type.

is_tuple_type

Return whether the type is a tuple type.

is_value_type

Return whether the type is a value type.

parent_type

The parent type of the type.

parent_typename

Return the typename of the parent type.

quantized

Whether the tensor is quantized.

typename

The (full) typename of the type.

dtype

The scalar value type of the vector.

dim

The dimension of the vector.

choices

The number of choices for vector values per factor.

factors

The number of factors of the vector.

__init__(dtype, dim=0, choices=0, factors=1, alias=None)[source]#

Initialize the type.

Parameters:
  • typename – The name of the type.

  • alias (str | None) – The alias of the type.

  • dtype (ScalarValueType) –

  • dim (int) –

  • choices (int) –

  • factors (int) –

__new__(**kwargs)#
assignment_type()[source]#

Return the value type for assignment.

Return type:

VectorValueType

downcast_compatible(other, allow_self_list=False, allow_list=False)#

Check if the type is downcast-compatible with the other type; that is, if this type is a subtype of the other type.

Parameters:
  • other (TypeBase) – the other type.

  • allow_self_list (bool) – if True, this type can be a list type derived from the other type.

  • allow_list (bool) – if True, the other type can be a list type derived from the type.

Return type:

bool

static from_tensor(tensor)#

Create a value type from a pytorch tensor.

Parameters:

tensor (Tensor) – the tensor.

Returns:

the tensor value type.

Return type:

TensorValueTypeBase

is_intrinsically_quantized()[source]#

Return whether the value type can be quantized. In this project, quantizable means we can transform the value into a single integer scalar. Therefore, only BOOL-valued and INTxx-valued tensors are quantizable.

Returns:

True if the value type can be quantized.

Return type:

bool

long_str()[source]#

Return the long string representation of the type.

ndim()[source]#

Return the number of dimensions of the value type.

Return type:

int

short_str()#

Return the short string representation of the type.

Return type:

str

size()[source]#

Return the total size of the value type.

Return type:

int

size_tuple()[source]#

Return the size of the value type as a tuple.

Return type:

Tuple[int]

tensor_dtype()[source]#

Return the corresponding PyTorch tensor dtype.

Return type:

dtype

property alias: str | None#

An optional alias of the type.

choices: int#

The number of choices for vector values per factor.

dim: int#

The dimension of the vector.

dtype: ScalarValueType#

The scalar value type of the vector.

factors: int#

The number of factors of the vector.

property is_list_type#

Return whether the type is a list type.

property is_object_type#

Return whether the type is an object type.

property is_pyobj_value_type#

Return whether the type is a Python object value type.

property is_sequence_type#

Return whether the type is a sequence type.

property is_tensor_value_type#

Return whether the type is a tensor value type.

property is_tuple_type#

Return whether the type is a tuple type.

property is_value_type#

Return whether the type is a value type.

property parent_type: TypeBase | None#

The parent type of the type.

property parent_typename#

Return the typename of the parent type.

property quantized: bool#

Whether the tensor is quantized.

property typename: str#

The (full) typename of the type.