ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnfw_api.cc File Reference
#include "nnfw.h"
#include "nnfw_experimental.h"
#include "nnfw_version.h"
#include "nnfw_session.h"

Go to the source code of this file.

Macros

#define STATIC_ASSERT_ENUM_CHECK(ENUM, VAL)   static_assert((ENUM) == (VAL), #ENUM " has changed")
 
#define NNFW_RETURN_ERROR_IF_NULL(p)
 

Functions

 STATIC_ASSERT_ENUM_CHECK (NNFW_TYPE_TENSOR_FLOAT32, 0)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_TYPE_TENSOR_INT32, 1)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_TYPE_TENSOR_QUANT8_ASYMM, 2)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_TYPE_TENSOR_BOOL, 3)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_TYPE_TENSOR_UINT8, 4)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_TYPE_TENSOR_INT64, 5)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_TYPE_TENSOR_QUANT8_ASYMM_SIGNED, 6)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_TYPE_TENSOR_QUANT16_SYMM_SIGNED, 7)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_STATUS_NO_ERROR, 0)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_STATUS_ERROR, 1)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_STATUS_UNEXPECTED_NULL, 2)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_STATUS_INVALID_STATE, 3)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_STATUS_OUT_OF_MEMORY, 4)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_STATUS_INSUFFICIENT_OUTPUT_SIZE, 5)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_LAYOUT_NONE, 0)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_LAYOUT_CHANNELS_LAST, 1)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_LAYOUT_CHANNELS_FIRST, 2)
 
 STATIC_ASSERT_ENUM_CHECK (NNFW_INFO_ID_VERSION, 0)
 
NNFW_STATUS nnfw_create_session (nnfw_session **session)
 Create a new session instance.
 
NNFW_STATUS nnfw_close_session (nnfw_session *session)
 Close a session instance.
 
NNFW_STATUS nnfw_load_model_from_file (nnfw_session *session, const char *path)
 Load model from nnpackage file or directory.
 
NNFW_STATUS nnfw_prepare (nnfw_session *session)
 Prepare session to be ready for inference.
 
NNFW_STATUS nnfw_run (nnfw_session *session)
 Run inference.
 
NNFW_STATUS nnfw_run_async (nnfw_session *session)
 Run inference asynchronously.
 
NNFW_STATUS nnfw_await (nnfw_session *session)
 Wait for asynchronous run to finish.
 
NNFW_STATUS nnfw_set_input (nnfw_session *session, uint32_t index, NNFW_TYPE type, const void *buffer, size_t length)
 Set input buffer.
 
NNFW_STATUS nnfw_set_output (nnfw_session *session, uint32_t index, NNFW_TYPE type, void *buffer, size_t length)
 Set output buffer.
 
NNFW_STATUS nnfw_input_size (nnfw_session *session, uint32_t *number)
 Get the number of inputs.
 
NNFW_STATUS nnfw_output_size (nnfw_session *session, uint32_t *number)
 Get the number of outputs.
 
NNFW_STATUS nnfw_set_input_layout (nnfw_session *session, uint32_t index, NNFW_LAYOUT layout)
 Set the layout of an input.
 
NNFW_STATUS nnfw_set_output_layout (nnfw_session *session, uint32_t index, NNFW_LAYOUT layout)
 Set the layout of an output.
 
NNFW_STATUS nnfw_input_tensorinfo (nnfw_session *session, uint32_t index, nnfw_tensorinfo *tensor_info)
 Get i-th input tensor info.
 
NNFW_STATUS nnfw_output_tensorinfo (nnfw_session *session, uint32_t index, nnfw_tensorinfo *tensor_info)
 Get i-th output tensor info.
 
NNFW_STATUS nnfw_register_custom_op_info (nnfw_session *session, const char *id, custom_kernel_registration_info *info)
 
NNFW_STATUS nnfw_apply_tensorinfo (nnfw_session *, uint32_t, nnfw_tensorinfo)
 Apply i-th input's tensor info to resize input tensor.
 
NNFW_STATUS nnfw_set_input_tensorinfo (nnfw_session *session, uint32_t index, const nnfw_tensorinfo *tensor_info)
 Set input model's tensor info for resizing.
 
NNFW_STATUS nnfw_set_available_backends (nnfw_session *session, const char *backends)
 Set available backends.
 
NNFW_STATUS nnfw_set_op_backend (nnfw_session *, const char *, const char *)
 Set the operation's backend.
 
NNFW_STATUS nnfw_query_info_u32 (nnfw_session *session, NNFW_INFO_ID id, uint32_t *val)
 Retrieve uint32 type of nnfw information for given information ID.
 
NNFW_STATUS nnfw_input_tensorindex (nnfw_session *session, const char *tensorname, uint32_t *index)
 Get the input tensor index by name.
 
NNFW_STATUS nnfw_output_tensorindex (nnfw_session *session, const char *tensorname, uint32_t *index)
 Get the input tensor index by name.
 
NNFW_STATUS nnfw_set_backends_per_operation (nnfw_session *session, const char *backend_settings)
 Set the backend for each operation in the session.
 
NNFW_STATUS nnfw_prepare_pipeline (nnfw_session *, const char *)
 Prepare session to be ready for inference.
 
NNFW_STATUS nnfw_push_pipeline_input (nnfw_session *, void *, void *)
 Set input buffer.
 
NNFW_STATUS nnfw_pop_pipeline_output (nnfw_session *, void *)
 Get last outputs of partitioned model in session.
 
NNFW_STATUS nnfw_set_workspace (nnfw_session *session, const char *dir)
 Set runtime's workspace directory.
 
NNFW_STATUS nnfw_train_get_traininfo (nnfw_session *session, nnfw_train_info *info)
 Get training information.
 
NNFW_STATUS nnfw_train_set_traininfo (nnfw_session *session, const nnfw_train_info *info)
 Set training information.
 
NNFW_STATUS nnfw_train_prepare (nnfw_session *session)
 Prepare session to be ready for training.
 
NNFW_STATUS nnfw_train_input_tensorinfo (nnfw_session *session, uint32_t index, nnfw_tensorinfo *info)
 Get the training model input information.
 
NNFW_STATUS nnfw_train_expected_tensorinfo (nnfw_session *session, uint32_t index, nnfw_tensorinfo *info)
 Get the training model expected output information.
 
NNFW_STATUS nnfw_train_set_input (nnfw_session *session, uint32_t index, const void *input, const nnfw_tensorinfo *input_info)
 Set training input.
 
NNFW_STATUS nnfw_train_set_expected (nnfw_session *session, uint32_t index, const void *expected, const nnfw_tensorinfo *expected_info)
 Set training expected output.
 
NNFW_STATUS nnfw_train_set_output (nnfw_session *session, uint32_t index, NNFW_TYPE type, void *buffer, size_t length)
 Set training output buffer.
 
NNFW_STATUS nnfw_train (nnfw_session *session, bool update_weights)
 Train the model.
 
NNFW_STATUS nnfw_train_get_loss (nnfw_session *session, uint32_t index, float *loss)
 Get loss value for expected output.
 
NNFW_STATUS nnfw_train_export_circle (nnfw_session *session, const char *path)
 Export current training model into circle model.
 
NNFW_STATUS nnfw_train_import_checkpoint (nnfw_session *session, const char *path)
 Import circle checkpoint.
 
NNFW_STATUS nnfw_train_export_checkpoint (nnfw_session *session, const char *path)
 Export circle checkpoint.
 
NNFW_STATUS nnfw_set_quantization_type (nnfw_session *session, NNFW_QUANTIZE_TYPE qtype)
 Set quantization type.
 
NNFW_STATUS nnfw_set_quantized_model_path (nnfw_session *session, const char *path)
 Set exported quantized model path.
 
NNFW_STATUS nnfw_quantize (nnfw_session *session)
 Quantize circle model.
 
NNFW_STATUS nnfw_set_codegen_model_path (nnfw_session *session, const char *path)
 Set exported codegen model path.
 
NNFW_STATUS nnfw_codegen (nnfw_session *session, const char *target, NNFW_CODEGEN_PREF pref)
 Generate target-dependent code.
 
NNFW_STATUS nnfw_set_odc_param_minmax_records_count (nnfw_session *session, int minmax_records_count)
 Set MinMax records count in auto compilation mode with on-device compiler.
 
NNFW_STATUS nnfw_odc_delete_minmax_file (nnfw_session *session)
 Delete MinMax file for on-device compiler.
 
NNFW_STATUS nnfw_run_with_auto_compilation (nnfw_session *session, const char *target, NNFW_CODEGEN_PREF pref)
 Run inference with auto compilation.
 
NNFW_STATUS nnfw_set_prepare_config (nnfw_session *session, const NNFW_PREPARE_CONFIG key, const char *value)
 Set prepare configuration.
 
NNFW_STATUS nnfw_reset_prepare_config (nnfw_session *session)
 Reset prepare configurations.
 
NNFW_STATUS nnfw_set_execute_config (nnfw_session *session, const NNFW_RUN_CONFIG key, const char *value)
 Set execution (run or train) configuration.
 
NNFW_STATUS nnfw_reset_execute_config (nnfw_session *session)
 Reset execution (run or train) configurations.
 

Macro Definition Documentation

◆ NNFW_RETURN_ERROR_IF_NULL

#define NNFW_RETURN_ERROR_IF_NULL (   p)
Value:
do \
{ \
if ((p) == NULL) \
} while (0)
@ NNFW_STATUS_UNEXPECTED_NULL
Definition onert-micro.h:95

Definition at line 51 of file nnfw_api.cc.

53 { \
54 if ((p) == NULL) \
56 } while (0)

◆ STATIC_ASSERT_ENUM_CHECK

#define STATIC_ASSERT_ENUM_CHECK (   ENUM,
  VAL 
)    static_assert((ENUM) == (VAL), #ENUM " has changed")

Definition at line 25 of file nnfw_api.cc.

Function Documentation

◆ nnfw_apply_tensorinfo()

NNFW_STATUS nnfw_apply_tensorinfo ( nnfw_session session,
uint32_t  index,
nnfw_tensorinfo  tensor_info 
)

Apply i-th input's tensor info to resize input tensor.

This function should be called before nnfw_prepare is invoked, and should be called after nnfw_load_model_from_file is invoked See nnfw_prepare for information applying updated tensor info If this function is called many times for same index, tensor info is overwritten

Parameters
[in]sessionSession to the input tensor info is to be set
[in]indexIndex of input to be applied (0-indexed)
[in]tensor_infoTensor info to be applied
Returns
NNFW_STATUS_NO_ERROR if successful, otherwise return NNFW_STATUS_ERROR

Definition at line 155 of file nnfw_api.cc.

156{
157 return nnfw_session::deprecated("nnfw_apply_tensorinfo: Deprecated");
158}
static NNFW_STATUS deprecated(const char *msg)

References nnfw_session::deprecated().

◆ nnfw_await()

NNFW_STATUS nnfw_await ( nnfw_session session)

Wait for asynchronous run to finish.

This function must be called after calling nnfw_run_async, and can be called only once for a nnfw_run_async call.

When this function returns, it means that this session has finished the asynchronous run. Then the user can safely use the output data.

This function returns after the asynchronous inference is finished.

Parameters
[in]sessionThe session to run inference
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 90 of file nnfw_api.cc.

91{
93 return session->await();
94}
SessionID session(const coco::Module *m)
Definition Session.cpp:48
#define NNFW_RETURN_ERROR_IF_NULL(p)
Definition nnfw_api.cc:51

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by NNFW_SESSION::wait().

◆ nnfw_close_session()

NNFW_STATUS nnfw_close_session ( nnfw_session session)

Close a session instance.

After called, access to closed session by application will be invalid

Parameters
[in]sessionThe session to be closed
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 60 of file nnfw_api.cc.

61{
62 delete session;
64}
@ NNFW_STATUS_NO_ERROR
Definition onert-micro.h:88

References NNFW_STATUS_NO_ERROR.

Referenced by NNFW_SESSION::close_session(), and main().

◆ nnfw_codegen()

NNFW_STATUS nnfw_codegen ( nnfw_session session,
const char *  target,
NNFW_CODEGEN_PREF  pref 
)

Generate target-dependent code.

This function opens a dynamic shared object. It searches for the object as flollows ld.so(8) search rules. If the nnfw_set_codegen_model_path is not called before this function, the codegen model path is automatically defined and used using the same directory of the original model/package with the target backend extension.

Parameters
[in]sessionnnfw_session the session which contains information about compilation
[in]targetTarget backend to generate code This target string will be used to find a backend library. The name of target backend library should follow the following rules: 'lib' + {backend extension} + '-gen' + {lib extension} And the target string should be a name except 'lib' and {lib extension}. For example, if the backend extension is 'aaa', the backend library should be 'libaaa-gen.so', and the target string should be 'aaa-gen'.
[in]prefNNFW_CODEGEN_PREF
Returns
NNFW_STATUS_NO_ERROR if successful, otherwise return NNFW_STATUS_ERROR

Definition at line 347 of file nnfw_api.cc.

348{
350 return session->codegen(target, pref);
351}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_create_session()

NNFW_STATUS nnfw_create_session ( nnfw_session **  session)

Create a new session instance.

This only creates a session. Model is loaded after nnfw_load_model_from_file is invoked. And inference is performed after nnfw_run is invoked.

nnfw_close_session should be called once if session is no longer needed

Parameters
[out]sessionThe session to be created
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 58 of file nnfw_api.cc.

58{ return nnfw_session::create(session); }
static NNFW_STATUS create(nnfw_session **session)
Factory method. It creates and initialize nnfw_session.

References nnfw_session::create().

Referenced by main(), and NNFW_SESSION::NNFW_SESSION().

◆ nnfw_input_size()

NNFW_STATUS nnfw_input_size ( nnfw_session session,
uint32_t *  number 
)

Get the number of inputs.

Application can call this function to get number of inputs defined in loaded model. This function should be called after nnfw_load_model_from_file is invoked to load model

Parameters
[in]sessionSession from input information is to be extracted
[out]numberVariable which the number of inputs is put into
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 110 of file nnfw_api.cc.

111{
113 return session->input_size(number);
114}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by NNFW_SESSION::input_size().

◆ nnfw_input_tensorindex()

NNFW_STATUS nnfw_input_tensorindex ( nnfw_session session,
const char *  tensorname,
uint32_t *  index 
)

Get the input tensor index by name.

This function finds an input tensor of the given name. If found, the index value is set to the address that index points to, and returns NNFW_STATUS_NO_ERROR. Otherwise, index is unchanged and returns NNFW_STATUS_ERROR .

Note
If two or more input tensors are of the same name, the one with the lowest index is always returned.
Parameters
[in]sessionthe session object
[in]tensornamethe name of the tensor to find, a null terminated char pointer string
[out]indexthe index to be ret
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 197 of file nnfw_api.cc.

198{
200 return session->input_tensorindex(tensorname, index);
201}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_input_tensorinfo()

NNFW_STATUS nnfw_input_tensorinfo ( nnfw_session session,
uint32_t  index,
nnfw_tensorinfo tensor_info 
)

Get i-th input tensor info.

Before nnfw_prepare is invoked, this function return tensor info in model, so updated tensor info by nnfw_apply_tensorinfo is not returned.

After nnfw_prepare is invoked, this function return updated tensor info if tensor info is updated by nnfw_apply_tensorinfo.

Parameters
[in]sessionSession from input information is to be extracted
[in]indexIndex of input
[out]tensor_infoTensor info (shape, type, etc)
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 134 of file nnfw_api.cc.

136{
138 return session->input_tensorinfo(index, tensor_info);
139}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by NNFW_SESSION::input_tensorinfo(), main(), and NNFW_SESSION::set_input().

◆ nnfw_load_model_from_file()

NNFW_STATUS nnfw_load_model_from_file ( nnfw_session session,
const char *  package_file_path 
)

Load model from nnpackage file or directory.

Load model from path to model or nnpackage.

The length of package_file_path must not exceed 1024 bytes including zero at the end.

Parameters
[in]sessionnnfw_session loading the given nnpackage file/dir
[in]package_file_pathPath to the nnpackage file or unzipped directory to be loaded
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 66 of file nnfw_api.cc.

67{
69 return session->load_model_from_path(path);
70}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by main(), and NNFW_SESSION::NNFW_SESSION().

◆ nnfw_odc_delete_minmax_file()

NNFW_STATUS nnfw_odc_delete_minmax_file ( nnfw_session session)

Delete MinMax file for on-device compiler.

Parameters
[in]sessionnnfw_session
Returns
NNFW_STATUS_NO_ERROR if successful, otherwise return NNFW_STATUS_ERROR

Definition at line 359 of file nnfw_api.cc.

360{
362 return session->delete_odc_minmax_file();
363}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_output_size()

NNFW_STATUS nnfw_output_size ( nnfw_session session,
uint32_t *  number 
)

Get the number of outputs.

Application can call this function to get number of outputs defined in loaded model. This function should be called after nnfw_load_model_from_file is invoked to load model

Parameters
[in]sessionSession from output information is to be extracted
[out]numberVariable which the number of outputs is put into
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 116 of file nnfw_api.cc.

117{
119 return session->output_size(number);
120}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by NNFW_SESSION::output_size().

◆ nnfw_output_tensorindex()

NNFW_STATUS nnfw_output_tensorindex ( nnfw_session session,
const char *  tensorname,
uint32_t *  index 
)

Get the input tensor index by name.

This function finds an input tensor of the given name. If found, the index value is set to the address that index points to, and returns NNFW_STATUS_NO_ERROR. Otherwise, index is unchanged and returns NNFW_STATUS_ERROR .

Note
If two or more input tensors are of the same name, the one with the lowest index is always returned.
Parameters
[in]sessionthe session object
[in]tensornamethe name of the tensor to find, a null terminated char pointer string
[out]indexthe index to be ret
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 203 of file nnfw_api.cc.

204{
206 return session->output_tensorindex(tensorname, index);
207}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_output_tensorinfo()

NNFW_STATUS nnfw_output_tensorinfo ( nnfw_session session,
uint32_t  index,
nnfw_tensorinfo tensor_info 
)

Get i-th output tensor info.

After nnfw_load_model_from_file and before nnfw_prepare is invoked, it returns tensor info in the model.

After nnfw_prepare and before nnfw_run is invoked, this function returns updated tensor info if tensor info is updated by nnfw_set_input_tensorinfo.

After nnfw_run is invoked(at least once), it returns the updated tensor info during the latest execution.

Parameters
[in]sessionSession from output information is to be extracted
[in]indexIndex of output
[out]tensor_infoTensor info (shape, type, etc)
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 141 of file nnfw_api.cc.

143{
145 return session->output_tensorinfo(index, tensor_info);
146}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by main(), NNFW_SESSION::output_tensorinfo(), and NNFW_SESSION::set_output().

◆ nnfw_pop_pipeline_output()

NNFW_STATUS nnfw_pop_pipeline_output ( nnfw_session session,
void *  outputs 
)

Get last outputs of partitioned model in session.

This function must be called after nnfw_prepare_pipeline, outputs given to this function must be cleared for memory management.

Parameters
[in]sessionSession from last outputs is to be extracted
[out]outputsRaw buffer for outputs, it must be std::vector<void *> type pointer for multiple output model
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 225 of file nnfw_api.cc.

226{
227 return nnfw_session::deprecated("nnfw_pop_pipeline_output: Deprecated");
228}

References nnfw_session::deprecated().

◆ nnfw_prepare()

NNFW_STATUS nnfw_prepare ( nnfw_session session)

Prepare session to be ready for inference.

This phase may finalize model compilation, scheduling, and additional settings. If nnfw_apply_tensorinfo is called to apply input tensor info different with model before this function, tries to resize all tensors.

Parameters
[in]sessionthe session to be prepared
Returns
NNFW_STATUS_NO_ERROR if successful, otherwise return NNFW_STATUS_ERROR

Definition at line 72 of file nnfw_api.cc.

73{
75 return session->prepare();
76}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by main(), and NNFW_SESSION::NNFW_SESSION().

◆ nnfw_prepare_pipeline()

NNFW_STATUS nnfw_prepare_pipeline ( nnfw_session session,
const char *  map_file_path = nullptr 
)

Prepare session to be ready for inference.

This phase may finalize model compilation, scheduling, and additional settings.

Parameters
sessionthe session to be prepared
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 215 of file nnfw_api.cc.

216{
217 return nnfw_session::deprecated("nnfw_prepare_pipeline: Deprecated");
218}

References nnfw_session::deprecated().

◆ nnfw_push_pipeline_input()

NNFW_STATUS nnfw_push_pipeline_input ( nnfw_session session,
void *  inputs,
void *  lengths 
)

Set input buffer.

This function must be called after nnfw_prepare_pipeline, inputs given to this function can be reused for many inferences. lengths must be greater or equal than the operand requires. if you give empty inputs to this function, then this function will join all threads.

Parameters
[in]sessionSession to the input is to be set
[in]inputsRaw buffers for input, it must be std::vector<void *> type pointer for multiple input model
[in]lengthsSize of bytes of input buffers, it must be std::vector<uint32_t> type pointer for multiple input model
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 220 of file nnfw_api.cc.

221{
222 return nnfw_session::deprecated("nnfw_push_pipeline_input: Deprecated");
223}

References nnfw_session::deprecated().

◆ nnfw_quantize()

NNFW_STATUS nnfw_quantize ( nnfw_session session)

Quantize circle model.

Parameters
[in]sessionnnfw_session to quantize
Returns
ODC_STATUS_NO_ERROR if successful, otherwise return ODC_STATUS_ERROR

Definition at line 335 of file nnfw_api.cc.

336{
338 return session->quantize();
339}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_query_info_u32()

NNFW_STATUS nnfw_query_info_u32 ( nnfw_session session,
NNFW_INFO_ID  id,
uint32_t *  val 
)

Retrieve uint32 type of nnfw information for given information ID.

Retrieves the information of property given by information id

Note
: The input session could be null for global information (e.g. runtime version).*
Parameters
[in]sessionsession to be queried on.
[in]idID to be queried
[out]valuint32 value to be returned.
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 178 of file nnfw_api.cc.

179{
180 (void)session;
181 switch (id)
182 {
184 if (val)
185 {
186 *val = NNFW_VERSION;
188 }
189 break;
190 default:
191 return NNFW_STATUS_ERROR;
192 }
193 // It should not be reached.
194 return NNFW_STATUS_ERROR;
195}
@ NNFW_INFO_ID_VERSION
Definition nnfw.h:157
#define NNFW_VERSION
@ NNFW_STATUS_ERROR
Definition onert-micro.h:93

References NNFW_INFO_ID_VERSION, NNFW_STATUS_ERROR, NNFW_STATUS_NO_ERROR, and NNFW_VERSION.

◆ nnfw_register_custom_op_info()

NNFW_STATUS nnfw_register_custom_op_info ( nnfw_session session,
const char *  id,
custom_kernel_registration_info info 
)

Definition at line 148 of file nnfw_api.cc.

150{
152 return session->register_custom_operation(id, info->eval_function);
153}
volatile const char info[]

References info, and NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_reset_execute_config()

NNFW_STATUS nnfw_reset_execute_config ( nnfw_session session)

Reset execution (run or train) configurations.

This function reset all execution configuration.

Parameters
[in]sessionnnfw_session to reset all execution configurations
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 394 of file nnfw_api.cc.

395{
397 return session->reset_execute_config();
398}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_reset_prepare_config()

NNFW_STATUS nnfw_reset_prepare_config ( nnfw_session session)

Reset prepare configurations.

This function reset all prepare configuration.

Parameters
[in]sessionnnfw_session to reset all prepare configurations
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 381 of file nnfw_api.cc.

382{
384 return session->reset_prepare_config();
385}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_run()

NNFW_STATUS nnfw_run ( nnfw_session session)

Run inference.

This function should be called after model is loaded by nnfw_load_model_from_file, session is prepared for inference by nnfw_prepare, set input and output buffers by nnfw_set_input and nnfw_set_output.

This function return after inference is finished.

Parameters
[in]sessionThe session to run inference
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 78 of file nnfw_api.cc.

79{
81 return session->run();
82}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by main(), and NNFW_SESSION::run().

◆ nnfw_run_async()

NNFW_STATUS nnfw_run_async ( nnfw_session session)

Run inference asynchronously.

This function must be called after model is loaded by nnfw_load_model_from_file, session is prepared for inference by nnfw_prepare, set input and output buffers by nnfw_set_input and nnfw_set_output.

This function returns immediately after starting a thread to run the inference. To get the result of it or to do the next inference with nnfw_run or nnfw_run_async, nnfw_await must be called to ensure the current asynchronous inference has finished. Only one asynchronous inference is allowed at a time for a session. If this function is called while the previous one is still running, it returns an error.

Parameters
[in]sessionThe session to run inference
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 84 of file nnfw_api.cc.

85{
87 return session->run_async();
88}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by NNFW_SESSION::run_async().

◆ nnfw_run_with_auto_compilation()

NNFW_STATUS nnfw_run_with_auto_compilation ( nnfw_session session,
const char *  target,
NNFW_CODEGEN_PREF  pref 
)

Run inference with auto compilation.

This function runs inference with automatic compilation and replaces the original model with a quantized or compiled model inside. During the inference the minmax statistics is collected and after that quantization is performed. If quantization was successful, try to code generating for target backend, otherwise run original float model. If compilation was successful, run compiled model, otherwise run quantized model. On-device compiler (ODC) provides quantization and compilation functionality. Function should be called after model is loaded by nnfw_load_model_from_file, session is prepared for inference by nnfw_prepare, set input and output buffers by nnfw_set_input and nnfw_set_output.

Additionally the following parameters should be set up :

  1. Quantization type nnfw_set_quantization_type
  2. Quantizated model path nnfw_set_quantized_model_path
  3. Minmax records threshold for quantization nnfw_set_odc_param_minmax_records_count
  1. File with minMax statistics can be removed by nnfw_odc_delete_minmax_file
  2. Compiled model path nnfw_set_codegen_model_path
Parameters
[in]sessionnnfw_session
[in]targetTarget backend to generate code as in nnfw_codegen
[in]prefNNFW_CODEGEN_PREF
Returns
NNFW_STATUS_NO_ERROR if successful, otherwise return NNFW_STATUS_ERROR

Definition at line 365 of file nnfw_api.cc.

367{
369 return session->run_with_auto_compilation(target, pref);
370}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_set_available_backends()

NNFW_STATUS nnfw_set_available_backends ( nnfw_session session,
const char *  backends 
)

Set available backends.

This function should be called before nnfw_prepare is invoked.

Supported backends differs on each platforms. For example, x86_64 supports "cpu" only. Multiple backends can be set and they must be separated by a semicolon (ex: "acl_cl;cpu"). For each backend string, libbackend_{backend}.so will be dynamically loaded during nnfw_prepare. Among the multiple backends, the 1st element is used as the default backend.

Parameters
[in]sessionsession to which avilable backends are set
[in]backendsavailable backends on which nnfw uses
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 167 of file nnfw_api.cc.

168{
170 return session->set_available_backends(backends);
171}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by NNFW_SESSION::NNFW_SESSION().

◆ nnfw_set_backends_per_operation()

NNFW_STATUS nnfw_set_backends_per_operation ( nnfw_session session,
const char *  backend_settings 
)

Set the backend for each operation in the session.

This function assigns backends (acl_cl, acl_neon, cpu) to each operation in the session. If successful,the function returns NNFW_STATUS_NO_ERROR. Otherwise, the function returns NNFW_STATUS_ERROR.

Note
The argument specifying backends must be in the format "OP_BACKEND_MAP=\"0=acl_cl;1=cpu;2=acl_cl\"".
Parameters
[in]sessionthe session object
[in]backend_settingsString containing backend assignments indexed by operation sequence
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 209 of file nnfw_api.cc.

210{
212 return session->set_backends_per_operation(backend_settings);
213}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_set_codegen_model_path()

NNFW_STATUS nnfw_set_codegen_model_path ( nnfw_session session,
const char *  path 
)

Set exported codegen model path.

This function should be called before nnfw_codegen is invoked.

Parameters
[in]sessionnnfw_session to set codegen model path
[in]pathTarget-dependent model path
Returns
NNFW_STATUS_NO_ERROR if successful, otherwise return NNFW_STATUS_ERROR

Definition at line 341 of file nnfw_api.cc.

342{
344 return session->set_codegen_model_path(path);
345}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_set_execute_config()

NNFW_STATUS nnfw_set_execute_config ( nnfw_session session,
const NNFW_RUN_CONFIG  key,
const char *  value 
)

Set execution (run or train) configuration.

This function set execution configuration to dump execution data to workspace. If you enable configuration to dump execution data into workspace and want to change workspace, refer nnfw_set_workspace to use workspace directory.

Parameters
[in]sessionnnfw_session to set execution configuration
[in]keyexecution configuration key
[in]valueexecution configuration value if needed, otherwise set NULL
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 387 of file nnfw_api.cc.

389{
391 return session->set_execute_config(key, value);
392}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_set_input()

NNFW_STATUS nnfw_set_input ( nnfw_session session,
uint32_t  index,
NNFW_TYPE  type,
const void *  buffer,
size_t  length 
)

Set input buffer.

This function must be called after nnfw_prepare, buffer given to this function can be reused for many inferences. length must be greater or equal than the operand requires. To specify an optional input, you can either not call this for that input or call this with buffer of NULL and length of 0. If you set NNFW_TYPE_TENSOR_FLOAT32 type and model has quantized input type on given index, runtime will set quantized data type model input by converting from float buffer data internally.

Parameters
[in]sessionSession to the input is to be set
[in]indexIndex of input to be set (0-indexed)
[in]typeType of the input
[in]bufferRaw buffer for input
[in]lengthSize of bytes of input buffer
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 96 of file nnfw_api.cc.

98{
100 return session->set_input(index, type, buffer, length);
101}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by main(), and NNFW_SESSION::set_input().

◆ nnfw_set_input_layout()

NNFW_STATUS nnfw_set_input_layout ( nnfw_session session,
uint32_t  index,
NNFW_LAYOUT  layout 
)

Set the layout of an input.

The input that does not call this has NNFW_LAYOUT_NHWC layout

Parameters
[in]sessionsession from inference input is to be extracted
[in]indexindex of input to be set (0-indexed)
[in]layoutlayout to set to target input
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 122 of file nnfw_api.cc.

123{
125 return session->set_input_layout(index, layout);
126}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by NNFW_SESSION::set_input_layout().

◆ nnfw_set_input_tensorinfo()

NNFW_STATUS nnfw_set_input_tensorinfo ( nnfw_session session,
uint32_t  index,
const nnfw_tensorinfo tensor_info 
)

Set input model's tensor info for resizing.

This function can be called at any time after calling nnfw_load_model_from_file. Changing input tensor's shape will cause shape inference for the model. There are two different types of shape inference - static and dynamic. Which one to use is depend on the current state of the session. When it is called after calling nnfw_load_model_from_file and before calling nnfw_prepare, this info will be used when nnfw_prepare. And it will perform static shape inference for all tensors. When it is called after calling nnfw_prepare or even after nnfw_run, this info will be used when nnfw_run. And the shapes of the tensors are determined on the fly. If this function is called many times for the same index, it is overwritten. tensor_info's dtype field is ignored.

Parameters
[in]sessionSession to the input tensor info is to be set
[in]indexIndex of input to be set (0-indexed)
[in]tensor_infoTensor info to be set
Returns
NNFW_STATUS_NO_ERROR if successful, otherwise return NNFW_STATUS_ERROR

Definition at line 160 of file nnfw_api.cc.

162{
164 return session->set_input_tensorinfo(index, tensor_info);
165}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by NNFW_SESSION::set_input_tensorinfo().

◆ nnfw_set_odc_param_minmax_records_count()

NNFW_STATUS nnfw_set_odc_param_minmax_records_count ( nnfw_session session,
int  minmax_records_count 
)

Set MinMax records count in auto compilation mode with on-device compiler.

This function set MinMax records count for quantization in auto compilation mode. To enable automatic compilation mode, use nnfw_run_with_auto_compilation

Parameters
[in]sessionnnfw_session
[in]minmax_records_countminmax records count
Returns
NNFW_STATUS_NO_ERROR if successful, otherwise return NNFW_STATUS_ERROR

Definition at line 353 of file nnfw_api.cc.

354{
356 return session->set_odc_param_minmax_records_count(minmax_records_count);
357}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_set_op_backend()

NNFW_STATUS nnfw_set_op_backend ( nnfw_session session,
const char *  op,
const char *  backend 
)

Set the operation's backend.

This function should be called before nnfw_prepare is invoked.

The backend for op has higher priority than available backends specified by nnfw_set_available_backends.

Parameters
[in]sessionsession to be modified
[in]opoperation to be set
[in]backendbakcend on which operation run
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 173 of file nnfw_api.cc.

174{
175 return nnfw_session::deprecated("nnfw_set_op_backend: Deprecated");
176}

References nnfw_session::deprecated().

Referenced by main().

◆ nnfw_set_output()

NNFW_STATUS nnfw_set_output ( nnfw_session session,
uint32_t  index,
NNFW_TYPE  type,
void *  buffer,
size_t  length 
)

Set output buffer.

This function must be called after nnfw_prepare, buffer given to this function can be reused for many inferences. length must be greater or equal than the operand requires. An output operand can have unspecified shape and deduced dynamically during the execution. You must provide buffer large enough. If you set NNFW_TYPE_TENSOR_FLOAT32 type and model has quantized output type on given index, runtime will set dequantized float buffer data from quantize data type model output internally.

Parameters
[in]sessionSession from inference output is to be extracted
[in]indexIndex of output to be set (0-indexed)
[in]typeType of the output
[out]bufferRaw buffer for output
[in]lengthSize of bytes of output buffer
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 103 of file nnfw_api.cc.

105{
107 return session->set_output(index, type, buffer, length);
108}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by main(), and NNFW_SESSION::set_output().

◆ nnfw_set_output_layout()

NNFW_STATUS nnfw_set_output_layout ( nnfw_session session,
uint32_t  index,
NNFW_LAYOUT  layout 
)

Set the layout of an output.

The output that does not call this has NNFW_LAYOUT_NHWC layout

Parameters
[in]sessionsession from inference output is to be extracted
[in]indexindex of output to be set (0-indexed)
[in]layoutlayout to set to target output
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 128 of file nnfw_api.cc.

129{
131 return session->set_output_layout(index, layout);
132}

References NNFW_RETURN_ERROR_IF_NULL.

Referenced by NNFW_SESSION::set_output_layout().

◆ nnfw_set_prepare_config()

NNFW_STATUS nnfw_set_prepare_config ( nnfw_session session,
NNFW_PREPARE_CONFIG  key,
const char *  value 
)

Set prepare configuration.

This function set prepare configuration to decide additional compiling and scheduing feature. If you enable configuration to prepare dumping execution data into workspace, refer nnfw_set_workspace to use workspace directory.

Parameters
[in]sessionnnfw_session to set prepare configuration
[in]keyprepare configuration key
[in]valueprepare configuration value
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 374 of file nnfw_api.cc.

376{
378 return session->set_prepare_config(key, value);
379}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_set_quantization_type()

NNFW_STATUS nnfw_set_quantization_type ( nnfw_session session,
NNFW_QUANTIZE_TYPE  qtype 
)

Set quantization type.

This function should be called before nnfw_quantize is invoked.

Parameters
[in]sessionnnfw_session to set quantization type
[in]prefNNFW_QUANTIZE_TYPE
Returns
NNFW_STATUS_NO_ERROR if successful, NNFW_STATUS_UNEXPECTED_NULL if session is null, otherwise return NNFW_STATUS_ERROR

Definition at line 323 of file nnfw_api.cc.

324{
326 return session->set_quantization_type(qtype);
327}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_set_quantized_model_path()

NNFW_STATUS nnfw_set_quantized_model_path ( nnfw_session session,
const char *  path 
)

Set exported quantized model path.

This function should be called before nnfw_quantize is invoked.

TODO: If this function is not called, quantized model will not be exported

Parameters
[in]sessionnnfw_session to set quantized model path
[in]pathQuantized model path
Returns
NNFW_STATUS_NO_ERROR if successful, otherwise return NNFW_STATUS_ERROR

Definition at line 329 of file nnfw_api.cc.

330{
332 return session->set_quantized_model_path(path);
333}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_set_workspace()

NNFW_STATUS nnfw_set_workspace ( nnfw_session session,
const char *  dir 
)

Set runtime's workspace directory.

This function sets the directory to be used as a workspace. System should allow read and write access to the directory for the runtime. Default workspace is running directory of the application. This function should be called before nnfw_load_model_from_file is invoked.

Parameters
[in]sessionsession to be queried on.
[in]dirworkspace directory path
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 230 of file nnfw_api.cc.

231{
233 return session->set_workspace(dir);
234}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train()

NNFW_STATUS nnfw_train ( nnfw_session session,
bool  update_weights 
)

Train the model.

Note
This function should be called after nnfw_train_set_input and nnfw_train_set_expected for each input and expected output

In order to use update_weights as false, it should be called after nnfw_train_set_output.

Parameters
[in]sessionThe session to be trained
[in]update_weightsIf true, update weights of the model If false, do not update weights of the model (for validation)
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 291 of file nnfw_api.cc.

292{
294 return session->train_run(update_weights);
295}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train_expected_tensorinfo()

NNFW_STATUS nnfw_train_expected_tensorinfo ( nnfw_session session,
uint32_t  index,
nnfw_tensorinfo info 
)

Get the training model expected output information.

Note
This function should be called after nnfw_train_prepare
Parameters
[in]sessionThe session to get the training model expected output information
[in]indexThe index of training model expected output
[out]infoThe shape and type of training model expected output
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 263 of file nnfw_api.cc.

265{
267 return session->train_expected_tensorinfo(index, info);
268}

References info, and NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train_export_checkpoint()

NNFW_STATUS nnfw_train_export_checkpoint ( nnfw_session session,
const char *  path 
)

Export circle checkpoint.

Note
This function should be called on training mode This function should be called after nnfw_train
Parameters
[in]sessionThe session to export a checkpoint
[in]pathThe path to export a checkpoint
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 315 of file nnfw_api.cc.

316{
318 return session->train_export_checkpoint(path);
319}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train_export_circle()

NNFW_STATUS nnfw_train_export_circle ( nnfw_session session,
const char *  path 
)

Export current training model into circle model.

Export circle model.

Note
This function should be called on training mode This function should be called after nnfw_train
Parameters
[in]sessionThe session to export inference model
[in]pathThe path to export inference model
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 303 of file nnfw_api.cc.

304{
306 return session->train_export_circle(path);
307}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train_get_loss()

NNFW_STATUS nnfw_train_get_loss ( nnfw_session session,
uint32_t  index,
float *  loss 
)

Get loss value for expected output.

Note
This function should be called after nnfw_train
Parameters
[in]sessionThe session to get loss value
[in]indexThe index of loss value [0, number of expected outputs)
[out]lossThe loss value
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 297 of file nnfw_api.cc.

298{
300 return session->train_get_loss(index, loss);
301}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train_get_traininfo()

NNFW_STATUS nnfw_train_get_traininfo ( nnfw_session session,
nnfw_train_info info 
)

Get training information.

Note
This function should be called after calling nnfw_load_model_from_file
   For the field which is not set in training information, it returns training information
   filled with default value. The default value of each field is as follows :
   learning_rate = 0.0f, batch_size = 0, *_UNDEF for other enums
Parameters
[in]sessionThe session to get training information
[out]infoTraining information
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 238 of file nnfw_api.cc.

239{
241 return session->train_get_traininfo(info);
242}

References info, and NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train_import_checkpoint()

NNFW_STATUS nnfw_train_import_checkpoint ( nnfw_session session,
const char *  path 
)

Import circle checkpoint.

Note
This function should be called on training mode This function should be called before nnfw_train
Parameters
[in]sessionThe session to export a checkpoint
[in]pathThe path to export a checkpoint
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 309 of file nnfw_api.cc.

310{
312 return session->train_import_checkpoint(path);
313}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train_input_tensorinfo()

NNFW_STATUS nnfw_train_input_tensorinfo ( nnfw_session session,
uint32_t  index,
nnfw_tensorinfo info 
)

Get the training model input information.

Note
This function should be called after nnfw_train_prepare
Parameters
[in]sessionThe session to get the training model input information
[in]indexThe index of training model input
[out]infoThe shape and type of training model input
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 256 of file nnfw_api.cc.

258{
260 return session->train_input_tensorinfo(index, info);
261}

References info, and NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train_prepare()

NNFW_STATUS nnfw_train_prepare ( nnfw_session session)

Prepare session to be ready for training.

Note
The session will be entered into training mode
   If training info is NOT set in session, this function returns @c NNFW_STATUS_ERROR .
   You should set training info using {@link nnfw_train_set_traininfo}.
Parameters
[in]sessionThe session to be prepared for training
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 250 of file nnfw_api.cc.

251{
253 return session->train_prepare();
254}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train_set_expected()

NNFW_STATUS nnfw_train_set_expected ( nnfw_session session,
uint32_t  index,
const void *  expected,
const nnfw_tensorinfo expected_info 
)

Set training expected output.

Note
This function should be called after nnfw_train_prepare
Parameters
sessionThe session to be set training inputs and expected model outputs
indexThe index of training expected output
expectedThe expected buffers for training
expected_infoThe shape and type of expected buffer If it is nullptr, it will not change shape and batch size
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 277 of file nnfw_api.cc.

279{
281 return session->train_set_expected(index, expected, expected_info);
282}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train_set_input()

NNFW_STATUS nnfw_train_set_input ( nnfw_session session,
uint32_t  index,
const void *  input,
const nnfw_tensorinfo input_info 
)

Set training input.

Note
This function should be called after nnfw_train_prepare
Parameters
[in]sessionThe session to be set training inputs and expected model outputs
[in]indexThe index of training input
[in]inputThe input buffers for training
[in]input_infoThe shape and type of input buffer If it is nullptr, it will not change shape and batch size
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 270 of file nnfw_api.cc.

272{
274 return session->train_set_input(index, input, input_info);
275}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train_set_output()

NNFW_STATUS nnfw_train_set_output ( nnfw_session session,
uint32_t  index,
NNFW_TYPE  type,
void *  buffer,
size_t  length 
)

Set training output buffer.

This function must be called after nnfw_train_prepare, buffer given to this function can be reused for training. length must be greater or equal than the operand requires. An output operand can have unspecified shape and deduced dynamically during the execution. You must provide buffer large enough.

Parameters
[in]sessionSession from inference output is to be extracted
[in]indexIndex of output to be set (0-indexed)
[in]typeType of the output
[out]bufferRaw buffer for output
[in]lengthSize of bytes of output buffer
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 284 of file nnfw_api.cc.

286{
288 return session->train_set_output(index, type, buffer, length);
289}

References NNFW_RETURN_ERROR_IF_NULL.

◆ nnfw_train_set_traininfo()

NNFW_STATUS nnfw_train_set_traininfo ( nnfw_session session,
const nnfw_train_info info 
)

Set training information.

Note
This function should be called after calling nnfw_load_model_from_file and before calling nnfw_train_prepare
Parameters
[in]sessionThe session to be set training information
[in]infoThe training information
Returns
NNFW_STATUS_NO_ERROR if successful

Definition at line 244 of file nnfw_api.cc.

245{
247 return session->train_set_traininfo(info);
248}

References info, and NNFW_RETURN_ERROR_IF_NULL.

◆ STATIC_ASSERT_ENUM_CHECK() [1/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_INFO_ID_VERSION  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [2/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_LAYOUT_CHANNELS_FIRST  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [3/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_LAYOUT_CHANNELS_LAST  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [4/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_LAYOUT_NONE  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [5/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_STATUS_ERROR  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [6/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_STATUS_INSUFFICIENT_OUTPUT_SIZE  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [7/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_STATUS_INVALID_STATE  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [8/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_STATUS_NO_ERROR  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [9/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_STATUS_OUT_OF_MEMORY  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [10/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_STATUS_UNEXPECTED_NULL  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [11/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_TYPE_TENSOR_BOOL  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [12/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_TYPE_TENSOR_FLOAT32  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [13/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_TYPE_TENSOR_INT32  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [14/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_TYPE_TENSOR_INT64  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [15/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_TYPE_TENSOR_QUANT16_SYMM_SIGNED  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [16/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_TYPE_TENSOR_QUANT8_ASYMM  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [17/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_TYPE_TENSOR_QUANT8_ASYMM_SIGNED  ,
 
)

◆ STATIC_ASSERT_ENUM_CHECK() [18/18]

STATIC_ASSERT_ENUM_CHECK ( NNFW_TYPE_TENSOR_UINT8  ,
 
)