| 913 | } |
| 914 | |
| 915 | uint32_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 | |
| 935 | Optional<BufferOffset<tflite::Operator>> Translator::BuildOperator( |
| 936 | Operation* inst, const std::vector<int32_t>& operands, |
nothing calls this directly
no test coverage detected