# `Vllm.ScalarType`
[🔗](https://github.com/nshkrdotcom/vllm/blob/v0.3.0/lib/snakebridge_generated/vllm/scalar_type/scalar_type.ex#L7)

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.

# `t`

```elixir
@opaque t()
```

# `_floating_point_max`

```elixir
@spec _floating_point_max(
  SnakeBridge.Ref.t(),
  keyword()
) :: {:ok, float()} | {:error, Snakepit.Error.t()}
```

Python method `ScalarType._floating_point_max`.

## Returns

- `float()`

# `_floating_point_max_int`

```elixir
@spec _floating_point_max_int(
  SnakeBridge.Ref.t(),
  keyword()
) :: {:ok, integer()} | {:error, Snakepit.Error.t()}
```

Python method `ScalarType._floating_point_max_int`.

## Returns

- `integer()`

# `_raw_max`

```elixir
@spec _raw_max(
  SnakeBridge.Ref.t(),
  keyword()
) :: {:ok, term()} | {:error, Snakepit.Error.t()}
```

Python method `ScalarType._raw_max`.

## Returns

- `term()`

# `_raw_min`

```elixir
@spec _raw_min(
  SnakeBridge.Ref.t(),
  keyword()
) :: {:ok, term()} | {:error, Snakepit.Error.t()}
```

Python method `ScalarType._raw_min`.

## Returns

- `term()`

# `float_`

```elixir
@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()`

# `float_ieee754`

```elixir
@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()`

# `from_id`

```elixir
@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()`

# `has_bias`

```elixir
@spec has_bias(
  SnakeBridge.Ref.t(),
  keyword()
) :: {:ok, boolean()} | {:error, Snakepit.Error.t()}
```

If the type has a non-zero bias

## Returns

- `boolean()`

# `has_infs`

```elixir
@spec has_infs(
  SnakeBridge.Ref.t(),
  keyword()
) :: {:ok, boolean()} | {:error, Snakepit.Error.t()}
```

If the type is floating point and supports infinity

## Returns

- `boolean()`

# `has_nans`

```elixir
@spec has_nans(
  SnakeBridge.Ref.t(),
  keyword()
) :: {:ok, boolean()} | {:error, Snakepit.Error.t()}
```

Python method `ScalarType.has_nans`.

## Returns

- `boolean()`

# `id`

```elixir
@spec id(SnakeBridge.Ref.t()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
```

# `int_`

```elixir
@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()`

# `is_floating_point`

```elixir
@spec is_floating_point(
  SnakeBridge.Ref.t(),
  keyword()
) :: {:ok, boolean()} | {:error, Snakepit.Error.t()}
```

If the type is a floating point type

## Returns

- `boolean()`

# `is_ieee_754`

```elixir
@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()`

# `is_integer`

```elixir
@spec is_integer(
  SnakeBridge.Ref.t(),
  keyword()
) :: {:ok, boolean()} | {:error, Snakepit.Error.t()}
```

If the type is an integer type

## Returns

- `boolean()`

# `is_signed`

```elixir
@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()`

# `max`

```elixir
@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()`

# `min`

```elixir
@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()`

# `nan_repr`

```elixir
@spec nan_repr(SnakeBridge.Ref.t()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
```

# `new`

```elixir
@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>)

# `size_bits`

```elixir
@spec size_bits(SnakeBridge.Ref.t()) :: {:ok, term()} | {:error, Snakepit.Error.t()}
```

# `uint`

```elixir
@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()`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
