Skip to content
Snippets Groups Projects
Commit 2463ebc9 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Fixed incorrect MetaOperator copy constructor and clone() method

parent 62de1a25
No related branches found
No related tags found
2 merge requests!333[Fix] Attribute snake case,!322Fix Generic and Meta op copy constructor issues
Pipeline #64790 passed
...@@ -69,10 +69,7 @@ public: ...@@ -69,10 +69,7 @@ public:
* *
* @param op The operator to copy. * @param op The operator to copy.
*/ */
MetaOperator_Op(const MetaOperator_Op& op) MetaOperator_Op(const MetaOperator_Op& op);
: OperatorTensor(op),
mGraph(op.mGraph->clone()) // Clone the micro-graph for isolation
{}
/** /**
* @brief Set the node for scheduling. * @brief Set the node for scheduling.
......
...@@ -54,8 +54,28 @@ Aidge::MetaOperator_Op::MetaOperator_Op(const std::string& type, const std::shar ...@@ -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 { 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) { 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