ONE - On-device Neural Engine
Loading...
Searching...
No Matches
mir::Operation Class Referenceabstract

#include <Operation.h>

Data Structures

class  Output
 Represents an output of a node. More...
 
struct  Use
 Represents a use of an operation output. More...
 

Public Types

enum class  Type { HANDLE_OP }
 

Public Member Functions

virtual ~Operation ()=default
 
Type getType () const
 
std::size_t getId () const
 
void setId (std::size_t id)
 
std::size_t getNumInputs () const
 
std::size_t getNumOutputs () const
 
std::deque< Output * > & getInputs ()
 
const std::deque< Output * > & getInputs () const
 
std::deque< Output > & getOutputs ()
 
const std::deque< Output > & getOutputs () const
 
OutputgetInput (std::size_t index)
 
const OutputgetInput (std::size_t index) const
 
OutputgetOutput (std::size_t index)
 
const OutputgetOutput (std::size_t index) const
 
const ShapegetInputShape (std::size_t index) const
 
const ShapegetOutputShape (std::size_t index) const
 
void accept (IVisitor *v)
 
virtual OperationcopyWithInputs (const std::vector< Output * > &inputs)=0
 

Protected Member Functions

 Operation (Type type, const std::vector< Output * > &inputs, std::size_t num_outputs=1)
 
void setOutputType (std::size_t index, const TensorType &type)
 

Detailed Description

Definition at line 32 of file Operation.h.

Member Enumeration Documentation

◆ Type

enum class mir::Operation::Type
strong
Enumerator
HANDLE_OP 

Definition at line 35 of file Operation.h.

36 {
37#define HANDLE_OP(OpType, OpClass) OpType,
38#include "mir/Operations.inc"
39#undef HANDLE_OP
40 };

Constructor & Destructor Documentation

◆ ~Operation()

virtual mir::Operation::~Operation ( )
virtualdefault

◆ Operation()

Operation::Operation ( Type  type,
const std::vector< Output * > &  inputs,
std::size_t  num_outputs = 1 
)
protected

Definition at line 42 of file Operation.cpp.

43 : _type(type)
44{
45 for (std::size_t i = 0; i < inputs.size(); ++i)
46 {
47 inputs[i]->addUse(Use(this, i));
48 _inputs.push_back(inputs[i]);
49 }
50 for (std::size_t i = 0; i < num_outputs; ++i)
51 {
52 _outputs.emplace_back(this, i);
53 }
54}

Member Function Documentation

◆ accept()

void Operation::accept ( IVisitor v)

Definition at line 56 of file Operation.cpp.

57{
58 switch (getType())
59 {
60#define HANDLE_OP(OpType, OpClass) \
61 case Type::OpType: \
62 v->visit(dynamic_cast<ops::OpClass &>(*this)); \
63 break;
64#include "mir/Operations.inc"
65#undef HANDLE_OP
66 default:
67 assert(false && "OP not defined!");
68 }
69}
Type getType() const
Definition Operation.h:123

References getType().

Referenced by mir::Graph::accept(), mir_onnx::foldConstants(), and nnc::Serializer::serialize().

◆ copyWithInputs()

◆ getId()

◆ getInput() [1/2]

◆ getInput() [2/2]

const Output * mir::Operation::getInput ( std::size_t  index) const
inline

Definition at line 143 of file Operation.h.

144 {
145 assert(index < _inputs.size());
146 return _inputs[index];
147 }

◆ getInputs() [1/2]

std::deque< Output * > & mir::Operation::getInputs ( )
inline

Definition at line 131 of file Operation.h.

131{ return _inputs; }

Referenced by mir_onnx::foldConstants(), nnc::opt_util::swapAdjacent(), and nnc::AclCppOpGenerator::visit().

◆ getInputs() [2/2]

const std::deque< Output * > & mir::Operation::getInputs ( ) const
inline

Definition at line 132 of file Operation.h.

132{ return _inputs; }

◆ getInputShape()

◆ getNumInputs()

◆ getNumOutputs()

std::size_t mir::Operation::getNumOutputs ( ) const
inline

Definition at line 129 of file Operation.h.

129{ return _outputs.size(); }

Referenced by mir::DotNodeBuilder::DotNodeBuilder(), mir_onnx::foldConstants(), and nnc::opt_util::swapAdjacent().

◆ getOutput() [1/2]

Output * mir::Operation::getOutput ( std::size_t  index)
inline

◆ getOutput() [2/2]

const Output * mir::Operation::getOutput ( std::size_t  index) const
inline

Definition at line 155 of file Operation.h.

156 {
157 assert(index < _outputs.size());
158 return &_outputs[index];
159 }

◆ getOutputs() [1/2]

std::deque< Output > & mir::Operation::getOutputs ( )
inline

Definition at line 134 of file Operation.h.

134{ return _outputs; }

Referenced by nnc::ModelAnalyzer::analyze(), mir::getSortedNodes(), mir::Graph::removeNode(), and nnc::opt_util::swapAdjacent().

◆ getOutputs() [2/2]

const std::deque< Output > & mir::Operation::getOutputs ( ) const
inline

Definition at line 135 of file Operation.h.

135{ return _outputs; }

◆ getOutputShape()

const Shape & mir::Operation::getOutputShape ( std::size_t  index) const
inline

Definition at line 163 of file Operation.h.

163{ return getOutput(index)->getShape(); }
Output * getOutput(std::size_t index)
Definition Operation.h:149

References getOutput(), and mir::Operation::Output::getShape().

Referenced by mir::ops::BroadcastOp::copyWithInputs(), mir::ops::DeConv2DOp::copyWithInputs(), mir::ops::ReshapeOp::copyWithInputs(), mir::ops::ResizeOp::copyWithInputs(), mir::DotNodeBuilder::DotNodeBuilder(), mir_interpreter::AvgPool2DImpl< uint8_t >::run(), mir_interpreter::AvgPool2DImpl< T >::run(), mir_interpreter::DepthwiseConv2DImpl< T >::run(), mir_interpreter::DepthwiseConv2DImpl< uint8_t >::run(), mir_interpreter::MaxPool2DImpl< uint8_t >::run(), mir_interpreter::TransposeImpl< T >::run(), mir_interpreter::MaxPool2DImpl< T >::run(), mir_interpreter::ReduceMeanImpl< T >::run(), mir_interpreter::FullyConnectedImpl< uint8_t >::run(), nnc::ConstantFoldTranspose::run(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), nnc::Serializer::visit(), nnc::Serializer::visit(), mir_interpreter::MIRInterpreter::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), mir2loco::Transformer::visit(), nnc::ModelAnalyzer::visit(), nnc::Serializer::visit(), nnc::ModelAnalyzer::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), mir2loco::Transformer::visit(), nnc::Serializer::visit(), nnc::ModelAnalyzer::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), nnc::Serializer::visit(), and nnc::Serializer::visit().

◆ getType()

Type mir::Operation::getType ( ) const
inline

Definition at line 123 of file Operation.h.

123{ return _type; }

Referenced by accept(), mir::DotNodeBuilder::DotNodeBuilder(), mir_onnx::foldConstants(), and mir::Graph::removeNode().

◆ setId()

void mir::Operation::setId ( std::size_t  id)
inline

Definition at line 126 of file Operation.h.

126{ _id = id; }

Referenced by mir::Graph::copyOpWithInputs().

◆ setOutputType()

void mir::Operation::setOutputType ( std::size_t  index,
const TensorType type 
)
inlineprotected

Definition at line 172 of file Operation.h.

172{ getOutput(index)->setType(type); }
void setType(const TensorType &type)
Sets the type of this output.
Definition Operation.h:95

References getOutput(), and mir::Operation::Output::setType().

Referenced by mir::ops::EqualOp::EqualOp(), mir::ops::GreaterOp::GreaterOp(), mir::ops::SqueezeOp::inferOutputTypes(), and mir::ops::LessOp::LessOp().


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