View Source TFLiteElixir.FlatBufferModel (tflite_elixir v0.1.2)

Link to this section Summary

Functions

Build model from caller owned memory buffer

Build model from a given tflite file

Returns the minimum runtime version from the flatbuffer. This runtime version encodes the minimum required interpreter version to run the flatbuffer model. If the minimum version can't be determined, an empty string will be returned.

Raising version of initialized/1.

Return model metadata as a mapping of name & buffer strings.

Link to this section Types

@type nif_error() :: {:error, String.t()}

Link to this section Functions

@spec buildFromBuffer(binary()) ::
  %TFLiteElixir.FlatBufferModel{model: term()} | nif_error()

Build model from caller owned memory buffer

Note that buffer will NOT be copied. Caller has the ensure that the buffer lives longer than the returned reference of TFLite.FlatBufferModel

Discussion:

We can copy the data in the NIF, but FlatBufferModel::BuildFromBuffer always assumes that the buffer is owner by the caller, (in this case, the binding code)

However, we would have no way to release the copied memory because we couldn't identify if the allocation_ borrows or owns that memory.

Link to this function

buildFromBuffer!(buffer)

View Source

Raising version of buildFromBuffer/1.

@spec buildFromFile(String.t()) ::
  %TFLiteElixir.FlatBufferModel{model: term()} | nif_error()

Build model from a given tflite file

Note that if the tensorflow-lite library was compiled with TFLITE_MCU, then this function will always have return type nif_error()

Link to this function

buildFromFile!(filename)

View Source

Raising version of buildFromFile/1.

Link to this function

getMinimumRuntime(flat_buffer_model)

View Source
@spec getMinimumRuntime(%TFLiteElixir.FlatBufferModel{model: term()}) ::
  String.t() | nif_error()

Returns the minimum runtime version from the flatbuffer. This runtime version encodes the minimum required interpreter version to run the flatbuffer model. If the minimum version can't be determined, an empty string will be returned.

Note that the returned minimum version is a lower-bound but not a strict lower-bound; ops in the graph may not have an associated runtime version, in which case the actual required runtime might be greater than the reported minimum.

Link to this function

getMinimumRuntime!(self)

View Source

Raising version of getMinimumRuntime/1.

Link to this function

initialized(flat_buffer_model)

View Source
@spec initialized(%TFLiteElixir.FlatBufferModel{model: term()}) ::
  bool() | nif_error()

Raising version of initialized/1.

Link to this function

readAllMetadata(flat_buffer_model)

View Source
@spec readAllMetadata(%TFLiteElixir.FlatBufferModel{model: term()}) ::
  %{required(String.t()) => String.t()} | nif_error()

Return model metadata as a mapping of name & buffer strings.

See Metadata table in TFLite schema.

Raising version of readAllMetadata/1.