ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
onert::compiler::OperandObserver Class Reference

Class that observe and update operands. More...

#include <StaticShapeInferer.h>

Public Member Functions

 OperandObserver (const std::vector< ir::Operand * > &operands)
 Constructor of OperandObserver.
 
virtual ~OperandObserver ()=default
 Destructor of OperandObserver.
 
void updateShapes (const std::vector< ir::OperandInfo > &changed_operands_info, bool unpredictable=false)
 Update Shape and some OperandInfo of operands.
 

Detailed Description

Class that observe and update operands.

Definition at line 32 of file StaticShapeInferer.h.

Constructor & Destructor Documentation

◆ OperandObserver()

onert::compiler::OperandObserver::OperandObserver ( const std::vector< ir::Operand * > &  operands)
inline

Constructor of OperandObserver.

Parameters
operandsOperands to be updated

Definition at line 40 of file StaticShapeInferer.h.

40: _operands{operands} {}

◆ ~OperandObserver()

virtual onert::compiler::OperandObserver::~OperandObserver ( )
virtualdefault

Destructor of OperandObserver.

Member Function Documentation

◆ updateShapes()

void onert::compiler::OperandObserver::updateShapes ( const std::vector< ir::OperandInfo > &  changed_operands_info,
bool  unpredictable = false 
)

Update Shape and some OperandInfo of operands.

Parameters
operandsOperands to be updated
unpredictableWhether runtime can predict shapes of operands in compilation time

Definition at line 28 of file StaticShapeInferer.cc.

30{
31 assert(changed_operands_info.size() == _operands.size());
32 for (size_t i = 0; i < changed_operands_info.size(); ++i)
33 {
34 const auto &changed_operand_info = changed_operands_info.at(i);
35 auto &operand = _operands.at(i);
36 // assert(changed_operand_info.typeInfo() == operand->typeInfo());
37 // assert(changed_operand_info.typeInfo() == operand->typeInfo());
38 // This error check may by replaced by an assertion if this function is called after the
39 // validation of models are completed.
40 if (changed_operand_info.typeInfo() != operand->typeInfo())
41 {
42 throw std::runtime_error("OperandObserver: The types of operands are mismatched");
43 }
44 if (!operand->info().isConstant() && (changed_operand_info.isDynamic() || unpredictable))
45 {
46 operand->info().setDynamic();
47 }
48 else
49 {
50 const auto &new_shape = changed_operands_info.at(i).shape();
51 operand->info().shape(new_shape);
52 }
53 }
54}

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