ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnfw_tensorinfo_bindings.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
18
19#include "nnfw_api_wrapper.h"
20
21namespace onert
22{
23namespace api
24{
25namespace python
26{
27
28namespace py = pybind11;
29
30// Bind the `tensorinfo` class
31void bind_tensorinfo(py::module_ &m)
32{
33 py::class_<tensorinfo>(m, "tensorinfo", "tensorinfo describes the type and shape of tensors",
34 py::module_local())
35 .def(py::init<>(), "The constructor of tensorinfo")
36 .def_readwrite("dtype", &tensorinfo::dtype, "The data type")
37 .def_readwrite("rank", &tensorinfo::rank, "The number of dimensions (rank)")
38 .def_property(
39 "dims", [](const tensorinfo &ti) { return get_dims(ti); },
40 [](tensorinfo &ti, const py::list &dims_list) { set_dims(ti, dims_list); },
41 "The dimension of tensor. Maximum rank is 6 (NNFW_MAX_RANK).");
42}
43
44} // namespace python
45} // namespace api
46} // namespace onert
void set_dims(tensorinfo &tensor_info, const py::list &array)
Set nnfw_tensorinfo->dims.
void bind_tensorinfo(pybind11::module_ &m)
py::list get_dims(const tensorinfo &tensor_info)
Get nnfw_tensorinfo->dims.
tensor info describes the type and shape of tensors