MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetOrInsertOpCodeIndex

Function GetOrInsertOpCodeIndex

tensorflow/lite/tools/optimize/model_utils.cc:34–49  ·  view source on GitHub ↗

Returns the index of the OpCode. If a OpCode doesn't exist, adds it and returns its index.

Source from the content-addressed store, hash-verified

32// Returns the index of the OpCode.
33// If a OpCode doesn't exist, adds it and returns its index.
34int32_t GetOrInsertOpCodeIndex(ModelT* model, const BuiltinOperator& op_code,
35 int32_t version) {
36 for (size_t i = 0; i < model->operator_codes.size(); ++i) {
37 if (model->operator_codes[i]->builtin_code == op_code) {
38 return i;
39 }
40 }
41 model->operator_codes.push_back(absl::make_unique<OperatorCodeT>());
42 int op_code_idx = model->operator_codes.size() - 1;
43 model->operator_codes[op_code_idx]->builtin_code = op_code;
44 // Version 2 and onwards supports INT8 inputs.
45 model->operator_codes[op_code_idx]->version = version;
46
47 // Return the index of the newly placed OperatorCodeT.
48 return op_code_idx;
49}
50
51} // namespace
52

Callers 2

MakeDequantizeOperatorFunction · 0.85
MakeQuantizeOperatorFunction · 0.85

Calls 2

sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected