ScalarType can represent a wide range of floating point and integer
types, in particular it can be used to represent sub-byte data types
(something that torch.dtype currently does not support). It is also
capable of representing types with a bias, i.e.:
stored_value = value + bias,
this is useful for quantized types (e.g. standard GPTQ 4bit uses a bias
of 8). The implementation for this class can be found in
csrc/core/scalar_type.hpp, these type signatures should be kept in sync
with that file.
Summary
Functions
Python method ScalarType._floating_point_max.
Python method ScalarType._floating_point_max_int.
Python method ScalarType._raw_max.
Python method ScalarType._raw_min.
Create a non-standard floating point type
Create a standard floating point type
Python method ScalarType.from_id.
If the type has a non-zero bias
If the type is floating point and supports infinity
Python method ScalarType.has_nans.
Create a signed integer scalar type (size_bits includes sign-bit).
If the type is a floating point type
If the type is a floating point type that follows IEEE 754
If the type is an integer type
If the type is signed (i.e. has a sign bit), same as signed
Max representable value for this scalar type.
Min representable value for this scalar type.
Initialize self. See help(type(self)) for accurate signature.
Create an unsigned integer scalar type.
Types
Functions
@spec _floating_point_max( SnakeBridge.Ref.t(), keyword() ) :: {:ok, float()} | {:error, Snakepit.Error.t()}
Python method ScalarType._floating_point_max.
Returns
float()
@spec _floating_point_max_int( SnakeBridge.Ref.t(), keyword() ) :: {:ok, integer()} | {:error, Snakepit.Error.t()}
Python method ScalarType._floating_point_max_int.
Returns
integer()
@spec _raw_max( SnakeBridge.Ref.t(), keyword() ) :: {:ok, term()} | {:error, Snakepit.Error.t()}
Python method ScalarType._raw_max.
Returns
term()
@spec _raw_min( SnakeBridge.Ref.t(), keyword() ) :: {:ok, term()} | {:error, Snakepit.Error.t()}
Python method ScalarType._raw_min.
Returns
term()
@spec float_( SnakeBridge.Ref.t(), integer(), integer(), boolean(), Vllm.ScalarType.NanRepr.t(), keyword() ) :: {:ok, t()} | {:error, Snakepit.Error.t()}
Create a non-standard floating point type
(i.e. does not follow IEEE 754 conventions).
Parameters
exponent(integer())mantissa(integer())finite_values_only(boolean())nan_repr(Vllm.ScalarType.NanRepr.t())
Returns
Vllm.ScalarType.t()
@spec float_ieee754(SnakeBridge.Ref.t(), integer(), integer(), keyword()) :: {:ok, t()} | {:error, Snakepit.Error.t()}
Create a standard floating point type
(i.e. follows IEEE 754 conventions).
Parameters
exponent(integer())mantissa(integer())
Returns
Vllm.ScalarType.t()
@spec from_id(SnakeBridge.Ref.t(), integer(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
Python method ScalarType.from_id.
Parameters
scalar_type_id(integer())
Returns
term()
@spec has_bias( SnakeBridge.Ref.t(), keyword() ) :: {:ok, boolean()} | {:error, Snakepit.Error.t()}
If the type has a non-zero bias
Returns
boolean()
@spec has_infs( SnakeBridge.Ref.t(), keyword() ) :: {:ok, boolean()} | {:error, Snakepit.Error.t()}
If the type is floating point and supports infinity
Returns
boolean()
@spec has_nans( SnakeBridge.Ref.t(), keyword() ) :: {:ok, boolean()} | {:error, Snakepit.Error.t()}
Python method ScalarType.has_nans.
Returns
boolean()
@spec id(SnakeBridge.Ref.t()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
@spec int_(SnakeBridge.Ref.t(), integer(), term(), keyword()) :: {:ok, t()} | {:error, Snakepit.Error.t()}
Create a signed integer scalar type (size_bits includes sign-bit).
Parameters
size_bits(integer())bias(term())
Returns
Vllm.ScalarType.t()
@spec is_floating_point( SnakeBridge.Ref.t(), keyword() ) :: {:ok, boolean()} | {:error, Snakepit.Error.t()}
If the type is a floating point type
Returns
boolean()
@spec is_ieee_754( SnakeBridge.Ref.t(), keyword() ) :: {:ok, boolean()} | {:error, Snakepit.Error.t()}
If the type is a floating point type that follows IEEE 754
conventions
Returns
boolean()
@spec is_integer( SnakeBridge.Ref.t(), keyword() ) :: {:ok, boolean()} | {:error, Snakepit.Error.t()}
If the type is an integer type
Returns
boolean()
@spec is_signed( SnakeBridge.Ref.t(), keyword() ) :: {:ok, boolean()} | {:error, Snakepit.Error.t()}
If the type is signed (i.e. has a sign bit), same as signed
added for consistency with: https://pytorch.org/docs/stable/generated/torch.Tensor.is_signed.html
Returns
boolean()
@spec max( SnakeBridge.Ref.t(), keyword() ) :: {:ok, term()} | {:error, Snakepit.Error.t()}
Max representable value for this scalar type.
(accounting for bias if there is one)
Returns
term()
@spec min( SnakeBridge.Ref.t(), keyword() ) :: {:ok, term()} | {:error, Snakepit.Error.t()}
Min representable value for this scalar type.
(accounting for bias if there is one)
Returns
term()
@spec nan_repr(SnakeBridge.Ref.t()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
@spec new(integer(), integer(), boolean(), integer(), [term()], keyword()) :: {:ok, SnakeBridge.Ref.t()} | {:error, Snakepit.Error.t()}
Initialize self. See help(type(self)) for accurate signature.
Parameters
exponent(integer())mantissa(integer())signed(boolean())bias(integer())finite_values_only(boolean() default: False)nan_repr(Vllm.ScalarType.NanRepr.t() default: <NanRepr.IEEE_754: 1>)
@spec size_bits(SnakeBridge.Ref.t()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
@spec uint(SnakeBridge.Ref.t(), integer(), term(), keyword()) :: {:ok, t()} | {:error, Snakepit.Error.t()}
Create an unsigned integer scalar type.
Parameters
size_bits(integer())bias(term())
Returns
Vllm.ScalarType.t()