diff --git a/include/aidge/backend/QuantizationCPU.hpp b/include/aidge/backend/QuantizationCPU.hpp index 8b6fe7853e484b0c19e3a59923b96711be3f2b2d..dbc6c0ebbc55493399e0c8fd00ab2eaa1c7f97bc 100644 --- a/include/aidge/backend/QuantizationCPU.hpp +++ b/include/aidge/backend/QuantizationCPU.hpp @@ -15,6 +15,8 @@ #include "aidge/backend/cpu/operator/LSQImpl.hpp" #include "aidge/backend/cpu/operator/SAT/TanhClampImpl.hpp" +#include "aidge/backend/cpu/operator/SAT/DoReFaImpl.hpp" + // ... diff --git a/python_binding/operator/SAT/pybind_DoReFa.cpp b/python_binding/operator/SAT/pybind_DoReFa.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4e66665f71cf22ee48dd814692e7645c515e4dc1 --- /dev/null +++ b/python_binding/operator/SAT/pybind_DoReFa.cpp @@ -0,0 +1,34 @@ +/******************************************************************************** + * 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/data/Tensor.hpp" +#include "aidge/operator/SAT/DoReFa.hpp" +#include "aidge/operator/OperatorTensor.hpp" + +namespace py = pybind11; +namespace Aidge { + +void init_DoReFa(py::module& m) { + py::enum_<DoReFaMode>(m, "DoReFaMode") + .value("Default", DoReFaMode::Default) + .value("Symmetric", DoReFaMode::Symmetric) + .export_values(); + + py::class_<DoReFa_Op, std::shared_ptr<DoReFa_Op>, OperatorTensor>(m, "DoReFaOp", py::multiple_inheritance()) + .def(py::init<size_t, DoReFaMode>(), py::arg("range") = 255, py::arg("mode") = DoReFaMode::Default) + .def_static("get_inputs_name", &DoReFa_Op::getInputsName) + .def_static("get_outputs_name", &DoReFa_Op::getOutputsName); + declare_registrable<DoReFa_Op>(m, "DoReFaOp"); + m.def("DoReFa", &DoReFa, py::arg("range") = 255, py::arg("mode") = DoReFaMode::Default, py::arg("name") = ""); +} +} // namespace Aidge diff --git a/python_binding/pybind_Quantization.cpp b/python_binding/pybind_Quantization.cpp index 2ab1d0d3b35f253929e2a2f58a0075635cc00beb..ab26c112e093bcb016a8da6911cc5f6c919dd6e3 100644 --- a/python_binding/pybind_Quantization.cpp +++ b/python_binding/pybind_Quantization.cpp @@ -23,6 +23,7 @@ namespace Aidge void init_FixedQ(py::module& m); void init_LSQ(py::module& m); void init_TanhClamp(py::module& m); +void init_DoReFa(py::module& m); // quantization routines @@ -36,12 +37,11 @@ PYBIND11_MODULE(aidge_quantization, m) init_FixedQ(m); init_LSQ(m); init_TanhClamp(m); - + init_DoReFa(m); init_PTQ(m); init_QAT_FixedQ(m); init_QAT_LSQ(m); - } } // namespace Aidge