Skip to content
Snippets Groups Projects
Commit aa12de58 authored by Maxence Naud's avatar Maxence Naud
Browse files

Merge branch 'chore_setOutput-should-be-const' into 'dev'

Update 'Operator::setOutput()' and overrides to be const

See merge request !164
parents b9f2c952 88558904
No related branches found
No related tags found
2 merge requests!212Version 0.3.0,!164Update 'Operator::setOutput()' and overrides to be const
Pipeline #50620 passed
......@@ -109,7 +109,7 @@ public:
* The pointer itself is not changed, thus keeping the current connections.
* @param inputIdx Index of the input to set.
*/
virtual void setOutput(const IOIndex_t outputIdx, const std::shared_ptr<Data>& data) = 0;
virtual void setOutput(const IOIndex_t outputIdx, const std::shared_ptr<Data>& data) const = 0;
virtual std::shared_ptr<Data> getRawOutput(const IOIndex_t outputIdx) const = 0;
std::shared_ptr<Hook> getHook(const std::string& hookName) {
......
......@@ -62,7 +62,7 @@ public:
std::shared_ptr<Data> getRawInput(const IOIndex_t inputIdx) const override final;
// output management
void setOutput(const IOIndex_t outputIdx, const std::shared_ptr<Data>& data) override;
void setOutput(const IOIndex_t outputIdx, const std::shared_ptr<Data>& data) const override;
virtual const std::shared_ptr<Tensor>& getOutput(const IOIndex_t outputIdx) const;
std::shared_ptr<Aidge::Data> getRawOutput(const Aidge::IOIndex_t outputIdx) const override final;
///////////////////////////////////////////////////
......
......@@ -115,7 +115,7 @@ public:
// fmt::print("Basic Producer backward() function.\n");
}
void setOutput(const Aidge::IOIndex_t outputIdx, const std::shared_ptr<Aidge::Data>& data) override {
void setOutput(const Aidge::IOIndex_t outputIdx, const std::shared_ptr<Aidge::Data>& data) const override {
if (mAttributes->template getAttr<ProdAttr::Constant>()) {
AIDGE_THROW_OR_ABORT(std::runtime_error, "Producer is constant, cannot update output.");
}
......
......@@ -37,7 +37,7 @@ void init_Operator(py::module& m){
py::class_<Operator, std::shared_ptr<Operator>>(m, "Operator")
.def("__repr__", &Operator::repr)
.def("backend", &Operator::backend)
.def("set_output", py::overload_cast<const IOIndex_t, const std::shared_ptr<Data>&>(&Operator::setOutput), py::arg("outputIdx"), py::arg("data"))
.def("set_output", py::overload_cast<const IOIndex_t, const std::shared_ptr<Data>&>(&Operator::setOutput, py::const_), py::arg("outputIdx"), py::arg("data"))
.def("set_input", py::overload_cast<const IOIndex_t, const std::shared_ptr<Data>&>(&Operator::setInput), py::arg("inputIdx"), py::arg("data"))
.def("get_raw_output", &Operator::getRawOutput, py::arg("outputIdx"))
.def("set_input", py::overload_cast<const IOIndex_t, const std::shared_ptr<Data>&>(&Operator::setInput), py::arg("inputIdx"), py::arg("data"))
......
......@@ -28,7 +28,7 @@ void init_OperatorTensor(py::module& m){
.def("get_output", &OperatorTensor::getOutput, py::arg("outputIdx"))
.def("get_input", &OperatorTensor::getInput, py::arg("inputIdx"))
.def("set_output", (void (OperatorTensor::*)(const IOIndex_t, const std::shared_ptr<Data>&)) &OperatorTensor::setOutput, py::arg("outputIdx"), py::arg("data"))
.def("set_output", (void (OperatorTensor::*)(const IOIndex_t, const std::shared_ptr<Data>&) const) &OperatorTensor::setOutput, py::arg("outputIdx"), py::arg("data"))
.def("set_input", (void (OperatorTensor::*)(const IOIndex_t, const std::shared_ptr<Data>&)) &OperatorTensor::setInput, py::arg("outputIdx"), py::arg("data"))
.def("forward_dims", &OperatorTensor::forwardDims, py::arg("allow_data_dependency") = false)
.def("dims_forwarded", &OperatorTensor::dimsForwarded)
......
......@@ -73,7 +73,7 @@ const std::shared_ptr<Aidge::Tensor>& Aidge::OperatorTensor::getInput(const Aidg
return mInputs[inputIdx];
}
void Aidge::OperatorTensor::setOutput(const Aidge::IOIndex_t outputIdx, const std::shared_ptr<Aidge::Data>& data) {
void Aidge::OperatorTensor::setOutput(const Aidge::IOIndex_t outputIdx, const std::shared_ptr<Aidge::Data>& data) const {
AIDGE_ASSERT(data->type() == Tensor::Type, "{} Operator only accepts Tensors as inputs", type());
AIDGE_ASSERT(outputIdx < nbOutputs(), "{} Operator has {} outputs", type(), nbOutputs());
const auto& data_tensor = std::dynamic_pointer_cast<Tensor>(data);
......
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