17#ifndef __ONERT_API_PYTHON_NNFW_API_WRAPPER_H__
18#define __ONERT_API_PYTHON_NNFW_API_WRAPPER_H__
24#include <pybind11/stl.h>
25#include <pybind11/numpy.h>
34namespace py = pybind11;
143 template <
typename T>
void set_input(uint32_t index, py::array_t<T> &buffer)
148 uint32_t input_elements =
num_elems(&tensor_info);
149 size_t length =
sizeof(T) * input_elements;
157 template <
typename T>
void set_output(uint32_t index, py::array_t<T> &buffer)
162 uint32_t output_elements =
num_elems(&tensor_info);
163 size_t length =
sizeof(T) * output_elements;
197 py::buffer_info buf_info = buffer.request();
198 const auto buf_shape = buf_info.shape;
199 assert(tensor_info.
rank ==
static_cast<int32_t
>(buf_shape.size()) && buf_shape.size() > 0);
200 tensor_info.
dims[0] =
static_cast<int32_t
>(buf_shape.at(0));
209 py::buffer_info buf_info = buffer.request();
210 const auto buf_shape = buf_info.shape;
211 assert(tensor_info.
rank ==
static_cast<int32_t
>(buf_shape.size()) && buf_shape.size() > 0);
212 tensor_info.
dims[0] =
static_cast<int32_t
>(buf_shape.at(0));
222 uint32_t output_elements =
num_elems(&tensor_info);
223 size_t length =
sizeof(T) * output_elements;
229 void train(
bool update_weights);
nnfw_train_info train_get_traininfo()
void train_set_output(uint32_t index, py::array_t< T > &buffer)
void train_export_circle(const py::str &path)
py::array get_output(uint32_t index)
tensorinfo input_tensorinfo(uint32_t index)
void train_import_checkpoint(const py::str &path)
void set_input_tensorinfo(uint32_t index, const tensorinfo *tensor_info)
void set_input(uint32_t index, py::array_t< T > &buffer)
process input array according to data type of numpy array sent by Python (int, float,...
void set_input_layout(uint32_t index, const char *layout)
void train_set_input(uint32_t index, py::array_t< T > &buffer)
float train_get_loss(uint32_t index)
void train_set_traininfo(const nnfw_train_info *info)
void set_output_layout(uint32_t index, const char *layout)
void set_output(uint32_t index, py::array_t< T > &buffer)
process output array according to data type of numpy array sent by Python (int, float,...
void set_prepare_config(NNFW_PREPARE_CONFIG config)
tensorinfo output_tensorinfo(uint32_t index)
void train_set_expected(uint32_t index, py::array_t< T > &buffer)
void train_export_checkpoint(const py::str &path)
volatile const char info[]
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="")
void ensure_status(NNFW_STATUS status)
Handle errors with NNFW_STATUS in API functions.
NNFW_LAYOUT getLayout(const char *layout="")
uint64_t num_elems(const nnfw_tensorinfo *tensor_info)
Get the total number of elements in nnfw_tensorinfo->dims.
py::list get_dims(const tensorinfo &tensor_info)
Get nnfw_tensorinfo->dims.
This file describes runtime API.
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_output_tensorinfo(nnfw_session *session, uint32_t index, nnfw_tensorinfo *tensor_info)
Get i-th output tensor info.
NNFW_STATUS nnfw_input_tensorinfo(nnfw_session *session, uint32_t index, nnfw_tensorinfo *tensor_info)
Get i-th input tensor info.
NNFW_STATUS nnfw_set_output(nnfw_session *session, uint32_t index, NNFW_TYPE type, void *buffer, size_t length)
Set output buffer.
NNFW_LAYOUT
Data format of a tensor.
NNFW_PREPARE_CONFIG
Configuration key for prepare (compile and schedule)
NNFW_STATUS
Result values returned from a call to an API function.
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_output(nnfw_session *session, uint32_t index, NNFW_TYPE type, void *buffer, size_t length)
Set training output buffer.
NNFW_STATUS nnfw_train_set_expected(nnfw_session *session, uint32_t index, void *expected, const nnfw_tensorinfo *expected_info)
Set training expected output.
#define NNFW_MAX_RANK
Maximum rank expressible with nnfw.
tensor info describes the type and shape of tensors
int32_t dims[NNFW_MAX_RANK]
Training information to prepare training.
tensor info describes the type and shape of tensors
int32_t dims[NNFW_MAX_RANK]