ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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::api::python
22{
23
24namespace py = pybind11;
25
26// Bind the `tensorinfo` class
27void bind_tensorinfo(py::module_ &m)
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}
39
40} // namespace onert::api::python
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