ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::api::python Namespace Reference

Data Structures

class  NNFW_SESSION
 
struct  NnfwDeprecatedApiError
 
struct  NnfwError
 
struct  NnfwInsufficientOutputError
 
struct  NnfwInvalidStateError
 
struct  NnfwOutOfMemoryError
 
struct  NnfwUnexpectedNullError
 
struct  tensorinfo
 tensor info describes the type and shape of tensors More...
 

Functions

void ensure_status (NNFW_STATUS status)
 Handle errors with NNFW_STATUS in API functions.
 
NNFW_LAYOUT getLayout (const char *layout="")
 
NNFW_TYPE getType (const char *type="")
 
const char * getStringType (NNFW_TYPE type)
 
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.
 
void set_dims (tensorinfo &tensor_info, const py::list &array)
 Set nnfw_tensorinfo->dims.
 
void bind_nnfw_exceptions (py::module_ &m)
 
void bind_nnfw_session (pybind11::module_ &m)
 
void bind_experimental_nnfw_session (pybind11::module_ &m)
 
void bind_tensorinfo (pybind11::module_ &m)
 
void bind_nnfw_enums (pybind11::module_ &m)
 
void bind_nnfw_session (py::module_ &m)
 
void bind_experimental_nnfw_session (py::module_ &m)
 
void bind_tensorinfo (py::module_ &m)
 
void bind_nnfw_enums (py::module_ &m)
 

Function Documentation

◆ bind_experimental_nnfw_session() [1/2]

void onert::api::python::bind_experimental_nnfw_session ( py::module_ &  m)

Definition at line 153 of file nnfw_session_bindings.cc.

160{
161 // Add experimental APIs for the `NNFW_SESSION` class
162 m.attr("nnfw_session")
163 .cast<py::class_<NNFW_SESSION>>()
164 .def("train_get_traininfo", &NNFW_SESSION::train_get_traininfo,
165 "Retrieve training information for the model.")
166 .def("train_set_traininfo", &NNFW_SESSION::train_set_traininfo, py::arg("info"),
167 "Set training information for the model.")
168 .def("train_prepare", &NNFW_SESSION::train_prepare, "Prepare for training")
169 .def("train", &NNFW_SESSION::train, py::arg("update_weights") = true,
170 "Run a training step, optionally updating weights.")
171 .def("train_get_loss", &NNFW_SESSION::train_get_loss, py::arg("index"),
172 "Retrieve the training loss for a specific index.")
173 .def("train_set_input", &NNFW_SESSION::train_set_input<float>, py::arg("index"),
174 py::arg("buffer"), "Set training input tensor for the given index (float).")
175 .def("train_set_input", &NNFW_SESSION::train_set_input<int>, py::arg("index"),
176 py::arg("buffer"), "Set training input tensor for the given index (int).")
177 .def("train_set_input", &NNFW_SESSION::train_set_input<uint8_t>, py::arg("index"),
178 py::arg("buffer"), "Set training input tensor for the given index (uint8).")
179 .def("train_set_expected", &NNFW_SESSION::train_set_expected<float>, py::arg("index"),
180 py::arg("buffer"), "Set expected output tensor for the given index (float).")
181 .def("train_set_expected", &NNFW_SESSION::train_set_expected<int>, py::arg("index"),
182 py::arg("buffer"), "Set expected output tensor for the given index (int).")
183 .def("train_set_expected", &NNFW_SESSION::train_set_expected<uint8_t>, py::arg("index"),
184 py::arg("buffer"), "Set expected output tensor for the given index (uint8).")
185 .def("train_set_output", &NNFW_SESSION::train_set_output<float>, py::arg("index"),
186 py::arg("buffer"), "Set output tensor for the given index (float).")
187 .def("train_set_output", &NNFW_SESSION::train_set_output<int>, py::arg("index"),
188 py::arg("buffer"), "Set output tensor for the given index (int).")
189 .def("train_set_output", &NNFW_SESSION::train_set_output<uint8_t>, py::arg("index"),
190 py::arg("buffer"), "Set output tensor for the given index (uint8).")
191 .def("train_export_circle", &NNFW_SESSION::train_export_circle, py::arg("path"),

◆ bind_experimental_nnfw_session() [2/2]

void onert::api::python::bind_experimental_nnfw_session ( pybind11::module_ &  m)

Referenced by PYBIND11_MODULE().

◆ bind_nnfw_enums() [1/2]

void onert::api::python::bind_nnfw_enums ( py::module_ &  m)

Definition at line 40 of file nnfw_tensorinfo_bindings.cc.

41{
42 // Bind NNFW_TRAIN_LOSS
43 py::enum_<NNFW_PREPARE_CONFIG>(m, "prepare_config", py::module_local())
44 .value("PREPARE_CONFIG_PROFILE", NNFW_PREPARE_CONFIG_PROFILE)
45 .value("ENABLE_INTERNAL_OUTPUT_ALLOC", NNFW_ENABLE_INTERNAL_OUTPUT_ALLOC);
46}
@ NNFW_PREPARE_CONFIG_PROFILE
@ NNFW_ENABLE_INTERNAL_OUTPUT_ALLOC

References m, NNFW_ENABLE_INTERNAL_OUTPUT_ALLOC, and NNFW_PREPARE_CONFIG_PROFILE.

◆ bind_nnfw_enums() [2/2]

void onert::api::python::bind_nnfw_enums ( pybind11::module_ &  m)

Referenced by PYBIND11_MODULE().

◆ bind_nnfw_exceptions()

void onert::api::python::bind_nnfw_exceptions ( py::module_ &  m)

Definition at line 28 of file nnfw_exception_bindings.cc.

29{
30 // register base first
31 py::register_exception<NnfwError>(m, "OnertError", PyExc_RuntimeError);
32
33 // derived exceptions, each inheriting from NnfwError in Python as well
34 py::register_exception<NnfwUnexpectedNullError>(m, "OnertUnexpectedNullError",
35 m.attr("OnertError").cast<py::object>());
36 py::register_exception<NnfwInvalidStateError>(m, "OnertInvalidStateError",
37 m.attr("OnertError").cast<py::object>());
38 py::register_exception<NnfwOutOfMemoryError>(m, "OnertOutOfMemoryError",
39 m.attr("OnertError").cast<py::object>());
40 py::register_exception<NnfwInsufficientOutputError>(m, "OnertInsufficientOutputError",
41 m.attr("OnertError").cast<py::object>());
42 py::register_exception<NnfwDeprecatedApiError>(m, "OnertDeprecatedApiError",
43 m.attr("OnertError").cast<py::object>());
44}

References m.

Referenced by PYBIND11_MODULE().

◆ bind_nnfw_session() [1/2]

void onert::api::python::bind_nnfw_session ( py::module_ &  m)

Definition at line 27 of file nnfw_session_bindings.cc.

28{
29 py::class_<NNFW_SESSION>(m, "nnfw_session", py::module_local())
30 .def(
31 py::init<const char *, const char *>(), py::arg("package_file_path"), py::arg("backends"),
32 "Create a new session instance, load model from nnpackage file or directory, "
33 "set available backends and prepare session to be ready for inference\n"
34 "Parameters:\n"
35 "\tpackage_file_path (str): Path to the nnpackage file or unzipped directory to be loaded\n"
36 "\tbackends (str): Available backends on which nnfw uses\n"
37 "\t\tMultiple backends can be set and they must be separated by a semicolon "
38 "(ex: \"acl_cl;cpu\")\n"
39 "\t\tAmong the multiple backends, the 1st element is used as the default backend.")
40 .def("set_input_tensorinfo", &NNFW_SESSION::set_input_tensorinfo, py::arg("index"),
41 py::arg("tensor_info"),
42 "Set input model's tensor info for resizing.\n"
43 "Parameters:\n"
44 "\tindex (int): Index of input to be set (0-indexed)\n"
45 "\ttensor_info (tensorinfo): Tensor info to be set")
46 .def("prepare", &NNFW_SESSION::prepare, "Prepare for inference")
47 .def("run", &NNFW_SESSION::run, "Run inference")
48 .def("run_async", &NNFW_SESSION::run_async, "Run inference asynchronously")
49 .def("wait", &NNFW_SESSION::wait, "Wait for asynchronous run to finish")
50 .def(
51 "set_input",
52 [](NNFW_SESSION &session, uint32_t index, py::array_t<float> &buffer) {
53 session.set_input<float>(index, buffer);
54 },
55 py::arg("index"), py::arg("buffer"),
56 "Set input buffer\n"
57 "Parameters:\n"
58 "\tindex (int): Index of input to be set (0-indexed)\n"
59 "\tbuffer (numpy): Raw buffer for input")
60 .def(
61 "set_input",
62 [](NNFW_SESSION &session, uint32_t index, py::array_t<int> &buffer) {
63 session.set_input<int>(index, buffer);
64 },
65 py::arg("index"), py::arg("buffer"),
66 "Set input buffer\n"
67 "Parameters:\n"
68 "\tindex (int): Index of input to be set (0-indexed)\n"
69 "\tbuffer (numpy): Raw buffer for input")
70 .def(
71 "set_input",
72 [](NNFW_SESSION &session, uint32_t index, py::array_t<uint8_t> &buffer) {
73 session.set_input<uint8_t>(index, buffer);
74 },
75 py::arg("index"), py::arg("buffer"),
76 "Set input buffer\n"
77 "Parameters:\n"
78 "\tindex (int): Index of input to be set (0-indexed)\n"
79 "\tbuffer (numpy): Raw buffer for input")
80 .def(
81 "set_input",
82 [](NNFW_SESSION &session, uint32_t index, py::array_t<bool> &buffer) {
83 session.set_input<bool>(index, buffer);
84 },
85 py::arg("index"), py::arg("buffer"),
86 "Set input buffer\n"
87 "Parameters:\n"
88 "\tindex (int): Index of input to be set (0-indexed)\n"
89 "\tbuffer (numpy): Raw buffer for input")
90 .def(
91 "set_input",
92 [](NNFW_SESSION &session, uint32_t index, py::array_t<int64_t> &buffer) {
93 session.set_input<int64_t>(index, buffer);
94 },
95 py::arg("index"), py::arg("buffer"),
96 "Set input buffer\n"
97 "Parameters:\n"
98 "\tindex (int): Index of input to be set (0-indexed)\n"
99 "\tbuffer (numpy): Raw buffer for input")
100 .def(
101 "set_input",
102 [](NNFW_SESSION &session, uint32_t index, py::array_t<int8_t> &buffer) {
103 session.set_input<int8_t>(index, buffer);
104 },
105 py::arg("index"), py::arg("buffer"),
106 "Set input buffer\n"
107 "Parameters:\n"
108 "\tindex (int): Index of input to be set (0-indexed)\n"
109 "\tbuffer (numpy): Raw buffer for input")
110 .def(
111 "set_input",
112 [](NNFW_SESSION &session, uint32_t index, py::array_t<int16_t> &buffer) {
113 session.set_input<int16_t>(index, buffer);
114 },
115 py::arg("index"), py::arg("buffer"),
116 "Set input buffer\n"
117 "Parameters:\n"
118 "\tindex (int): Index of input to be set (0-indexed)\n"
119 "\tbuffer (numpy): Raw buffer for input")
120 .def("input_size", &NNFW_SESSION::input_size,
121 "Get the number of inputs defined in loaded model\n"
122 "Returns:\n"
123 "\tint: The number of inputs")
124 .def("output_size", &NNFW_SESSION::output_size,
125 "Get the number of outputs defined in loaded model\n"
126 "Returns:\n"
127 "\tint: The number of outputs")
128 .def("set_input_layout", &NNFW_SESSION::set_input_layout, py::arg("index"),
129 py::arg("layout") = "NONE",
130 "Set the layout of an input\n"
131 "Parameters:\n"
132 "\tindex (int): Index of input to be set (0-indexed)\n"
133 "\tlayout (str): Layout to set to target input")
134 .def("input_tensorinfo", &NNFW_SESSION::input_tensorinfo, py::arg("index"),
135 "Get i-th input tensor info\n"
136 "Parameters:\n"
137 "\tindex (int): Index of input\n"
138 "Returns:\n"
139 "\ttensorinfo: Tensor info (shape, type, etc)")
140 .def("output_tensorinfo", &NNFW_SESSION::output_tensorinfo, py::arg("index"),
141 "Get i-th output tensor info\n"
142 "Parameters:\n"
143 "\tindex (int): Index of output\n"
144 "Returns:\n"
145 "\ttensorinfo: Tensor info (shape, type, etc)")
146 .def("get_output", &NNFW_SESSION::get_output, py::arg("index"),
147 R"pbdoc(
148 Retrieve the internally-allocated dynamic output as a copy.
149 Parameters:
150 index (int): Index of the output tensor (0-indexed)
SessionID session(const coco::Module *m)
Definition Session.cpp:48
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54

References onert::api::python::NNFW_SESSION::get_output(), onert::api::python::NNFW_SESSION::input_size(), onert::api::python::NNFW_SESSION::input_tensorinfo(), m, onert::api::python::NNFW_SESSION::output_size(), onert::api::python::NNFW_SESSION::output_tensorinfo(), onert::api::python::NNFW_SESSION::prepare(), onert::api::python::NNFW_SESSION::run(), onert::api::python::NNFW_SESSION::run_async(), onert::api::python::NNFW_SESSION::set_input_layout(), onert::api::python::NNFW_SESSION::set_input_tensorinfo(), and onert::api::python::NNFW_SESSION::wait().

◆ bind_nnfw_session() [2/2]

void onert::api::python::bind_nnfw_session ( pybind11::module_ &  m)

Referenced by PYBIND11_MODULE().

◆ bind_tensorinfo() [1/2]

void onert::api::python::bind_tensorinfo ( py::module_ &  m)

Definition at line 27 of file nnfw_tensorinfo_bindings.cc.

28{
29 py::class_<tensorinfo>(m, "tensorinfo", "tensorinfo describes the type and shape of tensors",
30 py::module_local())
31 .def(py::init<>(), "The constructor of tensorinfo")
32 .def_readwrite("dtype", &tensorinfo::dtype, "The data type")
33 .def_readwrite("rank", &tensorinfo::rank, "The number of dimensions (rank)")
34 .def_property(
35 "dims", [](const tensorinfo &ti) { return get_dims(ti); },
36 [](tensorinfo &ti, const py::list &dims_list) { set_dims(ti, dims_list); },
37 "The dimension of tensor. Maximum rank is 6 (NNFW_MAX_RANK).");
38}
py::list get_dims(const tensorinfo &tensor_info)
Get nnfw_tensorinfo->dims.
tensor info describes the type and shape of tensors

References onert::api::python::tensorinfo::dtype, get_dims(), m, onert::api::python::tensorinfo::rank, and set_dims().

◆ bind_tensorinfo() [2/2]

void onert::api::python::bind_tensorinfo ( pybind11::module_ &  m)

Referenced by PYBIND11_MODULE().

◆ ensure_status()

void onert::api::python::ensure_status ( NNFW_STATUS  status)

Handle errors with NNFW_STATUS in API functions.

This only handles NNFW_STATUS errors.

Parameters
[in]statusThe status returned by API functions

Definition at line 27 of file nnfw_api_wrapper.cc.

28{
29 switch (status)
30 {
32 return;
34 throw NnfwError("NNFW_STATUS_ERROR");
36 throw NnfwUnexpectedNullError("NNFW_STATUS_UNEXPECTED_NULL");
38 throw NnfwInvalidStateError("NNFW_STATUS_INVALID_STATE");
40 throw NnfwOutOfMemoryError("NNFW_STATUS_OUT_OF_MEMORY");
42 throw NnfwInsufficientOutputError("NNFW_STATUS_INSUFFICIENT_OUTPUT_SIZE");
44 throw NnfwDeprecatedApiError("NNFW_STATUS_DEPRECATED_API");
45 default:
46 throw NnfwError("NNFW_UNKNOWN_ERROR");
47 }
48}
@ NNFW_STATUS_INVALID_STATE
Definition onert-micro.h:97
@ NNFW_STATUS_UNEXPECTED_NULL
Definition onert-micro.h:95
@ NNFW_STATUS_NO_ERROR
Definition onert-micro.h:88
@ NNFW_STATUS_DEPRECATED_API
@ NNFW_STATUS_INSUFFICIENT_OUTPUT_SIZE
@ NNFW_STATUS_ERROR
Definition onert-micro.h:93
@ NNFW_STATUS_OUT_OF_MEMORY
Definition onert-micro.h:99

References NNFW_STATUS_DEPRECATED_API, NNFW_STATUS_ERROR, NNFW_STATUS_INSUFFICIENT_OUTPUT_SIZE, NNFW_STATUS_INVALID_STATE, NNFW_STATUS_NO_ERROR, NNFW_STATUS_OUT_OF_MEMORY, and NNFW_STATUS_UNEXPECTED_NULL.

Referenced by onert::api::python::NNFW_SESSION::close_session(), onert::api::python::NNFW_SESSION::get_output(), onert::api::python::NNFW_SESSION::input_size(), onert::api::python::NNFW_SESSION::input_tensorinfo(), onert::api::python::NNFW_SESSION::NNFW_SESSION(), onert::api::python::NNFW_SESSION::output_size(), onert::api::python::NNFW_SESSION::output_tensorinfo(), onert::api::python::NNFW_SESSION::prepare(), onert::api::python::NNFW_SESSION::run(), onert::api::python::NNFW_SESSION::run_async(), onert::api::python::NNFW_SESSION::set_input(), onert::api::python::NNFW_SESSION::set_input_layout(), onert::api::python::NNFW_SESSION::set_input_tensorinfo(), onert::api::python::NNFW_SESSION::set_output(), onert::api::python::NNFW_SESSION::set_prepare_config(), onert::api::python::NNFW_SESSION::train(), onert::api::python::NNFW_SESSION::train_export_checkpoint(), onert::api::python::NNFW_SESSION::train_export_circle(), onert::api::python::NNFW_SESSION::train_get_loss(), onert::api::python::NNFW_SESSION::train_get_traininfo(), onert::api::python::NNFW_SESSION::train_import_checkpoint(), onert::api::python::NNFW_SESSION::train_prepare(), onert::api::python::NNFW_SESSION::train_set_expected(), onert::api::python::NNFW_SESSION::train_set_input(), onert::api::python::NNFW_SESSION::train_set_output(), onert::api::python::NNFW_SESSION::train_set_traininfo(), and onert::api::python::NNFW_SESSION::wait().

◆ get_dims()

py::list onert::api::python::get_dims ( const tensorinfo tensor_info)

Get nnfw_tensorinfo->dims.

This function is called to get dimension array of tensorinfo.

Parameters
[in]tensor_infoTensor info (shape, type, etc)
Returns
python list of dims

Definition at line 117 of file nnfw_api_wrapper.cc.

118{
119 py::list dims_list;
120 for (int32_t i = 0; i < tensor_info.rank; ++i)
121 {
122 dims_list.append(tensor_info.dims[i]);
123 }
124 return dims_list;
125}
int32_t dims[NNFW_MAX_RANK]

References onert::api::python::tensorinfo::dims, and onert::api::python::tensorinfo::rank.

Referenced by bind_tensorinfo().

◆ getLayout()

NNFW_LAYOUT onert::api::python::getLayout ( const char *  layout = "")

Convert the layout with string to NNFW_LAYOUT

Parameters
[in]layoutlayout to be converted
Returns
proper layout if exists

Definition at line 50 of file nnfw_api_wrapper.cc.

51{
52 if (std::strcmp(layout, "NCHW") == 0)
54 else if (std::strcmp(layout, "NHWC") == 0)
56 else if (std::strcmp(layout, "NONE") == 0)
58 else
59 throw NnfwError(std::string("Unknown layout type: '") + layout + "'");
60}
@ NNFW_LAYOUT_CHANNELS_LAST
Definition nnfw.h:141
@ NNFW_LAYOUT_CHANNELS_FIRST
Definition nnfw.h:146
@ NNFW_LAYOUT_NONE
Definition nnfw.h:136

References NNFW_LAYOUT_CHANNELS_FIRST, NNFW_LAYOUT_CHANNELS_LAST, and NNFW_LAYOUT_NONE.

Referenced by onert::api::python::NNFW_SESSION::set_input_layout().

◆ getStringType()

const char * onert::api::python::getStringType ( NNFW_TYPE  type)

Convert the type with NNFW_TYPE to string

Parameters
[in]typetype to be converted
Returns
proper type

Definition at line 82 of file nnfw_api_wrapper.cc.

83{
84 switch (type)
85 {
87 return "float32";
89 return "int32";
90 case NNFW_TYPE::NNFW_TYPE_TENSOR_QUANT8_ASYMM:
91 case NNFW_TYPE::NNFW_TYPE_TENSOR_UINT8:
92 return "uint8";
93 case NNFW_TYPE::NNFW_TYPE_TENSOR_BOOL:
94 return "bool";
95 case NNFW_TYPE::NNFW_TYPE_TENSOR_INT64:
96 return "int64";
97 case NNFW_TYPE::NNFW_TYPE_TENSOR_QUANT8_ASYMM_SIGNED:
98 return "int8";
99 case NNFW_TYPE::NNFW_TYPE_TENSOR_QUANT16_SYMM_SIGNED:
100 return "int16";
101 default:
102 throw NnfwError(std::string("Cannot convert NNFW_TYPE enum to string (value=") +
103 std::to_string(static_cast<int>(type)) + ")");
104 }
105}
@ NNFW_TYPE_TENSOR_INT32
Definition onert-micro.h:79
@ NNFW_TYPE_TENSOR_FLOAT32
Definition onert-micro.h:77

References NNFW_TYPE_TENSOR_FLOAT32, and NNFW_TYPE_TENSOR_INT32.

Referenced by onert::api::python::NNFW_SESSION::get_output(), onert::api::python::NNFW_SESSION::input_tensorinfo(), and onert::api::python::NNFW_SESSION::output_tensorinfo().

◆ getType()

NNFW_TYPE onert::api::python::getType ( const char *  type = "")

Convert the type with string to NNFW_TYPE

Parameters
[in]typetype to be converted
Returns
proper type if exists

Definition at line 62 of file nnfw_api_wrapper.cc.

63{
64 if (std::strcmp(type, "float32") == 0)
66 else if (std::strcmp(type, "int32") == 0)
68 else if (std::strcmp(type, "bool") == 0)
69 return NNFW_TYPE::NNFW_TYPE_TENSOR_UINT8;
70 else if (std::strcmp(type, "bool") == 0)
71 return NNFW_TYPE::NNFW_TYPE_TENSOR_BOOL;
72 else if (std::strcmp(type, "int64") == 0)
73 return NNFW_TYPE::NNFW_TYPE_TENSOR_INT64;
74 else if (std::strcmp(type, "int8") == 0)
75 return NNFW_TYPE::NNFW_TYPE_TENSOR_QUANT8_ASYMM_SIGNED;
76 else if (std::strcmp(type, "int16") == 0)
77 return NNFW_TYPE::NNFW_TYPE_TENSOR_QUANT16_SYMM_SIGNED;
78 else
79 throw NnfwError(std::string("Cannot convert string to NNFW_TYPE: '") + type + "'");
80}

References NNFW_TYPE_TENSOR_FLOAT32, and NNFW_TYPE_TENSOR_INT32.

Referenced by onert::api::python::NNFW_SESSION::set_input_tensorinfo().

◆ num_elems()

uint64_t onert::api::python::num_elems ( const nnfw_tensorinfo tensor_info)

Get the total number of elements in nnfw_tensorinfo->dims.

This function is called to set the size of the input, output array.

Parameters
[in]tensor_infoTensor info (shape, type, etc)
Returns
total number of elements

Definition at line 107 of file nnfw_api_wrapper.cc.

108{
109 uint64_t n = 1;
110 for (int32_t i = 0; i < tensor_info->rank; ++i)
111 {
112 n *= tensor_info->dims[i];
113 }
114 return n;
115}
int32_t dims[NNFW_MAX_RANK]

References nnfw_tensorinfo::dims, and nnfw_tensorinfo::rank.

Referenced by onert::api::python::NNFW_SESSION::set_input(), onert::api::python::NNFW_SESSION::set_output(), and onert::api::python::NNFW_SESSION::train_set_output().

◆ set_dims()

void onert::api::python::set_dims ( tensorinfo tensor_info,
const py::list &  array 
)

Set nnfw_tensorinfo->dims.

This function is called to set dimension array of tensorinfo.

Parameters
[in]tensor_infoTensor info (shape, type, etc)
[in]arrayarray to set dimension

Definition at line 127 of file nnfw_api_wrapper.cc.

128{
129 tensor_info.rank = py::len(array);
130 for (int32_t i = 0; i < tensor_info.rank; ++i)
131 {
132 tensor_info.dims[i] = py::cast<int32_t>(array[i]);
133 }
134}

References onert::api::python::tensorinfo::dims, and onert::api::python::tensorinfo::rank.

Referenced by bind_tensorinfo().