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

#include <DotNodeBuilder.h>

Collaboration diagram for mir::DotNodeBuilder:

Public Member Functions

 DotNodeBuilder (const Operation &op)
 
void visit (ops::AvgPool2DOp &op) override
 
void visit (ops::CappedReluOp &op) override
 
void visit (ops::ConcatOp &op) override
 
void visit (ops::Conv2DOp &op) override
 
void visit (ops::DeConv2DOp &op) override
 
void visit (ops::DepthwiseConv2DOp &op) override
 
void visit (ops::EluOp &op) override
 
void visit (ops::GatherOp &op) override
 
void visit (ops::LeakyReluOp &op) override
 
void visit (ops::MaxPool2DOp &op) override
 
void visit (ops::PadOp &op) override
 
void visit (ops::ReduceMeanOp &op) override
 
void visit (ops::ResizeOp &op) override
 
void visit (ops::SliceOp &op) override
 
void visit (ops::SoftmaxOp &op) override
 
void visit (ops::SqueezeOp &op) override
 
void visit (ops::TransposeOp &op) override
 
void addAttribute (std::string name, std::string val)
 
DotNode getDotNode () const
 
- Public Member Functions inherited from mir::IVisitor
virtual ~IVisitor ()=default
 

Additional Inherited Members

- Protected Member Functions inherited from mir::Visitor
virtual void visit_fallback (Operation &)
 

Detailed Description

Definition at line 31 of file DotNodeBuilder.h.

Constructor & Destructor Documentation

◆ DotNodeBuilder()

mir::DotNodeBuilder::DotNodeBuilder ( const Operation op)
explicit

Definition at line 38 of file DotNodeBuilder.cpp.

39{
40 _type_name = getTypeName(op.getType());
41 _id = op.getId();
42
43 for (std::size_t i = 0; i < op.getNumInputs(); ++i)
44 {
45 _in_shapes.push_back(toString(op.getInputShape(i)));
46 }
47
48 for (std::size_t i = 0; i < op.getNumOutputs(); ++i)
49 {
50 _out_shapes.push_back(toString(op.getOutputShape(i)));
51 }
52
53 // Get attributes.
54 const_cast<Operation &>(op).accept(this);
55}
const std::string & getTypeName(Operation::Type type)
Definition Operation.cpp:71
std::string toString(DataFormat data_format)
Definition DataFormat.h:74

References mir::Operation::getId(), mir::Operation::getInputShape(), mir::Operation::getNumInputs(), mir::Operation::getNumOutputs(), mir::Operation::getOutputShape(), mir::Operation::getType(), mir::getTypeName(), and mir::toString().

Member Function Documentation

◆ addAttribute()

void mir::DotNodeBuilder::addAttribute ( std::string  name,
std::string  val 
)

Definition at line 164 of file DotNodeBuilder.cpp.

165{
166 this->_attributes.emplace_back(std::move(name), std::move(val));
167}

Referenced by visit(), visit(), visit(), visit(), visit(), visit(), visit(), visit(), visit(), visit(), visit(), visit(), visit(), visit(), visit(), and visit().

◆ getDotNode()

DotNode mir::DotNodeBuilder::getDotNode ( ) const
inline

Definition at line 56 of file DotNodeBuilder.h.

56{ return {_id, getLabel()}; }

Referenced by mir::dumpGraph().

◆ visit() [1/17]

void mir::DotNodeBuilder::visit ( ops::AvgPool2DOp op)
override

Definition at line 57 of file DotNodeBuilder.cpp.

58{
59 addAttribute("Window size", toString(op.getWindowSize()));
60 addAttribute("Strides", toString(op.getStrides()));
61 addAttribute("Padding before", toString(op.getPaddingBefore()));
62 addAttribute("Padding after", toString(op.getPaddingAfter()));
63 addAttribute("Include pad", std::to_string(op.getIncludePad()));
64}
void addAttribute(std::string name, std::string val)
const std::vector< std::int32_t > & getWindowSize() const
Definition AvgPool2DOp.h:45
const std::vector< std::int32_t > & getPaddingBefore() const
Definition AvgPool2DOp.h:49
const std::vector< std::int32_t > & getPaddingAfter() const
Definition AvgPool2DOp.h:51
bool getIncludePad() const
Definition AvgPool2DOp.h:53
const std::vector< std::int32_t > & getStrides() const
Definition AvgPool2DOp.h:47

References addAttribute(), mir::ops::AvgPool2DOp::getIncludePad(), mir::ops::AvgPool2DOp::getPaddingAfter(), mir::ops::AvgPool2DOp::getPaddingBefore(), mir::ops::AvgPool2DOp::getStrides(), mir::ops::AvgPool2DOp::getWindowSize(), and mir::toString().

◆ visit() [2/17]

void mir::DotNodeBuilder::visit ( ops::CappedReluOp op)
override

Definition at line 66 of file DotNodeBuilder.cpp.

67{
68 addAttribute("Cap", std::to_string(op.getCap()));
69}

References addAttribute(), and mir::ops::CappedReluOp::getCap().

◆ visit() [3/17]

void mir::DotNodeBuilder::visit ( ops::ConcatOp op)
override

Definition at line 71 of file DotNodeBuilder.cpp.

72{
73 addAttribute("Axis", std::to_string(op.getAxis()));
74}
int32_t getAxis() const
Definition ConcatOp.h:44

References addAttribute(), and mir::ops::ConcatOp::getAxis().

◆ visit() [4/17]

void mir::DotNodeBuilder::visit ( ops::Conv2DOp op)
override

Definition at line 76 of file DotNodeBuilder.cpp.

77{
78 addAttribute("Strides", toString(op.getStrides()));
79 addAttribute("Padding before", toString(op.getPaddingBefore()));
80 addAttribute("Padding after", toString(op.getPaddingAfter()));
81 addAttribute("Num groups", std::to_string(op.getNumGroups()));
82 addAttribute("Data format", toString(op.getDataFormat()));
83}
DataFormat getDataFormat() const
Definition Conv2DOp.h:60
std::int32_t getNumGroups() const
Definition Conv2DOp.h:58
const std::vector< std::int32_t > & getPaddingAfter() const
Definition Conv2DOp.h:56
const std::vector< std::int32_t > & getPaddingBefore() const
Definition Conv2DOp.h:54
const std::vector< std::int32_t > & getStrides() const
Definition Conv2DOp.h:52

References addAttribute(), mir::ops::Conv2DOp::getDataFormat(), mir::ops::Conv2DOp::getNumGroups(), mir::ops::Conv2DOp::getPaddingAfter(), mir::ops::Conv2DOp::getPaddingBefore(), mir::ops::Conv2DOp::getStrides(), and mir::toString().

◆ visit() [5/17]

void mir::DotNodeBuilder::visit ( ops::DeConv2DOp op)
override

Definition at line 113 of file DotNodeBuilder.cpp.

114{
115 addAttribute("Padding before", toString(op.getPaddingBefore()));
116 addAttribute("Padding after", toString(op.getPaddingAfter()));
117 addAttribute("Strides", toString(op.getStrides()));
118 addAttribute("Data format", toString(op.getDataFormat()));
119}
const std::vector< std::int32_t > & getPaddingBefore() const
Definition Deconv2DOp.h:62
const std::vector< std::int32_t > & getPaddingAfter() const
Definition Deconv2DOp.h:64
DataFormat getDataFormat() const
Definition Deconv2DOp.h:66
const std::vector< std::int32_t > & getStrides() const
Definition Deconv2DOp.h:58

References addAttribute(), mir::ops::DeConv2DOp::getDataFormat(), mir::ops::DeConv2DOp::getPaddingAfter(), mir::ops::DeConv2DOp::getPaddingBefore(), mir::ops::DeConv2DOp::getStrides(), and mir::toString().

◆ visit() [6/17]

void mir::DotNodeBuilder::visit ( ops::DepthwiseConv2DOp op)
override

Definition at line 85 of file DotNodeBuilder.cpp.

86{
87 addAttribute("Strides", toString(op.getStrides()));
88 addAttribute("Padding before", toString(op.getPaddingBefore()));
89 addAttribute("Padding after", toString(op.getPaddingAfter()));
90 addAttribute("Data format", toString(op.getDataFormat()));
91}
const std::vector< std::int32_t > & getStrides() const
const std::vector< std::int32_t > & getPaddingAfter() const
DataFormat getDataFormat() const
const std::vector< std::int32_t > & getPaddingBefore() const

References addAttribute(), mir::ops::DepthwiseConv2DOp::getDataFormat(), mir::ops::DepthwiseConv2DOp::getPaddingAfter(), mir::ops::DepthwiseConv2DOp::getPaddingBefore(), mir::ops::DepthwiseConv2DOp::getStrides(), and mir::toString().

◆ visit() [7/17]

void mir::DotNodeBuilder::visit ( ops::EluOp op)
override

Definition at line 121 of file DotNodeBuilder.cpp.

121{ addAttribute("Alpha", std::to_string(op.getAlpha())); }
float getAlpha() const
Definition EluOp.h:40

References addAttribute(), and mir::ops::EluOp::getAlpha().

◆ visit() [8/17]

void mir::DotNodeBuilder::visit ( ops::GatherOp op)
override

Definition at line 154 of file DotNodeBuilder.cpp.

155{
156 addAttribute("Axis", std::to_string(op.getAxis()));
157}
int32_t getAxis() const
Definition GatherOp.h:46

References addAttribute(), and mir::ops::GatherOp::getAxis().

◆ visit() [9/17]

void mir::DotNodeBuilder::visit ( ops::LeakyReluOp op)
override

Definition at line 159 of file DotNodeBuilder.cpp.

160{
161 addAttribute("Alpha", std::to_string(op.getAlpha()));
162}
float getAlpha() const
Definition LeakyReluOp.h:41

References addAttribute(), and mir::ops::LeakyReluOp::getAlpha().

◆ visit() [10/17]

void mir::DotNodeBuilder::visit ( ops::MaxPool2DOp op)
override

Definition at line 93 of file DotNodeBuilder.cpp.

94{
95 addAttribute("Window size", toString(op.getWindowSize()));
96 addAttribute("Strides", toString(op.getStrides()));
97 addAttribute("Padding before", toString(op.getPaddingBefore()));
98 addAttribute("Padding after", toString(op.getPaddingAfter()));
99 addAttribute("Data format", toString(op.getDataFormat()));
100}
const std::vector< std::int32_t > & getPaddingBefore() const
Definition MaxPool2DOp.h:49
const std::vector< std::int32_t > & getPaddingAfter() const
Definition MaxPool2DOp.h:51
DataFormat getDataFormat() const
Definition MaxPool2DOp.h:53
const std::vector< std::int32_t > & getWindowSize() const
Definition MaxPool2DOp.h:45
const std::vector< std::int32_t > & getStrides() const
Definition MaxPool2DOp.h:47

References addAttribute(), mir::ops::MaxPool2DOp::getDataFormat(), mir::ops::MaxPool2DOp::getPaddingAfter(), mir::ops::MaxPool2DOp::getPaddingBefore(), mir::ops::MaxPool2DOp::getStrides(), mir::ops::MaxPool2DOp::getWindowSize(), and mir::toString().

◆ visit() [11/17]

void mir::DotNodeBuilder::visit ( ops::PadOp op)
override

Definition at line 128 of file DotNodeBuilder.cpp.

129{
130 addAttribute("Padding before", toString(op.getPaddingBefore()));
131 addAttribute("Padding after", toString(op.getPaddingAfter()));
132 addAttribute("Padding value", std::to_string(op.getPaddingValue()));
133}
float getPaddingValue() const
Definition PadOp.h:47
const std::vector< std::int32_t > & getPaddingBefore() const
Definition PadOp.h:43
const std::vector< std::int32_t > & getPaddingAfter() const
Definition PadOp.h:45

References mir::ops::PadOp::getPaddingAfter(), mir::ops::PadOp::getPaddingBefore(), mir::ops::PadOp::getPaddingValue(), and mir::toString().

◆ visit() [12/17]

void mir::DotNodeBuilder::visit ( ops::ReduceMeanOp op)
override

Definition at line 135 of file DotNodeBuilder.cpp.

136{
137 addAttribute("Reduction dims", toString(op.getReductionDims()));
138 addAttribute("Keep dims", std::to_string(op.getKeepDims()));
139}
const std::vector< int > & getReductionDims() const
Definition ReduceOp.h:38
bool getKeepDims() const
Definition ReduceOp.h:40

References addAttribute(), mir::ops::ReduceOp::getKeepDims(), mir::ops::ReduceOp::getReductionDims(), and mir::toString().

◆ visit() [13/17]

void mir::DotNodeBuilder::visit ( ops::ResizeOp op)
override

Definition at line 141 of file DotNodeBuilder.cpp.

142{
144 (void)op;
145
146 addAttribute("Interpolation mode", "nearestNeighbor");
147}
ResizeMethod getMode() const
Definition ResizeOp.h:75

References addAttribute(), mir::ops::ResizeOp::getMode(), and mir::ops::ResizeOp::nearestNeighbor.

◆ visit() [14/17]

void mir::DotNodeBuilder::visit ( ops::SliceOp op)
override

Definition at line 107 of file DotNodeBuilder.cpp.

108{
109 addAttribute("Starts", toString(op.getStarts()));
110 addAttribute("Sizes", toString(op.getSizes()));
111}
const Shape & getStarts()
Definition SliceOp.h:41
const Shape & getSizes()
Definition SliceOp.h:43

References addAttribute(), mir::ops::SliceOp::getSizes(), mir::ops::SliceOp::getStarts(), and mir::toString().

◆ visit() [15/17]

void mir::DotNodeBuilder::visit ( ops::SoftmaxOp op)
override

Definition at line 102 of file DotNodeBuilder.cpp.

103{
104 addAttribute("Axis", std::to_string(op.getAxis()));
105}
int32_t getAxis() const
Definition SoftmaxOp.h:43

References addAttribute(), and mir::ops::SoftmaxOp::getAxis().

◆ visit() [16/17]

void mir::DotNodeBuilder::visit ( ops::SqueezeOp op)
override

Definition at line 123 of file DotNodeBuilder.cpp.

124{
125 addAttribute("Dims to squeeze", toString(op.getDimsToSqueeze()));
126}
const std::vector< int32_t > & getDimsToSqueeze() const
Definition SqueezeOp.h:47

References addAttribute(), mir::ops::SqueezeOp::getDimsToSqueeze(), and mir::toString().

◆ visit() [17/17]

void mir::DotNodeBuilder::visit ( ops::TransposeOp op)
override

Definition at line 149 of file DotNodeBuilder.cpp.

150{
151 addAttribute("Axis order", toString(op.getAxisOrder()));
152}
const std::vector< std::size_t > & getAxisOrder() const
Definition TransposeOp.h:38

References addAttribute(), mir::ops::TransposeOp::getAxisOrder(), and mir::toString().


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