99{
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
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 {
119 {
120 throw std::runtime_error("Operator has invalid input");
121 }
122 auto weight_input =
inputs[1];
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.
std::vector< T > as_index_vector(const flatbuffers::Vector< T > *flat_array)