Skip to content
Snippets Groups Projects
Commit d68006ec authored by Cyril Moineau's avatar Cyril Moineau
Browse files

[PyBind] Update GenericOp ctor to use kwargs to set attributes.

parent 76e8a21d
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,31 @@ void init_GenericOperator(py::module& m) { ...@@ -27,7 +27,31 @@ void init_GenericOperator(py::module& m) {
.def("compute_output_dims", &GenericOperator_Op::computeOutputDims) .def("compute_output_dims", &GenericOperator_Op::computeOutputDims)
.def("set_compute_output_dims", &GenericOperator_Op::setComputeOutputDims, py::arg("computation_function")); .def("set_compute_output_dims", &GenericOperator_Op::setComputeOutputDims, py::arg("computation_function"));
m.def("GenericOperator", &GenericOperator, py::arg("type"), py::arg("nb_data"), py::arg("nb_param"), py::arg("nb_out"), // &GenericOperator
py::arg("name") = ""); m.def("GenericOperator",
[]( const std::string& type,
IOIndex_t nbData,
IOIndex_t nbParam,
IOIndex_t nbOut,
const std::string& name = "",
const py::kwargs kwargs) {
std::shared_ptr<Node> genericNode = GenericOperator(
type,
nbData,
nbParam,
nbOut,
name
);
if (kwargs){
std::shared_ptr<GenericOperator_Op> gop = std::static_pointer_cast<GenericOperator_Op>(genericNode->getOperator());
for (auto item : kwargs) {
std::string key = py::cast<std::string>(item.first);
py::object value = py::reinterpret_borrow<py::object>(item.second);
gop->setAttrPy(key, std::move(value));
}
}
return genericNode;
}
, py::arg("type"), py::arg("nb_data"), py::arg("nb_param"), py::arg("nb_out"), py::arg("name") = "");
} }
} // namespace Aidge } // namespace Aidge
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