View Source TFLiteElixir.FlatBufferModel (tflite_elixir v0.1.4)
An RAII object that represents a read-only tflite model, copied from disk, or mmapped.
Link to this section Summary
Functions
Build model from caller owned memory buffer
Raising version of build_from_buffer/1
.
Build model from a given tflite file
Raising version of build_from_file/1
.
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 get_minimum_runtime/1
.
Raising version of initialized/1
.
Return model metadata as a mapping of name & buffer strings.
Raising version of read_all_metadata/1
.
Link to this section Types
@type nif_error() :: {:error, String.t()}
Link to this section Functions
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.
Raising version of build_from_buffer/1
.
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()
Raising version of build_from_file/1
.
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.
Raising version of get_minimum_runtime/1
.
Raising version of initialized/1
.
@spec read_all_metadata(%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 read_all_metadata/1
.