From 006e8f4bfc4a1557aae8292bd13783ff358ffbff Mon Sep 17 00:00:00 2001 From: thibault allenet <thibault.allenet@cea.fr> Date: Wed, 4 Dec 2024 13:27:55 +0000 Subject: [PATCH] Add python binding for WeightInterleaving Operator --- .../operator/pybind_WeightInterleaving.cpp | 39 +++++++++++++++++++ python_binding/pybind_core.cpp | 2 + 2 files changed, 41 insertions(+) create mode 100644 python_binding/operator/pybind_WeightInterleaving.cpp diff --git a/python_binding/operator/pybind_WeightInterleaving.cpp b/python_binding/operator/pybind_WeightInterleaving.cpp new file mode 100644 index 000000000..25b423bd6 --- /dev/null +++ b/python_binding/operator/pybind_WeightInterleaving.cpp @@ -0,0 +1,39 @@ +/******************************************************************************** + * Copyright (c) 2023 CEA-List + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + +#include <pybind11/pybind11.h> +#include "aidge/operator/WeightInterleaving.hpp" + +namespace py = pybind11; + +namespace Aidge { + +void declare_WeightInterleaving(py::module &m) { + py::class_<WeightInterleaving_Op, std::shared_ptr<WeightInterleaving_Op>, OperatorTensor>(m, "WeightInterleavingOp", py::multiple_inheritance()) + .def(py::init<>()) + .def_static("get_inputs_name", &WeightInterleaving_Op::getInputsName) + .def_static("get_outputs_name", &WeightInterleaving_Op::getOutputsName) + .def_readonly_static("Type", &WeightInterleaving_Op::Type) + + .def("__repr__", [](WeightInterleaving_Op& b) { + return fmt::format("Operator(type='{}')", b.Type); + }); + + declare_registrable<WeightInterleaving_Op>(m, "WeightInterleavingOp"); + + m.def("WeightInterleaving", &WeightInterleaving, py::arg("name") = ""); +} + +void init_WeightInterleaving(py::module &m) { + declare_WeightInterleaving(m); +} + +} // namespace Aidge diff --git a/python_binding/pybind_core.cpp b/python_binding/pybind_core.cpp index 006eeb289..f572c024d 100644 --- a/python_binding/pybind_core.cpp +++ b/python_binding/pybind_core.cpp @@ -83,6 +83,7 @@ void init_Sub(py::module&); void init_Tanh(py::module&); void init_Transpose(py::module&); void init_Unsqueeze(py::module&); +void init_WeightInterleaving(py::module&); void init_Node(py::module&); void init_GraphView(py::module&); @@ -177,6 +178,7 @@ void init_Aidge(py::module& m) { init_Tanh(m); init_Transpose(m); init_Unsqueeze(m); + init_WeightInterleaving(m); init_Producer(m); -- GitLab