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

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

parent 956bb3f0
No related branches found
No related tags found
2 merge requests!212Version 0.3.0,!164Update 'Operator::setOutput()' and overrides to be const
Pipeline #50520 failed
......@@ -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.");
}
......
......@@ -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