ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 31 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 38 of file AclSubTensorAnalyzer.h.

38 : _graph{graph}
39 {
40 // DO NOTHING
41 }

Member Function Documentation

◆ releaseParentMap()

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

Definition at line 98 of file AclSubTensorAnalyzer.h.

99 {
100 return std::move(_parent_map);
101 }

◆ setUsePadding()

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

Definition at line 44 of file AclSubTensorAnalyzer.h.

44{ 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 46 of file AclSubTensorAnalyzer.h.

47 {
48 // If operator is concat, fill subsumption info
49 int32_t axis_raw = node.param().axis;
50
51 const auto &output_index = node.getOutputs().at(0);
52 const auto &inputs = node.getInputs();
53
54 int32_t axis_point = 0;
55 const auto rank = _graph.operands().at(output_index).shape().rank();
56 int32_t axis = axis_raw < 0 ? (axis_raw + rank) : axis_raw;
57 assert(rank > axis);
58
59 // Concat elimination when axis is last dimension is not supported
60 // https://github.com/Samsung/ONE/issues/4407
61 // TODO Enable if backend don't use padding
62 if ((axis == rank - 1) && usePadding)
63 return;
64
65 for (const auto &ind : inputs)
66 {
73 if (_graph.operands().at(ind).isConstant() || _graph.getInputs().contains(ind) ||
74 _parent_map.find(ind) != _parent_map.end())
75 {
76 return;
77 }
78 }
79
80 for (const auto &input_index : inputs)
81 {
82 auto input_shape = _graph.operands().at(input_index).shape();
83 assert(rank == input_shape.rank());
84
85 ir::Coordinates coordinate_info{};
86 for (int i = 0; i < rank; i++)
87 {
88 coordinate_info.set(i, 0);
89 }
90 coordinate_info.set(axis, axis_point);
91
92 _parent_map.emplace(input_index, cl_common::ParentInfo{output_index, coordinate_info});
93
94 axis_point += input_shape.dim(axis);
95 }
96 }
const Operands & operands() const override
Definition Graph.h:110
const OperandIndexSequence & getInputs() const override
Definition Graph.h:104
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: