ONE - On-device Neural Engine
Loading...
Searching...
No Matches
circleinspect::DumpConv2DWeight Class Referencefinal

#include <Dump.h>

Collaboration diagram for circleinspect::DumpConv2DWeight:

Public Member Functions

 DumpConv2DWeight ()=default
 
void run (std::ostream &os, const circle::Model *model, const std::vector< char > *data)
 
- Public Member Functions inherited from circleinspect::DumpInterface
virtual ~DumpInterface ()=default
 

Detailed Description

Definition at line 45 of file Dump.h.

Constructor & Destructor Documentation

◆ DumpConv2DWeight()

circleinspect::DumpConv2DWeight::DumpConv2DWeight ( )
default

Member Function Documentation

◆ run()

void circleinspect::DumpConv2DWeight::run ( std::ostream &  os,
const circle::Model *  model,
const std::vector< char > *  data 
)
virtual

Implements circleinspect::DumpInterface.

Definition at line 97 of file Dump.cpp.

99{
100 mio::circle::Reader reader(model, data);
101
102 const uint32_t subgraph_size = reader.num_subgraph();
103
104 for (uint32_t g = 0; g < subgraph_size; g++)
105 {
106 reader.select_subgraph(g);
107 auto ops = reader.operators();
108
109 // dump Conv2D, DepthwiseConv2D and its weight input operator
110 for (uint32_t i = 0; i < ops->size(); ++i)
111 {
112 const auto op = ops->Get(i);
113 auto bc = reader.builtin_code(op);
114
115 if (bc == circle::BuiltinOperator_CONV_2D || bc == circle::BuiltinOperator_DEPTHWISE_CONV_2D)
116 {
117 const std::vector<int32_t> &inputs = mio::circle::as_index_vector(op->inputs());
118 if (inputs.size() < 2)
119 {
120 throw std::runtime_error("Operator has invalid input");
121 }
122 auto weight_input = inputs[1]; // Tensor ID of weight input
123
124 const auto op_weight = operator_match_output(reader, weight_input);
125 const auto buffer_size = tensor_buffer_size(reader, weight_input);
126
127 std::string weight_op_name = "?";
128
129 if (op_weight == nullptr && buffer_size > 0)
130 {
131 weight_op_name = "CONST";
132 }
133 else if (op_weight != nullptr)
134 {
135 weight_op_name = reader.opcode_name(op_weight);
136 }
137
138 auto op_name = reader.opcode_name(op);
139 os << op_name << "," << weight_op_name << std::endl;
140 }
141 }
142 }
143}
Loads Circle file and provides helpers to access attributes.
Definition Reader.h:39
std::vector< T > as_index_vector(const flatbuffers::Vector< T > *flat_array)
Definition Helper.h:36

References mio::circle::as_index_vector(), mio::circle::Reader::builtin_code(), mio::circle::Reader::num_subgraph(), mio::circle::Reader::opcode_name(), mio::circle::Reader::operators(), and mio::circle::Reader::select_subgraph().

Referenced by package.infer.session::inference().


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