ONE - On-device Neural Engine
Loading...
Searching...
No Matches
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 34 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 42 of file StaticShapeInferer.h.

42: _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 30 of file StaticShapeInferer.cc.

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

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