diff --git a/include/aidge/operator/MetaOperator.hpp b/include/aidge/operator/MetaOperator.hpp index f7f1cdfd5bc0d799adc87bd7b7e1be999363627f..c6ab45290265617850c01bb00abd7f972cd3525c 100644 --- a/include/aidge/operator/MetaOperator.hpp +++ b/include/aidge/operator/MetaOperator.hpp @@ -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. diff --git a/include/aidge/operator/Operator.hpp b/include/aidge/operator/Operator.hpp index 40899ffa7668298f3e90e09b9a30ed9f438d89b2..dd59af175231acb274126d7f396cdd502046b004 100644 --- a/include/aidge/operator/Operator.hpp +++ b/include/aidge/operator/Operator.hpp @@ -118,12 +118,12 @@ public: */ Operator(const Operator& op): std::enable_shared_from_this<Operator>(), + mType(op.mType), mOperatorType(op.mOperatorType), mInputsCategory(op.mInputsCategory), mNbOut(op.mNbOut), mBackEdges(op.mBackEdges) { - mType = op.mType; mImpl = nullptr; // Implementation is never cloned. It is up to the non-abstract Operator copy-constructor to create a new implementation matching the copied Operator implementation. // See https://gitlab.eclipse.org/eclipse/aidge/aidge_core/-/merge_requests/8#note_1214050 for the discussion. diff --git a/src/backend/OperatorImpl.cpp b/src/backend/OperatorImpl.cpp index 71f4f04b2d73e1501a2d428dd91dc8f85dd17649..08f5fe671c7502a6c5fe01dbdfb7ae4c9b95ac81 100644 --- a/src/backend/OperatorImpl.cpp +++ b/src/backend/OperatorImpl.cpp @@ -74,13 +74,6 @@ Aidge::ImplSpec Aidge::OperatorImpl::getRequiredSpec() const { requiredSpec.outputs.push_back({opTensor.getOutput(i)->dataType(), opTensor.getOutput(i)->dataFormat(), dims}); } - // Attributes - if (!mOp.isAtomic()) { - requiredSpec.attrs.setAttr("type:!", mOp.type()); // :! mandatory qualifier - } - else { - requiredSpec.attrs.setAttr("type", mOp.type()); - } const auto& inhAttrs = mOp.inheritedAttributes(); if (inhAttrs) { diff --git a/src/operator/GenericOperator.cpp b/src/operator/GenericOperator.cpp index 1e28cf289960dee280457cd6ea119fcc9477cf9f..e0f7cf34a91268c33395dfc94d20c25b4cb0e3d1 100644 --- a/src/operator/GenericOperator.cpp +++ b/src/operator/GenericOperator.cpp @@ -45,7 +45,7 @@ Aidge::GenericOperator_Op::GenericOperator_Op(const std::string& type, Aidge::GenericOperator_Op::GenericOperator_Op(const Aidge::GenericOperator_Op& op) : OperatorTensor(op), mForwardDims(op.mForwardDims), - mAttributes(op.attributes() ? op.mAttributes : std::make_shared<DynamicAttributes>()) + mAttributes(std::make_shared<DynamicAttributes>(*op.mAttributes)) { mImpl = std::make_shared<OperatorImpl>(*this, op.backend()); } diff --git a/src/operator/MetaOperator.cpp b/src/operator/MetaOperator.cpp index ae3c3ed6ca85c059204c524f467f5387f656e30b..96c5b219a35a32fb9574eda1a36a8fa4ee502cc4 100644 --- a/src/operator/MetaOperator.cpp +++ b/src/operator/MetaOperator.cpp @@ -54,8 +54,31 @@ 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) { + // Only setBackend() is mImpl is not nullptr. + // The inner-graph backend is already set in MetaOperator_Op copy + // construtor, when the graph is cloned. + metaOp->setBackend(mImpl->backend()); + } + return metaOp; } void Aidge::MetaOperator_Op::associateInput(const IOIndex_t inputIdx, const std::shared_ptr<Data>& data) {