ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::acl_common::AclSubTensorAnalyzer Class Reference

Class to analyze tensor subsumption. More...

#include <AclSubTensorAnalyzer.h>

Collaboration diagram for onert::backend::acl_common::AclSubTensorAnalyzer:

Public Member Functions

 AclSubTensorAnalyzer (const ir::Graph &graph)
 Construct a new SubTensorAnalyzer object.
 
void setUsePadding ()
 
void visit (const ir::operation::Concat &node) override
 
std::unordered_map< ir::OperandIndex, cl_common::ParentInfo > && releaseParentMap ()
 
- Public Member Functions inherited from onert::ir::OperationVisitor
virtual ~OperationVisitor ()=default
 

Detailed Description

Class to analyze tensor subsumption.

Definition at line 35 of file AclSubTensorAnalyzer.h.

Constructor & Destructor Documentation

◆ AclSubTensorAnalyzer()

onert::backend::acl_common::AclSubTensorAnalyzer::AclSubTensorAnalyzer ( const ir::Graph graph)
inline

Construct a new SubTensorAnalyzer object.

Parameters
[in]ctxGraph operand set

Definition at line 42 of file AclSubTensorAnalyzer.h.

42 : _graph{graph}
43 {
44 // DO NOTHING
45 }

Member Function Documentation

◆ releaseParentMap()

std::unordered_map< ir::OperandIndex, cl_common::ParentInfo > && onert::backend::acl_common::AclSubTensorAnalyzer::releaseParentMap ( )
inline

Definition at line 102 of file AclSubTensorAnalyzer.h.

103 {
104 return std::move(_parent_map);
105 }

◆ setUsePadding()

void onert::backend::acl_common::AclSubTensorAnalyzer::setUsePadding ( )
inline

Definition at line 48 of file AclSubTensorAnalyzer.h.

48{ usePadding = true; }

◆ visit()

void onert::backend::acl_common::AclSubTensorAnalyzer::visit ( const ir::operation::Concat node)
inlineoverride

NOTE Not support below cases.

  1. concat's input is a constant.
  2. concat's input is a input of model.
  3. concat's input already becomes a subtensor of another concat.

Definition at line 50 of file AclSubTensorAnalyzer.h.

51 {
52 // If operator is concat, fill subsumption info
53 int32_t axis_raw = node.param().axis;
54
55 const auto &output_index = node.getOutputs().at(0);
56 const auto &inputs = node.getInputs();
57
58 int32_t axis_point = 0;
59 const auto rank = _graph.operands().at(output_index).shape().rank();
60 int32_t axis = axis_raw < 0 ? (axis_raw + rank) : axis_raw;
61 assert(rank > axis);
62
63 // Concat elimination when axis is last dimension is not supported
64 // https://github.com/Samsung/ONE/issues/4407
65 // TODO Enable if backend don't use padding
66 if ((axis == rank - 1) && usePadding)
67 return;
68
69 for (const auto &ind : inputs)
70 {
77 if (_graph.operands().at(ind).isConstant() || _graph.getInputs().contains(ind) ||
78 _parent_map.find(ind) != _parent_map.end())
79 {
80 return;
81 }
82 }
83
84 for (const auto &input_index : inputs)
85 {
86 auto input_shape = _graph.operands().at(input_index).shape();
87 assert(rank == input_shape.rank());
88
89 ir::Coordinates coordinate_info{};
90 for (int i = 0; i < rank; i++)
91 {
92 coordinate_info.set(i, 0);
93 }
94 coordinate_info.set(axis, axis_point);
95
96 _parent_map.emplace(input_index, cl_common::ParentInfo{output_index, coordinate_info});
97
98 axis_point += input_shape.dim(axis);
99 }
100 }
const Operands & operands() const override
Definition Graph.h:112
const OperandIndexSequence & getInputs() const override
Definition Graph.h:106
bool contains(const OperandIndex &index) const
const Object & at(const Index &index) const
Get the object that is associated with the given index.

References onert::util::ObjectManager< Index, Object >::at(), onert::ir::OperandIndexSequence::at(), onert::ir::operation::Concat::Param::axis, onert::ir::OperandIndexSequence::contains(), onert::ir::Operation::getInputs(), onert::ir::Graph::getInputs(), onert::ir::Operation::getOutputs(), onert::ir::Graph::operands(), onert::ir::operation::Concat::param(), and onert::ir::Coordinates::set().


The documentation for this class was generated from the following file: