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

Represents an output of a node. More...

#include <Operation.h>

Public Member Functions

 Output (Operation *node, std::size_t index)
 
 ~Output ()=default
 
 Output (const Output &)=delete
 
 Output (Output &&)=delete
 
Outputoperator= (const Output &)=delete
 
Outputoperator= (Output &&)=delete
 
OperationgetNode ()
 Returns the node this is an output of.
 
const OperationgetNode () const
 
std::size_t getIndex () const
 Returns the index of this output among all the outputs of the node.
 
const std::vector< Use > & getUses () const
 Returns the inputs that consume this output.
 
void addUse (Use use)
 Adds the specified use to the uses of this output.
 
void removeUse (Use use)
 Removes the specified use from the uses of this output.
 
void replaceAllUsesWith (Output *new_def)
 Replace the defs of all uses of this output with the specified def.
 
const TensorTypegetType () const
 Gets the type of this output.
 
void setType (const TensorType &type)
 Sets the type of this output.
 
DataType getElementType () const
 
const ShapegetShape () const
 
void setShape (const Shape &shape)
 
const std::string & getName () const
 
void setName (const std::string &name)
 
void setQuantization (const mir::AffineQuantization &quant)
 Set AffineQuantization to Ouput.
 

Detailed Description

Represents an output of a node.

Definition at line 59 of file Operation.h.

Constructor & Destructor Documentation

◆ Output() [1/3]

mir::Operation::Output::Output ( Operation node,
std::size_t  index 
)
inline

Definition at line 62 of file Operation.h.

62: _node(node), _index(index) {}

◆ ~Output()

mir::Operation::Output::~Output ( )
default

◆ Output() [2/3]

mir::Operation::Output::Output ( const Output )
delete

◆ Output() [3/3]

mir::Operation::Output::Output ( Output &&  )
delete

Member Function Documentation

◆ addUse()

void mir::Operation::Output::addUse ( Use  use)
inline

Adds the specified use to the uses of this output.

Definition at line 82 of file Operation.h.

82{ _uses.push_back(use); }

Referenced by replaceAllUsesWith().

◆ getElementType()

DataType mir::Operation::Output::getElementType ( ) const
inline

Definition at line 98 of file Operation.h.

98{ return getType().getElementType(); }
NNFW_TYPE getType(const char *type="")

References getType().

Referenced by mir::ops::SqueezeOp::inferOutputTypes(), setQuantization(), mir2loco::Transformer::visit(), and mir2loco::Transformer::visit().

◆ getIndex()

std::size_t mir::Operation::Output::getIndex ( ) const
inline

Returns the index of this output among all the outputs of the node.

Definition at line 76 of file Operation.h.

76{ return _index; }

◆ getName()

const std::string & mir::Operation::Output::getName ( ) const
inline

Definition at line 104 of file Operation.h.

104{ return _name; }

Referenced by mir2loco::Transformer::visit(), and mir2loco::Transformer::visit().

◆ getNode() [1/2]

Operation * mir::Operation::Output::getNode ( )
inline

Returns the node this is an output of.

Definition at line 72 of file Operation.h.

72{ return _node; }

Referenced by mir_onnx::foldConstants(), and nnc::CombineTransposes::run().

◆ getNode() [2/2]

const Operation * mir::Operation::Output::getNode ( ) const
inline

Definition at line 73 of file Operation.h.

73{ return _node; }

◆ getShape()

const Shape & mir::Operation::Output::getShape ( ) const
inline

◆ getType()

const TensorType & mir::Operation::Output::getType ( ) const
inline

◆ getUses()

const std::vector< Use > & mir::Operation::Output::getUses ( ) const
inline

Returns the inputs that consume this output.

Definition at line 79 of file Operation.h.

79{ return _uses; }

Referenced by nnc::opt_util::removeNodeIfUnused().

◆ operator=() [1/2]

Output & mir::Operation::Output::operator= ( const Output )
delete

◆ operator=() [2/2]

Output & mir::Operation::Output::operator= ( Output &&  )
delete

◆ removeUse()

void mir::Operation::Output::removeUse ( Use  use)

Removes the specified use from the uses of this output.

Definition at line 26 of file Operation.cpp.

27{
28 auto it = std::remove(_uses.begin(), _uses.end(), use);
29 _uses.erase(it);
30}

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

◆ replaceAllUsesWith()

void mir::Operation::Output::replaceAllUsesWith ( Output new_def)

Replace the defs of all uses of this output with the specified def.

Definition at line 32 of file Operation.cpp.

33{
34 for (auto use : _uses)
35 {
36 use.getNode()->_inputs[use.getIndex()] = new_def;
37 new_def->addUse(use);
38 }
39 _uses.clear();
40}

References addUse().

◆ setName()

void mir::Operation::Output::setName ( const std::string &  name)
inline

Definition at line 105 of file Operation.h.

105{ _name = name; }

◆ setQuantization()

void mir::Operation::Output::setQuantization ( const mir::AffineQuantization quant)
inline

Set AffineQuantization to Ouput.

Definition at line 108 of file Operation.h.

109 {
110 setType(TensorType(getElementType(), getShape(), quant));
111 }
DataType getElementType() const
Definition Operation.h:98
void setType(const TensorType &type)
Sets the type of this output.
Definition Operation.h:95
const Shape & getShape() const
Definition Operation.h:99

References getElementType(), getShape(), and setType().

◆ setShape()

void mir::Operation::Output::setShape ( const Shape shape)
inline

Definition at line 102 of file Operation.h.

102{ setType(TensorType(_type.getElementType(), shape)); }
DataType getElementType() const
Definition TensorType.h:41

References mir::TensorType::getElementType(), and setType().

◆ setType()

void mir::Operation::Output::setType ( const TensorType type)
inline

Sets the type of this output.

Warning
Use with caution, because it can make the IR inconsistent.

Definition at line 95 of file Operation.h.

95{ _type = type; }
type
Definition infer.py:18

Referenced by mir::Operation::setOutputType(), setQuantization(), and setShape().


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