View Source TFLiteElixir.TFLiteTensor (tflite_elixir v0.3.7)

A typed multi-dimensional array used in Tensorflow Lite.

Summary

Functions

Get the dimensions (C++) API

Get the quantization params

Set tensor data

Get the tensor shape

Get binary data

Get the data type

Types

@type nif_error() :: {:error, String.t()}
@type nif_resource_ok() :: {:ok, reference()}
@type tensor_type() ::
  :no_type
  | {:f, 32}
  | {:s, 32}
  | {:u, 8}
  | {:s, 64}
  | :string
  | :bool
  | {:s, 16}
  | {:c, 64}
  | {:s, 8}
  | {:f, 16}
  | {:f, 64}
  | {:c, 128}
  | {:u, 64}
  | :resource
  | :variant
  | {:u, 32}

Functions

@spec dims(%TFLiteElixir.TFLiteTensor{
  index: term(),
  name: term(),
  quantization_params: term(),
  reference: term(),
  shape: term(),
  shape_signature: term(),
  sparsity_params: term(),
  type: term()
}) :: [integer()]
@spec dims(reference()) :: [integer()] | nif_error()

Get the dimensions (C++) API

Link to this function

quantization_params(self)

View Source
@spec quantization_params(
  %TFLiteElixir.TFLiteTensor{
    index: term(),
    name: term(),
    quantization_params: term(),
    reference: term(),
    shape: term(),
    shape_signature: term(),
    sparsity_params: term(),
    type: term()
  }
  | reference()
) ::
  %TFLiteElixir.TFLiteQuantizationParams{
    quantized_dimension: term(),
    scale: term(),
    zero_point: term()
  }
  | nif_error()

Get the quantization params

@spec set_data(
  %TFLiteElixir.TFLiteTensor{
    index: term(),
    name: term(),
    quantization_params: term(),
    reference: term(),
    shape: term(),
    shape_signature: term(),
    sparsity_params: term(),
    type: term()
  }
  | reference(),
  binary()
  | %Nx.Tensor{
      data: term(),
      names: term(),
      shape: term(),
      type: term(),
      vectorized_axes: term()
    }
) :: :ok | nif_error()

Set tensor data

@spec shape(%TFLiteElixir.TFLiteTensor{
  index: term(),
  name: term(),
  quantization_params: term(),
  reference: term(),
  shape: term(),
  shape_signature: term(),
  sparsity_params: term(),
  type: term()
}) :: tuple()
@spec shape(reference()) :: tuple() | nif_error()

Get the tensor shape

Link to this function

to_binary(self, limit \\ 0)

View Source
@spec to_binary(
  %TFLiteElixir.TFLiteTensor{
    index: term(),
    name: term(),
    quantization_params: term(),
    reference: term(),
    shape: term(),
    shape_signature: term(),
    sparsity_params: term(),
    type: term()
  }
  | reference(),
  non_neg_integer()
) :: binary() | {:error, String.t()}

Get binary data

Link to this function

to_nx(self_struct, opts \\ [])

View Source
@spec to_nx(
  reference()
  | %TFLiteElixir.TFLiteTensor{
      index: term(),
      name: term(),
      quantization_params: term(),
      reference: term(),
      shape: term(),
      shape_signature: term(),
      sparsity_params: term(),
      type: term()
    },
  Keyword.t()
) :: %Nx.Tensor{
  data: term(),
  names: term(),
  shape: term(),
  type: term(),
  vectorized_axes: term()
}

Convert TFLiteElixir.TFLiteTensor to Nx.Tensor

@spec type(%TFLiteElixir.TFLiteTensor{
  index: term(),
  name: term(),
  quantization_params: term(),
  reference: term(),
  shape: term(),
  shape_signature: term(),
  sparsity_params: term(),
  type: term()
}) :: tensor_type()
@spec type(reference()) :: tensor_type() | nif_error()

Get the data type