Skip to content

Commit

Permalink
[onert] Add generating training usedefs for Reshape op (Samsung#13460)
Browse files Browse the repository at this point in the history
This commit adds generating training usedefs for Reshape operation.

ONE-DCO-1.0-Signed-off-by: ragmani <[email protected]>
  • Loading branch information
ragmani authored Jul 18, 2024
1 parent 8e19a4a commit 5cae6ff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions runtime/onert/core/src/ir/train/UseDefGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ void UseDefGenerator::visit(const train::operation::Loss &node)
usedef_chain.removeTrainingUse(backwarding_op_index);
}

void UseDefGenerator::visit(const train::operation::Reshape &node)
{
assert(_node_to_idx.find(&node) != _node_to_idx.end());
const auto &op_index = _node_to_idx.at(&node);
const auto backwarding_op_index = TrainingOperationIndex{op_index, false};

// Insert use of backwarding(backprop) output
const auto &out_index = node.getOutputs().at(0);
const auto incoming_index = TrainingOperandIndex{out_index, false};
insertUse(incoming_index, backwarding_op_index);

// Set def of backwarding(backprop) input
const auto &in_index = node.getInputs().at(train::operation::Reduce::Input::INPUT);
const auto outgoing_index = TrainingOperandIndex{in_index, false};
insertBackPropDef(outgoing_index, backwarding_op_index);
}

void UseDefGenerator::insertUse(const TrainingOperandIndex &operand_index,
const TrainingOperationIndex &op_index)
{
Expand Down
1 change: 1 addition & 0 deletions runtime/onert/core/src/ir/train/UseDefGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class UseDefGenerator : public UseDefGeneratorBase

public:
void visit(const train::operation::Loss &node) override;
void visit(const train::operation::Reshape &node) override;

private:
void insertUse(const TrainingOperandIndex &operand_index, const TrainingOperationIndex &op_index);
Expand Down

0 comments on commit 5cae6ff

Please sign in to comment.