Skip to content
Snippets Groups Projects

Fix Generic and Meta op copy constructor issues

Merged Olivier BICHLER requested to merge fix_opctr into dev
2 unresolved threads
  • Fixed incorrect MetaOperator copy constructor and clone() method;
  • Fixed attributes not properly cloned in GenericOperator copy constructor;
  • Removed mandatory type attribute for Meta op, which is redundant with Meta op impl registry.
Edited by Olivier BICHLER

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
54 54 }
55 55 }
56 56
57 Aidge::MetaOperator_Op::MetaOperator_Op(const MetaOperator_Op& op)
58 : OperatorTensor(op),
59 mGraph(op.mGraph->clone()), // Clone the micro-graph for isolation
60 mAttributes(std::make_shared<DynamicAttributes>(*op.mAttributes)) // Clone attributes
61 {
62 // Associate outputs to micro-graph outputs for custom implementation
63 for (size_t outputIdx = 0; outputIdx < mOutputs.size(); ++outputIdx) {
64 const auto& outputOp = mGraph->getOrderedOutputs()[outputIdx];
  • 54 54 }
    55 55 }
    56 56
    57 Aidge::MetaOperator_Op::MetaOperator_Op(const MetaOperator_Op& op)
    58 : OperatorTensor(op),
    59 mGraph(op.mGraph->clone()), // Clone the micro-graph for isolation
    60 mAttributes(std::make_shared<DynamicAttributes>(*op.mAttributes)) // Clone attributes
    61 {
    62 // Associate outputs to micro-graph outputs for custom implementation
    63 for (size_t outputIdx = 0; outputIdx < mOutputs.size(); ++outputIdx) {
    64 const auto& outputOp = mGraph->getOrderedOutputs()[outputIdx];
    65 if (outputOp.first) {
    66 mOutputs[outputIdx] = std::dynamic_pointer_cast<Tensor>(outputOp.first->getOperator()->getRawOutput(outputOp.second));
    • Actually here you are using the copy operator which performs a shallow copy. This will probably cause a bug and I am not sure the user intends to copy the value of the output when copying the Operator.

      This is why OperatorTensor copy constructor only copies some keys features for Output Tensor copy

          mOutputs[i] = std::make_shared<Tensor>();
          mOutputs[i]->setDataType(other.getOutput(i)->dataType());
          mOutputs[i]->setDataFormat(other.getOutput(i)->dataFormat());
      
          if (!other.getOutput(i)->backend().empty()) {
              mOutputs[i]->setBackend(other.getOutput(i)->backend());
          }
    • Actually this is different: here we have to associate outputs of the Meta op with its internal node outputs! We are not copying any value.

    • Please register or sign in to reply
    Please register or sign in to reply
    Loading