Skip to content
Snippets Groups Projects
Commit dc82c0f5 authored by Olivier BICHLER's avatar Olivier BICHLER Committed by Maxence Naud
Browse files

Fixed incorrect MetaOperator copy constructor and clone() method

parent fe598818
No related branches found
No related tags found
1 merge request!325[Upd] Patch v0.5.1
......@@ -69,10 +69,7 @@ public:
*
* @param op The operator to copy.
*/
MetaOperator_Op(const MetaOperator_Op& op)
: OperatorTensor(op),
mGraph(op.mGraph->clone()) // Clone the micro-graph for isolation
{}
MetaOperator_Op(const MetaOperator_Op& op);
/**
* @brief Set the node for scheduling.
......
......@@ -54,8 +54,28 @@ Aidge::MetaOperator_Op::MetaOperator_Op(const std::string& type, const std::shar
}
}
Aidge::MetaOperator_Op::MetaOperator_Op(const MetaOperator_Op& op)
: OperatorTensor(op),
mGraph(op.mGraph->clone()), // Clone the micro-graph for isolation
mAttributes(std::make_shared<DynamicAttributes>(*op.mAttributes)) // Clone attributes
{
// Associate outputs to micro-graph outputs for custom implementation
for (size_t outputIdx = 0; outputIdx < mOutputs.size(); ++outputIdx) {
const auto& outputOp = mGraph->getOrderedOutputs()[outputIdx];
if (outputOp.first) {
mOutputs[outputIdx] = std::dynamic_pointer_cast<Tensor>(outputOp.first->getOperator()->getRawOutput(outputOp.second));
}
}
// Attributes are already cloned.
}
std::shared_ptr<Aidge::Operator> Aidge::MetaOperator_Op::clone() const {
return std::make_shared<MetaOperator_Op>(type(), mGraph->clone());
auto metaOp = std::make_shared<MetaOperator_Op>(*this);
if (mImpl) {
metaOp->setBackend(mImpl->backend());
}
return metaOp;
}
void Aidge::MetaOperator_Op::associateInput(const IOIndex_t inputIdx, const std::shared_ptr<Data>& 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