Skip to content
Snippets Groups Projects
Commit bd5dd3bb authored by Christophe Guillon's avatar Christophe Guillon
Browse files

[Memorize] Add python binding for Memorize

Add Memorize operator binding for constructing node as
aidge_core.Memorize(end_step: int, name: str = "").

Update Memorize Registrar parent class to shared_ptr
in order to share implementation with python.
parent 1f26e48b
Loading
Pipeline #54446 passed
......@@ -37,7 +37,7 @@ public:
enum class MemorizeAttr { ScheduleStep, ForwardStep, EndStep };
class Memorize_Op : public OperatorTensor,
public Registrable<Memorize_Op, std::string, std::unique_ptr<OperatorImpl>(const Memorize_Op&)> {
public Registrable<Memorize_Op, std::string, std::shared_ptr<OperatorImpl>(const Memorize_Op&)> {
public:
static const std::string Type;
......
/********************************************************************************
* 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 <string>
#include <vector>
#include "aidge/operator/Memorize.hpp"
#include "aidge/operator/OperatorTensor.hpp"
namespace py = pybind11;
namespace Aidge {
void init_Memorize(py::module& m) {
py::class_<Memorize_Op, std::shared_ptr<Memorize_Op>, OperatorTensor>(m, "MemorizeOp", py::multiple_inheritance())
.def(py::init<const std::uint32_t>(), py::arg("end_step"))
.def_static("get_inputs_name", &Memorize_Op::getInputsName)
.def_static("get_outputs_name", &Memorize_Op::getOutputsName);
declare_registrable<Memorize_Op>(m, "MemorizeOp");
m.def("Memorize", &Memorize, py::arg("end_step"), py::arg("name") = "");
}
} // namespace Aidge
......@@ -47,6 +47,7 @@ void init_Identity(py::module&);
void init_LeakyReLU(py::module&);
void init_MatMul(py::module&);
void init_MaxPooling(py::module&);
void init_Memorize(py::module&);
void init_MetaOperatorDefs(py::module&);
void init_Mul(py::module&);
void init_Pad(py::module&);
......@@ -126,6 +127,7 @@ void init_Aidge(py::module& m) {
init_LeakyReLU(m);
init_MatMul(m);
init_MaxPooling(m);
init_Memorize(m);
init_MetaOperatorDefs(m);
init_Mul(m);
init_Pad(m);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment