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

#include <Dump.h>

Collaboration diagram for tflinspect::DumpConv2DWeight:

Public Member Functions

 DumpConv2DWeight ()=default
 
void run (std::ostream &os, const tflite::Model *model)
 
- Public Member Functions inherited from tflinspect::DumpInterface
virtual ~DumpInterface ()=default
 

Detailed Description

Definition at line 45 of file Dump.h.

Constructor & Destructor Documentation

◆ DumpConv2DWeight()

tflinspect::DumpConv2DWeight::DumpConv2DWeight ( )
default

Member Function Documentation

◆ run()

void tflinspect::DumpConv2DWeight::run ( std::ostream &  os,
const tflite::Model *  model 
)
virtual

Implements tflinspect::DumpInterface.

Definition at line 96 of file Dump.cpp.

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

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

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


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