View Source tflite_beam_flatbuffer_model (tflite_beam v0.3.8)

An RAII object that represents a read-only tflite model, copied from disk, or mmapped.

Summary

Functions

Build model from caller owned memory buffer

Build model from caller owned memory buffer

Build model from a given .tflite file

Build model from a given .tflite file

Get the error report of the current FlatBuffer model.

Get associated file(s) from a FlatBuffer model

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.

Check whether current model has been initialized

Get a list of all associated file(s) in a TFLite model file

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

Verifies whether the content of the file is legit, then builds a model based on the file.

Functions

build_from_buffer(Buffer)

-spec build_from_buffer(binary()) ->
                           #tflite_beam_flatbuffer_model{initialized :: boolean(),
                                                         minimum_runtime :: binary(),
                                                         ref :: reference()} |
                           {error, binary()}.

Build model from caller owned memory buffer

build_from_buffer(Buffer, Opts)

-spec build_from_buffer(binary(), list()) ->
                           #tflite_beam_flatbuffer_model{initialized :: boolean(),
                                                         minimum_runtime :: binary(),
                                                         ref :: reference()} |
                           {error, binary()}.

Build model from caller owned memory buffer

build_from_file(Filename)

-spec build_from_file(list() | binary()) ->
                         #tflite_beam_flatbuffer_model{initialized :: boolean(),
                                                       minimum_runtime :: binary(),
                                                       ref :: reference()} |
                         {error, binary()}.

Build model from a given .tflite file

Positional Parameters

build_from_file(Filename, Opts)

-spec build_from_file(list() | binary(), list()) ->
                         #tflite_beam_flatbuffer_model{initialized :: boolean(),
                                                       minimum_runtime :: binary(),
                                                       ref :: reference()} |
                         {error, binary()}.

Build model from a given .tflite file

Positional Parameters

error_reporter(Tflite_beam_flatbuffer_model)

-spec error_reporter(#tflite_beam_flatbuffer_model{initialized :: boolean(),
                                                   minimum_runtime :: binary(),
                                                   ref :: reference()} |
                     reference()) ->
                        #tflite_beam_error_reporter{ref :: reference()} | {error, binary()}.

Get the error report of the current FlatBuffer model.

get_associated_file(Buffer, Filename)

-spec get_associated_file(binary(), [binary()] | binary()) -> map() | binary() | {error, binary()}.

Get associated file(s) from a FlatBuffer model

get_minimum_runtime(Tflite_beam_flatbuffer_model)

-spec get_minimum_runtime(#tflite_beam_flatbuffer_model{initialized :: boolean(),
                                                        minimum_runtime :: binary(),
                                                        ref :: reference()} |
                          reference()) ->
                             binary() | {error, binary()}.

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.

initialized(Tflite_beam_flatbuffer_model)

-spec initialized(#tflite_beam_flatbuffer_model{initialized :: boolean(),
                                                minimum_runtime :: binary(),
                                                ref :: reference()} |
                  reference()) ->
                     boolean() | {error, binary()}.

Check whether current model has been initialized

list_associated_files(Buffer)

-spec list_associated_files(binary()) -> [binary()] | {error, binary()}.

Get a list of all associated file(s) in a TFLite model file

read_all_metadata(Tflite_beam_flatbuffer_model)

-spec read_all_metadata(#tflite_beam_flatbuffer_model{initialized :: boolean(),
                                                      minimum_runtime :: binary(),
                                                      ref :: reference()} |
                        reference()) ->
                           map() | {error, binary()}.

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

See Metadata table in TFLite schema.

verify_and_build_from_file(Filename)

-spec verify_and_build_from_file(list() | binary()) ->
                                    #tflite_beam_flatbuffer_model{initialized :: boolean(),
                                                                  minimum_runtime :: binary(),
                                                                  ref :: reference()} |
                                    {error, binary()}.

Verifies whether the content of the file is legit, then builds a model based on the file.

Positional Parameters

verify_and_build_from_file(Filename, Opts)

-spec verify_and_build_from_file(list() | binary(), list()) ->
                                    #tflite_beam_flatbuffer_model{initialized :: boolean(),
                                                                  minimum_runtime :: binary(),
                                                                  ref :: reference()} |
                                    invalid |
                                    {error, binary()}.