concepts.dsl.dsl_types.ScalarValueType#
- class ScalarValueType[source]#
Bases:
TensorValueTypeBase
Methods
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.
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.
set_parent_type
(parent_type)Return the short string representation of the type.
size
()Return the total size of the value type.
Return the size of the value type as a tuple.
Return the corresponding PyTorch tensor dtype.
Attributes
An optional alias of the type.
Return the typename of the base type.
Return whether the type is a multidimensional list type.
Return whether the type is a list type.
Return whether the type is an object type.
Return whether the type is a Python object value type.
Return whether the type is a sequence type.
Return whether the type is a tensor value type.
Return whether the type is a tuple type.
Return whether the type is a value type.
The parent type of the type.
Return the typename of the parent type.
Whether the tensor is quantized.
The (full) typename of the type.
- __init__(typename)[source]#
Initialize the type.
- Parameters:
typename – The name of the type.
alias – The alias of the type.
- __new__(**kwargs)#
- 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.
- static from_tensor(tensor)#
Create a value type from a pytorch tensor.
- Parameters:
tensor (Tensor) – the tensor.
- Returns:
the tensor value type.
- Return type:
- 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:
- INTRINSICALLY_QUANTIZED_DTYPES = ['bool', 'int32', 'int64']#
- TENSOR_DTYPE_MAPPING = {'bool': torch.int64, 'float32': torch.float32, 'float64': torch.float64, 'int32': torch.int32, 'int64': torch.int64}#
- TENSOR_DTYPE_QUANTIZED = {'bool': True, 'float32': False, 'float64': False, 'int32': True, 'int64': True}#
- property base_typename#
Return the typename of the base type.
- property is_tensor_value_type#
Return whether the type is a tensor value type.
- property is_value_type#
Return whether the type is a value type.
- property parent_typename#
Return the typename of the parent type.