25#define STATIC_ASSERT_ENUM_CHECK(ENUM, VAL) static_assert((ENUM) == (VAL), #ENUM " has changed")
49#undef STATIC_ASSERT_ENUM_CHECK
51#define NNFW_RETURN_ERROR_IF_NULL(p) \
55 return NNFW_STATUS_UNEXPECTED_NULL; \
69 return session->load_model_from_path(path);
75 return session->prepare();
81 return session->run();
87 return session->run_async();
93 return session->await();
97 const void *buffer,
size_t length)
100 return session->set_input(index, type, buffer, length);
107 return session->set_output(index, type, buffer, length);
113 return session->input_size(number);
119 return session->output_size(number);
125 return session->set_input_layout(index, layout);
131 return session->set_output_layout(index, layout);
138 return session->input_tensorinfo(index, tensor_info);
145 return session->output_tensorinfo(index, tensor_info);
152 return session->register_custom_operation(
id,
info->eval_function);
164 return session->set_input_tensorinfo(index, tensor_info);
170 return session->set_available_backends(
backends);
200 return session->input_tensorindex(tensorname, index);
206 return session->output_tensorindex(tensorname, index);
212 return session->set_backends_per_operation(backend_settings);
233 return session->set_workspace(dir);
241 return session->train_get_traininfo(
info);
247 return session->train_set_traininfo(
info);
253 return session->train_prepare();
260 return session->train_input_tensorinfo(index,
info);
267 return session->train_expected_tensorinfo(index,
info);
274 return session->train_set_input(index, input, input_info);
281 return session->train_set_expected(index, expected, expected_info);
285 void *buffer,
size_t length)
288 return session->train_set_output(index, type, buffer, length);
294 return session->train_run(update_weights);
300 return session->train_get_loss(index, loss);
306 return session->train_export_circle(path);
312 return session->train_import_checkpoint(path);
318 return session->train_export_checkpoint(path);
326 return session->set_quantization_type(qtype);
332 return session->set_quantized_model_path(path);
338 return session->quantize();
344 return session->set_codegen_model_path(path);
350 return session->codegen(target, pref);
356 return session->set_odc_param_minmax_records_count(minmax_records_count);
362 return session->delete_odc_minmax_file();
369 return session->run_with_auto_compilation(target, pref);
378 return session->set_prepare_config(key, value);
384 return session->reset_prepare_config();
391 return session->set_execute_config(key, value);
397 return session->reset_execute_config();
volatile const char info[]
This file describes runtime API.
NNFW_INFO_ID
Information ID for retrieving information on nnfw (e.g. version)
@ NNFW_TYPE_TENSOR_QUANT16_SYMM_SIGNED
@ NNFW_TYPE_TENSOR_QUANT8_ASYMM_SIGNED
@ NNFW_TYPE_TENSOR_QUANT8_ASYMM
NNFW_LAYOUT
Data format of a tensor.
@ NNFW_LAYOUT_CHANNELS_LAST
@ NNFW_LAYOUT_CHANNELS_FIRST
NNFW_STATUS nnfw_create_session(nnfw_session **session)
Create a new 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_set_input(nnfw_session *session, uint32_t index, NNFW_TYPE type, const void *buffer, size_t length)
Set input buffer.
NNFW_STATUS nnfw_await(nnfw_session *session)
Wait for asynchronous run to finish.
NNFW_STATUS nnfw_close_session(nnfw_session *session)
Close a session instance.
#define STATIC_ASSERT_ENUM_CHECK(ENUM, VAL)
NNFW_STATUS nnfw_train_get_loss(nnfw_session *session, uint32_t index, float *loss)
Get loss value for expected output.
NNFW_STATUS nnfw_register_custom_op_info(nnfw_session *session, const char *id, custom_kernel_registration_info *info)
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_pop_pipeline_output(nnfw_session *, void *)
Get last outputs of partitioned model in session.
NNFW_STATUS nnfw_run_with_auto_compilation(nnfw_session *session, const char *target, NNFW_CODEGEN_PREF pref)
Run inference with auto compilation.
#define NNFW_RETURN_ERROR_IF_NULL(p)
NNFW_STATUS nnfw_train_export_checkpoint(nnfw_session *session, const char *path)
Export circle checkpoint.
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_prepare_pipeline(nnfw_session *, const char *)
Prepare session to be ready for inference.
NNFW_STATUS nnfw_run_async(nnfw_session *session)
Run inference asynchronously.
NNFW_STATUS nnfw_output_tensorinfo(nnfw_session *session, uint32_t index, nnfw_tensorinfo *tensor_info)
Get i-th output tensor info.
NNFW_STATUS nnfw_set_available_backends(nnfw_session *session, const char *backends)
Set available backends.
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_size(nnfw_session *session, uint32_t *number)
Get the number of outputs.
NNFW_STATUS nnfw_push_pipeline_input(nnfw_session *, void *, void *)
Set input buffer.
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_workspace(nnfw_session *session, const char *dir)
Set runtime's workspace directory.
NNFW_STATUS nnfw_input_size(nnfw_session *session, uint32_t *number)
Get the number of inputs.
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_train_prepare(nnfw_session *session)
Prepare session to be ready for training.
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_train(nnfw_session *session, bool update_weights)
Train the model.
NNFW_STATUS nnfw_set_quantization_type(nnfw_session *session, NNFW_QUANTIZE_TYPE qtype)
Set quantization type.
NNFW_STATUS nnfw_train_set_traininfo(nnfw_session *session, const nnfw_train_info *info)
Set training information.
NNFW_STATUS nnfw_train_get_traininfo(nnfw_session *session, nnfw_train_info *info)
Get training information.
NNFW_STATUS nnfw_input_tensorindex(nnfw_session *session, const char *tensorname, uint32_t *index)
Get the input tensor index by name.
NNFW_STATUS nnfw_run(nnfw_session *session)
Run inference.
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_prepare(nnfw_session *session)
Prepare session to be ready for inference.
NNFW_STATUS nnfw_codegen(nnfw_session *session, const char *target, NNFW_CODEGEN_PREF pref)
Generate target-dependent code.
NNFW_STATUS nnfw_quantize(nnfw_session *session)
Quantize circle model.
NNFW_STATUS nnfw_set_op_backend(nnfw_session *, const char *, const char *)
Set the operation's backend.
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_reset_prepare_config(nnfw_session *session)
Reset prepare configurations.
NNFW_STATUS nnfw_reset_execute_config(nnfw_session *session)
Reset execution (run or train) configurations.
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_set_execute_config(nnfw_session *session, const NNFW_RUN_CONFIG key, const char *value)
Set execution (run or train) configuration.
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_train_import_checkpoint(nnfw_session *session, const char *path)
Import circle checkpoint.
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_set_prepare_config(nnfw_session *session, const NNFW_PREPARE_CONFIG key, const char *value)
Set prepare configuration.
NNFW_STATUS nnfw_odc_delete_minmax_file(nnfw_session *session)
Delete MinMax file for on-device compiler.
NNFW_STATUS nnfw_set_codegen_model_path(nnfw_session *session, const char *path)
Set exported codegen model path.
NNFW_STATUS nnfw_set_quantized_model_path(nnfw_session *session, const char *path)
Set exported quantized model path.
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_set_output_layout(nnfw_session *session, uint32_t index, NNFW_LAYOUT layout)
Set the layout of an output.
NNFW_STATUS nnfw_train_export_circle(nnfw_session *session, const char *path)
Export current training model into circle model.
NNFW_STATUS nnfw_set_input_layout(nnfw_session *session, uint32_t index, NNFW_LAYOUT layout)
Set the layout of an input.
NNFW_CODEGEN_PREF
Preference for target-dependent code generation.
NNFW_QUANTIZE_TYPE
Convert between training mode and inference mode.
NNFW_RUN_CONFIG
Configuration key for execution.
NNFW_PREPARE_CONFIG
Configuration key for prepare (compile and schedule)
NNFW_STATUS
Result values returned from a call to an API function.
@ NNFW_STATUS_INVALID_STATE
@ NNFW_STATUS_UNEXPECTED_NULL
@ NNFW_STATUS_INSUFFICIENT_OUTPUT_SIZE
@ NNFW_STATUS_OUT_OF_MEMORY
@ NNFW_TYPE_TENSOR_FLOAT32
static NNFW_STATUS deprecated(const char *msg)
static NNFW_STATUS create(nnfw_session **session)
Factory method. It creates and initialize nnfw_session.
tensor info describes the type and shape of tensors
Training information to prepare training.