28 std::cout <<
"[ERROR]\tNNFW_STATUS_ERROR\n";
31 std::cout <<
"[ERROR]\tNNFW_STATUS_UNEXPECTED_NULL\n";
34 std::cout <<
"[ERROR]\tNNFW_STATUS_INVALID_STATE\n";
37 std::cout <<
"[ERROR]\tNNFW_STATUS_OUT_OF_MEMORY\n";
40 std::cout <<
"[ERROR]\tNNFW_STATUS_INSUFFICIENT_OUTPUT_SIZE\n";
43 std::cout <<
"[ERROR]\tNNFW_STATUS_DEPRECATED_API\n";
50 if (!strcmp(layout,
"NCHW"))
54 else if (!strcmp(layout,
"NHWC"))
58 else if (!strcmp(layout,
"NONE"))
64 std::cout <<
"[ERROR]\tLAYOUT_TYPE\n";
71 if (!strcmp(type,
"float32"))
75 else if (!strcmp(type,
"int32"))
79 else if (!strcmp(type,
"uint8"))
81 return NNFW_TYPE::NNFW_TYPE_TENSOR_UINT8;
84 else if (!strcmp(type,
"bool"))
86 return NNFW_TYPE::NNFW_TYPE_TENSOR_BOOL;
88 else if (!strcmp(type,
"int64"))
90 return NNFW_TYPE::NNFW_TYPE_TENSOR_INT64;
92 else if (!strcmp(type,
"int8"))
94 return NNFW_TYPE::NNFW_TYPE_TENSOR_QUANT8_ASYMM_SIGNED;
96 else if (!strcmp(type,
"int16"))
98 return NNFW_TYPE::NNFW_TYPE_TENSOR_QUANT16_SYMM_SIGNED;
102 std::cout <<
"[ERROR] String to NNFW_TYPE Failure\n";
115 case NNFW_TYPE::NNFW_TYPE_TENSOR_QUANT8_ASYMM:
116 case NNFW_TYPE::NNFW_TYPE_TENSOR_UINT8:
118 case NNFW_TYPE::NNFW_TYPE_TENSOR_BOOL:
120 case NNFW_TYPE::NNFW_TYPE_TENSOR_INT64:
122 case NNFW_TYPE::NNFW_TYPE_TENSOR_QUANT8_ASYMM_SIGNED:
124 case NNFW_TYPE::NNFW_TYPE_TENSOR_QUANT16_SYMM_SIGNED:
127 std::cout <<
"[ERROR] NNFW_TYPE to String Failure\n";
135 for (int32_t i = 0; i < tensor_info->
rank; ++i)
137 n *= tensor_info->
dims[i];
145 for (int32_t i = 0; i < tensor_info.
rank; ++i)
147 dims_list.append(tensor_info.
dims[i]);
154 tensor_info.
rank = py::len(array);
155 for (int32_t i = 0; i < tensor_info.
rank; ++i)
157 tensor_info.
dims[i] = py::cast<int32_t>(array[i]);
163 this->session =
nullptr;
180 this->session =
nullptr;
NNFW_SESSION(const char *package_file_path, const char *backends)
tensorinfo output_tensorinfo(uint32_t index)
void set_input_layout(uint32_t index, const char *layout)
void set_output_layout(uint32_t index, const char *layout)
tensorinfo input_tensorinfo(uint32_t index)
void set_input_tensorinfo(uint32_t index, const tensorinfo *tensor_info)
NNFW_STATUS nnfw_await(nnfw_session *session)
Wait for asynchronous run to finish.
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_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_run(nnfw_session *session)
Run inference.
NNFW_STATUS nnfw_prepare(nnfw_session *session)
Prepare session to be ready for inference.
NNFW_STATUS nnfw_set_output_layout(nnfw_session *session, uint32_t index, NNFW_LAYOUT layout)
Set the layout of an output.
NNFW_LAYOUT
Data format of a tensor.
@ NNFW_LAYOUT_CHANNELS_LAST
@ NNFW_LAYOUT_CHANNELS_FIRST
NNFW_STATUS nnfw_set_input_layout(nnfw_session *session, uint32_t index, NNFW_LAYOUT layout)
Set the layout of an input.
NNFW_LAYOUT getLayout(const char *layout)
void ensure_status(NNFW_STATUS status)
Handle errors with NNFW_STATUS in API functions.
py::list get_dims(const tensorinfo &tensor_info)
Get nnfw_tensorinfo->dims.
uint64_t num_elems(const nnfw_tensorinfo *tensor_info)
Get the total number of elements in nnfw_tensorinfo->dims.
void set_dims(tensorinfo &tensor_info, const py::list &array)
Set nnfw_tensorinfo->dims.
const char * getStringType(NNFW_TYPE type)
NNFW_TYPE getType(const char *type)
NNFW_TYPE getType(const char *type="")
void ensure_status(NNFW_STATUS status)
Handle errors with NNFW_STATUS in API functions.
NNFW_LAYOUT getLayout(const char *layout="")
const char * getStringType(NNFW_TYPE type)
NNFW_STATUS nnfw_create_session(nnfw_session **session)
Create a new session instance.
NNFW_STATUS
Result values returned from a call to an API function.
@ NNFW_STATUS_INVALID_STATE
@ NNFW_STATUS_UNEXPECTED_NULL
@ NNFW_STATUS_DEPRECATED_API
@ NNFW_STATUS_INSUFFICIENT_OUTPUT_SIZE
@ NNFW_STATUS_OUT_OF_MEMORY
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_TYPE_TENSOR_FLOAT32
#define NNFW_MAX_RANK
Maximum rank expressible with nnfw.
tensor info describes the type and shape of tensors
int32_t dims[NNFW_MAX_RANK]
tensor info describes the type and shape of tensors
int32_t dims[NNFW_MAX_RANK]