29 py::class_<NNFW_SESSION>(
m,
"nnfw_session", py::module_local())
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"
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.")
41 py::arg(
"tensor_info"),
42 "Set input model's tensor info for resizing.\n"
44 "\tindex (int): Index of input to be set (0-indexed)\n"
45 "\ttensor_info (tensorinfo): Tensor info to be set")
52 [](
NNFW_SESSION &session, uint32_t index, py::array_t<float> &buffer) {
53 session.set_input<
float>(index, buffer);
55 py::arg(
"index"), py::arg(
"buffer"),
58 "\tindex (int): Index of input to be set (0-indexed)\n"
59 "\tbuffer (numpy): Raw buffer for input")
62 [](
NNFW_SESSION &session, uint32_t index, py::array_t<int> &buffer) {
63 session.set_input<
int>(index, buffer);
65 py::arg(
"index"), py::arg(
"buffer"),
68 "\tindex (int): Index of input to be set (0-indexed)\n"
69 "\tbuffer (numpy): Raw buffer for input")
72 [](
NNFW_SESSION &session, uint32_t index, py::array_t<uint8_t> &buffer) {
73 session.set_input<uint8_t>(index, buffer);
75 py::arg(
"index"), py::arg(
"buffer"),
78 "\tindex (int): Index of input to be set (0-indexed)\n"
79 "\tbuffer (numpy): Raw buffer for input")
82 [](
NNFW_SESSION &session, uint32_t index, py::array_t<bool> &buffer) {
83 session.set_input<
bool>(index, buffer);
85 py::arg(
"index"), py::arg(
"buffer"),
88 "\tindex (int): Index of input to be set (0-indexed)\n"
89 "\tbuffer (numpy): Raw buffer for input")
92 [](
NNFW_SESSION &session, uint32_t index, py::array_t<int64_t> &buffer) {
93 session.set_input<int64_t>(index, buffer);
95 py::arg(
"index"), py::arg(
"buffer"),
98 "\tindex (int): Index of input to be set (0-indexed)\n"
99 "\tbuffer (numpy): Raw buffer for input")
102 [](
NNFW_SESSION &session, uint32_t index, py::array_t<int8_t> &buffer) {
103 session.set_input<int8_t>(index, buffer);
105 py::arg(
"index"), py::arg(
"buffer"),
108 "\tindex (int): Index of input to be set (0-indexed)\n"
109 "\tbuffer (numpy): Raw buffer for input")
112 [](
NNFW_SESSION &session, uint32_t index, py::array_t<int16_t> &buffer) {
113 session.set_input<int16_t>(index, buffer);
115 py::arg(
"index"), py::arg(
"buffer"),
118 "\tindex (int): Index of input to be set (0-indexed)\n"
119 "\tbuffer (numpy): Raw buffer for input")
121 "Get the number of inputs defined in loaded model\n"
123 "\tint: The number of inputs")
125 "Get the number of outputs defined in loaded model\n"
127 "\tint: The number of outputs")
129 py::arg(
"layout") =
"NONE",
130 "Set the layout of an input\n"
132 "\tindex (int): Index of input to be set (0-indexed)\n"
133 "\tlayout (str): Layout to set to target input")
135 "Get i-th input tensor info\n"
137 "\tindex (int): Index of input\n"
139 "\ttensorinfo: Tensor info (shape, type, etc)")
141 "Get i-th output tensor info\n"
143 "\tindex (int): Index of output\n"
145 "\ttensorinfo: Tensor info (shape, type, etc)")
148 Retrieve the internally-allocated dynamic output as a copy.
150 index (int): Index of the output tensor (0-indexed)
155 "Set configuration to prepare");
162 m.attr(
"nnfw_session")
163 .cast<py::class_<NNFW_SESSION>>()
165 "Retrieve training information for the model.")
167 "Set training information for the model.")
170 "Run a training step, optionally updating weights.")
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).")