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

Method GetOpcodeIndex

tensorflow/compiler/mlir/lite/flatbuffer_translate.cc:915–933  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

913}
914
915uint32_t Translator::GetOpcodeIndex(const std::string& op_name,
916 tflite::BuiltinOperator builtin) {
917 auto it = opcode_index_map_.insert({op_name, 0});
918
919 // If the insert succeeded, the opcode has not been created already. Create a
920 // new operator code and update its index value in the map.
921 if (it.second) {
922 it.first->second = opcodes_.size();
923 auto custom_code = builtin == tflite::BuiltinOperator_CUSTOM
924 ? builder_.CreateString(op_name)
925 : BufferOffset<flatbuffers::String>();
926 // Use version 0 for builtin op. This is a way to serialize version field to
927 // flatbuffer (since 0 is non default) and it will be corrected later.
928 int32_t op_version = builtin != tflite::BuiltinOperator_CUSTOM ? 0 : 1;
929 opcodes_.push_back(CreateOperatorCode(builder_, /*builtin_code=*/builtin,
930 custom_code, op_version));
931 }
932 return it.first->second;
933}
934
935Optional<BufferOffset<tflite::Operator>> Translator::BuildOperator(
936 Operation* inst, const std::vector<int32_t>& operands,

Callers

nothing calls this directly

Calls 4

CreateOperatorCodeFunction · 0.85
insertMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected