View Source tflite_beam_interpreter (tflite_beam v0.3.5)
Link to this section Summary
Functions
Return the execution plan of the model.
Get the name of the input tensor
Get the name of the output tensor
Fill data to the specified input tensor
Get the list of input tensors.
Get the data of the output tensor
Get the list of output tensors.
tflite_beam_interpreter:invoke/1
and return output tensor(s).Set the number of threads available to the interpreter.
Returns list of all keys of different method signatures defined in the model.
Get any tensor in the graph by its id
Link to this section Types
-type tflite_beam_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}.
Link to this section Functions
-spec allocate_tensors(reference()) -> ok | {error, binary()}.
-spec execution_plan(reference()) -> [non_neg_integer()] | {error, binary()}.
Return the execution plan of the model.
Experimental interface, subject to change.-spec get_input_name(reference(), non_neg_integer()) -> {ok, binary()} | {error, binary()}.
Get the name of the input tensor
Note that the index here means the index in the result list ofinputs/1
. For example, if inputs/1
returns [42, 314]
, then 0
should be passed here to get the name of tensor 42
-spec get_output_name(reference(), non_neg_integer()) -> {ok, binary()} | {error, binary()}.
Get the name of the output tensor
Note that the index here means the index in the result list ofoutputs/1
. For example, if outputs/1
returns [42, 314]
, then 0
should be passed here to get the name of tensor 42
-spec get_signature_defs(reference()) -> {ok, map()} | nil | {error, binary()}.
-spec input_tensor(reference(), non_neg_integer(), binary()) -> ok | {error, binary()}.
Fill data to the specified input tensor
Note: although we havetyped_input_tensor
available in C++, here what we really passed to the NIF is binary` data, therefore, I
m not pretend that we have type information.
-spec inputs(reference()) -> {ok, [non_neg_integer()]} | {error, binary()}.
Get the list of input tensors.
return a list of input tensor id-spec invoke(reference()) -> ok | {error, binary()}.
-spec new() -> {ok, reference()} | {error, binary()}.
-spec new(list() | binary()) -> {ok, reference()} | {error, binary()}.
-spec new_from_buffer(binary()) -> {ok, reference()} | {error, binary()}.
-spec nodes_size(reference()) -> non_neg_integer() | {error, binary()}.
-spec output_tensor(reference(), non_neg_integer()) -> {ok, binary()} | {error, binary()}.
Get the data of the output tensor
Note that the index here means the index in the result list ofoutputs/1
. For example, if outputs/1
returns [42, 314]
, then 0` should be passed here to get the name of tensor `42
-spec outputs(reference()) -> {ok, [non_neg_integer()]} | {error, binary()}.
Get the list of output tensors.
return a list of output tensor id-spec predict(reference(), [binary()] | binary() | map()) ->
[#tflite_beam_tensor{} | {error, binary()}] | #tflite_beam_tensor{} | {error, binary()}.
tflite_beam_interpreter:invoke/1
and return output tensor(s).
-spec set_inputs(reference(), [integer()]) -> ok | {error, binary()}.
-spec set_num_threads(reference(), integer()) -> ok | {error, binary()}.
Set the number of threads available to the interpreter.
As TfLite interpreter could internally apply a TfLite delegate by default (i.e. XNNPACK), the number of threads that are available to the default delegate should be set via InterpreterBuilder APIs as follows:
{ok, Interpreter} = tflite_beam_interpreter:new(),
{ok, Builder} = tflite_beam_interpreter_builder:new(Model, Resolver),
tflite_beam_interpreter_builder:set_num_threads(Builder, NumThreads),
tflite_beam_interpreter_builder:build(Builder, Interpreter)
-spec set_outputs(reference(), [integer()]) -> ok | {error, binary()}.
-spec set_variables(reference(), [integer()]) -> ok | {error, binary()}.
-spec signature_keys(reference()) -> [binary()] | {error, binary()}.
Returns list of all keys of different method signatures defined in the model.
WARNING: Experimental interface, subject to change-spec tensor(reference(), non_neg_integer()) -> #tflite_beam_tensor{} | {error, binary()}.
Get any tensor in the graph by its id
Note that thetensor_index
here means the id of a tensor. For example, if inputs/1
returns [42, 314]
, then 42
should be passed here to get tensor 42
.
-spec tensors_size(reference()) -> non_neg_integer() | {error, binary()}.
-spec variables(reference()) -> {ok, [non_neg_integer()]} | {error, binary()}.