17#ifndef _MIR_OPERATION_H_
18#define _MIR_OPERATION_H_
37#define HANDLE_OP(OpType, OpClass) OpType,
45 Use(
Operation *node, std::size_t index) : _node(node), _index(index) {}
49 std::size_t
getIndex()
const {
return _index; }
51 bool operator==(
const Use &other) {
return _node == other._node && _index == other._index; }
76 std::size_t
getIndex()
const {
return _index; }
79 const std::vector<Use> &
getUses()
const {
return _uses; }
85 void removeUse(
Use use);
88 void replaceAllUsesWith(
Output *new_def);
104 const std::string &
getName()
const {
return _name; }
105 void setName(
const std::string &name) { _name = name; }
116 std::vector<Use> _uses;
125 std::size_t
getId()
const {
return _id; }
126 void setId(std::size_t
id) { _id = id; }
132 const std::deque<Output *> &
getInputs()
const {
return _inputs; }
135 const std::deque<Output> &
getOutputs()
const {
return _outputs; }
139 assert(index < _inputs.size());
140 return _inputs[index];
145 assert(index < _inputs.size());
146 return _inputs[index];
151 assert(index < _outputs.size());
152 return &_outputs[index];
157 assert(index < _outputs.size());
158 return &_outputs[index];
170 Operation(
Type type,
const std::vector<Output *> &inputs, std::size_t num_outputs = 1);
176 std::size_t _id = std::numeric_limits<std::size_t>::max();
177 std::deque<Output *> _inputs;
178 std::deque<Output> _outputs;
184const std::string &
getTypeName(Operation::Type type);
Interface for visitors Use in MIR component if you want to enforce to implement visits for all operat...
Represents an output of a node.
DataType getElementType() const
Output & operator=(Output &&)=delete
Output(const Output &)=delete
Output & operator=(const Output &)=delete
void setQuantization(const mir::AffineQuantization &quant)
Set AffineQuantization to Ouput.
const Operation * getNode() const
void addUse(Use use)
Adds the specified use to the uses of this output.
std::size_t getIndex() const
Returns the index of this output among all the outputs of the node.
Output(Operation *node, std::size_t index)
void setType(const TensorType &type)
Sets the type of this output.
const std::vector< Use > & getUses() const
Returns the inputs that consume this output.
void setName(const std::string &name)
const std::string & getName() const
const Shape & getShape() const
void setShape(const Shape &shape)
Operation * getNode()
Returns the node this is an output of.
const TensorType & getType() const
Gets the type of this output.
std::size_t getNumInputs() const
Output * getInput(std::size_t index)
std::deque< Output > & getOutputs()
const std::deque< Output > & getOutputs() const
virtual ~Operation()=default
const Output * getInput(std::size_t index) const
Output * getOutput(std::size_t index)
const Shape & getInputShape(std::size_t index) const
virtual Operation * copyWithInputs(const std::vector< Output * > &inputs)=0
std::deque< Output * > & getInputs()
const Shape & getOutputShape(std::size_t index) const
const Output * getOutput(std::size_t index) const
void setId(std::size_t id)
std::size_t getId() const
const std::deque< Output * > & getInputs() const
void setOutputType(std::size_t index, const TensorType &type)
std::size_t getNumOutputs() const
DataType getElementType() const
const std::string & getTypeName(Operation::Type type)
NNFW_TYPE getType(const char *type="")
Represents a use of an operation output.
bool operator==(const Use &other)
std::size_t getIndex() const
Operation * getNode() const
Use(Operation *node, std::size_t index)