ONE - On-device Neural Engine
|
Go to the source code of this file.
Data Structures | |
struct | nnfw_tensorinfo |
tensor info describes the type and shape of tensors More... | |
struct | nnfw_loss_info |
struct | nnfw_adam_option |
struct | nnfw_train_info |
Training information to prepare training. More... | |
Macros | |
#define | NNFW_MAX_RANK (6) |
Maximum rank expressible with nnfw. | |
#define | NNFW_TRAINABLE_OPS_MAX_SIZE (256) |
Maximum numer of trainable operations. | |
Typedefs | |
typedef struct nnfw_session | nnfw_session |
typedef struct nnfw_tensorinfo | nnfw_tensorinfo |
tensor info describes the type and shape of tensors | |
typedef struct nnfw_loss_info | nnfw_loss_info |
typedef struct nnfw_adam_option | nnfw_adam_option |
typedef struct nnfw_train_info | nnfw_train_info |
Training information to prepare training. | |
Enumerations | |
enum | NNFW_TYPE { NNFW_TYPE_TENSOR_FLOAT32 = 0 , NNFW_TYPE_TENSOR_INT32 = 1 } |
enum | NNFW_STATUS { NNFW_STATUS_NO_ERROR = 0 , NNFW_STATUS_ERROR = 1 , NNFW_STATUS_UNEXPECTED_NULL = 2 , NNFW_STATUS_INVALID_STATE = 3 , NNFW_STATUS_OUT_OF_MEMORY = 4 , NNFW_STATUS_INSUFFICIENT_OUTPUT_SIZE = 5 , NNFW_STATUS_DEPRECATED_API = 6 } |
Result values returned from a call to an API function. More... | |
enum | NNFW_TRAIN_LOSS { NNFW_TRAIN_LOSS_UNDEFINED = 0 , NNFW_TRAIN_LOSS_MEAN_SQUARED_ERROR = 1 , NNFW_TRAIN_LOSS_CATEGORICAL_CROSSENTROPY = 2 } |
enum | NNFW_TRAIN_LOSS_REDUCTION { NNFW_TRAIN_LOSS_REDUCTION_UNDEFINED = 0 , NNFW_TRAIN_LOSS_REDUCTION_SUM_OVER_BATCH_SIZE = 1 , NNFW_TRAIN_LOSS_REDUCTION_SUM = 2 } |
enum | NNFW_TRAIN_OPTIMIZER { NNFW_TRAIN_OPTIMIZER_UNDEFINED = 0 , NNFW_TRAIN_OPTIMIZER_SGD = 1 , NNFW_TRAIN_OPTIMIZER_ADAM = 2 } |
Functions | |
NNFW_STATUS | nnfw_train_set_traininfo (nnfw_session *session, const nnfw_train_info *info) |
Set training information. | |
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 *package_file_path) |
Load model from nnpackage file or directory. | |
NNFW_STATUS | nnfw_train_prepare (nnfw_session *session) |
Prepare session to be ready for training. | |
NNFW_STATUS | nnfw_train (nnfw_session *session, bool update_weights) |
Train the model. | |
NNFW_STATUS | nnfw_train_export_circle (nnfw_session *session, const char *path) |
Export current training model into circle model. | |
NNFW_STATUS | nnfw_train_export_checkpoint (nnfw_session *session, const char *path) |
NNFW_STATUS | nnfw_train_import_checkpoint (nnfw_session *session, const char *path) |
NNFW_STATUS | nnfw_train_set_input (nnfw_session *session, uint32_t index, void *input, const nnfw_tensorinfo *input_info) |
Set training input. | |
NNFW_STATUS | nnfw_train_set_expected (nnfw_session *session, uint32_t index, void *expected, const nnfw_tensorinfo *expected_info) |
Set training expected output. | |
NNFW_STATUS | nnfw_train_get_loss (nnfw_session *session, uint32_t index, float *loss) |
Get loss value for 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. | |
#define NNFW_MAX_RANK (6) |
Maximum rank expressible with nnfw.
Definition at line 109 of file onert-micro.h.
#define NNFW_TRAINABLE_OPS_MAX_SIZE (256) |
Maximum numer of trainable operations.
Definition at line 179 of file onert-micro.h.
typedef struct nnfw_adam_option nnfw_adam_option |
typedef struct nnfw_loss_info nnfw_loss_info |
typedef struct nnfw_session nnfw_session |
Definition at line 72 of file onert-micro.h.
typedef struct nnfw_tensorinfo nnfw_tensorinfo |
tensor info describes the type and shape of tensors
This structure is used to describe input and output tensors. Application can get input and output tensor type and shape described in model by using nnfw_input_tensorinfo
and nnfw_output_tensorinfo
Maximum rank is 6 (NNFW_MAX_RANK). And tensor's dimension value is filled in 'dims' field from index 0. For example, if tensor's rank is 4, application can get dimension value from dims[0], dims[1], dims[2], and dims[3]
typedef struct nnfw_train_info nnfw_train_info |
Training information to prepare training.
enum NNFW_STATUS |
Result values returned from a call to an API function.
Definition at line 85 of file onert-micro.h.
enum NNFW_TRAIN_LOSS |
Enumerator | |
---|---|
NNFW_TRAIN_LOSS_UNDEFINED | |
NNFW_TRAIN_LOSS_MEAN_SQUARED_ERROR | |
NNFW_TRAIN_LOSS_CATEGORICAL_CROSSENTROPY |
Definition at line 139 of file onert-micro.h.
Definition at line 146 of file onert-micro.h.
enum NNFW_TRAIN_OPTIMIZER |
Enumerator | |
---|---|
NNFW_TRAIN_OPTIMIZER_UNDEFINED | |
NNFW_TRAIN_OPTIMIZER_SGD | |
NNFW_TRAIN_OPTIMIZER_ADAM |
Definition at line 156 of file onert-micro.h.
enum NNFW_TYPE |
Enumerator | |
---|---|
NNFW_TYPE_TENSOR_FLOAT32 | A tensor of 32 bit floating point |
NNFW_TYPE_TENSOR_INT32 | A tensor of 32 bit signed integer |
Definition at line 74 of file onert-micro.h.
NNFW_STATUS nnfw_close_session | ( | nnfw_session * | session | ) |
Close a session instance.
After called, access to closed session by application will be invalid
[in] | session | The session to be closed |
NNFW_STATUS_NO_ERROR
if successful Definition at line 60 of file nnfw_api.cc.
References NNFW_STATUS_NO_ERROR.
Referenced by NNFW_SESSION::close_session(), and main().
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
[out] | session | The session to be created |
Definition at line 390 of file onert-micro.cpp.
References nnfw_session::create().
Referenced by main(), and NNFW_SESSION::NNFW_SESSION().
NNFW_STATUS nnfw_load_model_from_file | ( | nnfw_session * | session, |
const char * | package_file_path | ||
) |
Load model from nnpackage file or directory.
The length of package_file_path
must not exceed 1024 bytes including zero at the end.
[in] | session | nnfw_session loading the given nnpackage file/dir |
[in] | package_file_path | Path to the nnpackage file or unzipped directory to be loaded |
NNFW_STATUS_NO_ERROR
if successful Definition at line 392 of file onert-micro.cpp.
Referenced by main(), and NNFW_SESSION::NNFW_SESSION().
NNFW_STATUS nnfw_train | ( | nnfw_session * | session, |
bool | update_weights | ||
) |
Train the model.
nnfw_train_set_input
and nnfw_train_set_expected
for each input and expected outputIn order to use update_weights
as false, it should be called after nnfw_train_set_output
.
[in] | session | The session to be trained |
[in] | update_weights | If true, update weights of the model If false, do not update weights of the model (for validation) |
NNFW_STATUS_NO_ERROR
if successful Definition at line 399 of file onert-micro.cpp.
NNFW_STATUS nnfw_train_export_checkpoint | ( | nnfw_session * | session, |
const char * | path | ||
) |
Definition at line 409 of file onert-micro.cpp.
NNFW_STATUS nnfw_train_export_circle | ( | nnfw_session * | session, |
const char * | path | ||
) |
Export current training model into circle model.
nnfw_train
[in] | session | The session to export inference model |
[in] | path | The path to export inference model |
NNFW_STATUS_NO_ERROR
if successful Definition at line 404 of file onert-micro.cpp.
NNFW_STATUS nnfw_train_get_loss | ( | nnfw_session * | session, |
uint32_t | index, | ||
float * | loss | ||
) |
Get loss value for expected output.
nnfw_train
[in] | session | The session to get loss value |
[in] | index | The index of loss value [0, number of expected outputs) |
[out] | loss | The loss value |
NNFW_STATUS_NO_ERROR
if successful Definition at line 433 of file onert-micro.cpp.
References NNFW_RETURN_ERROR_IF_NULL.
NNFW_STATUS nnfw_train_import_checkpoint | ( | nnfw_session * | session, |
const char * | path | ||
) |
Definition at line 414 of file onert-micro.cpp.
NNFW_STATUS nnfw_train_prepare | ( | nnfw_session * | session | ) |
Prepare session to be ready for training.
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}.
[in] | session | The session to be prepared for training |
NNFW_STATUS_NO_ERROR
if successful Definition at line 397 of file onert-micro.cpp.
NNFW_STATUS nnfw_train_set_expected | ( | nnfw_session * | session, |
uint32_t | index, | ||
void * | expected, | ||
const nnfw_tensorinfo * | expected_info | ||
) |
Set training expected output.
nnfw_train_prepare
session | The session to be set training inputs and expected model outputs |
index | The index of training expected output |
expected | The expected buffers for training |
expected_info | The shape and type of expected buffer If it is nullptr, it will not change shape and batch size |
NNFW_STATUS_NO_ERROR
if successful Definition at line 426 of file onert-micro.cpp.
References NNFW_RETURN_ERROR_IF_NULL.
NNFW_STATUS nnfw_train_set_input | ( | nnfw_session * | session, |
uint32_t | index, | ||
void * | input, | ||
const nnfw_tensorinfo * | input_info | ||
) |
Set training input.
nnfw_train_prepare
[in] | session | The session to be set training inputs and expected model outputs |
[in] | index | The index of training input |
[in] | input | The input buffers for training |
[in] | input_info | The shape and type of input buffer If it is nullptr, it will not change shape and batch size |
NNFW_STATUS_NO_ERROR
if successful Definition at line 419 of file onert-micro.cpp.
References NNFW_RETURN_ERROR_IF_NULL.
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.
[in] | session | Session from inference output is to be extracted |
[in] | index | Index of output to be set (0-indexed) |
[in] | type | Type of the output |
[out] | buffer | Raw buffer for output |
[in] | length | Size of bytes of output buffer |
NNFW_STATUS_NO_ERROR
if successful Definition at line 445 of file onert-micro.cpp.
References NNFW_RETURN_ERROR_IF_NULL.
NNFW_STATUS nnfw_train_set_traininfo | ( | nnfw_session * | session, |
const nnfw_train_info * | info | ||
) |
Set training information.
nnfw_load_model_from_file
and before calling nnfw_train_prepare
[in] | session | The session to be set training information |
[in] | info | The training information |
NNFW_STATUS_NO_ERROR
if successful Definition at line 439 of file onert-micro.cpp.
References info, and NNFW_RETURN_ERROR_IF_NULL.