| 285 | } |
| 286 | |
| 287 | StatusOr<std::string> OpNameForOpCode(const tflite::OperatorCodeT opcode) { |
| 288 | // TODO(b/143872630): Support custom ops |
| 289 | if (opcode.builtin_code == tflite::BuiltinOperator_CUSTOM) { |
| 290 | // Adding some custom op supported on GPU. |
| 291 | const absl::string_view custom_name = opcode.custom_code; |
| 292 | if (custom_name == "MaxPoolingWithArgmax2D") { |
| 293 | return std::string("tfl.max_pooling_with_argmax_2d"); |
| 294 | } |
| 295 | if (custom_name == "Convolution2DTransposeBias") { |
| 296 | return std::string("tfl.convolution_2d_transpose_bias"); |
| 297 | } |
| 298 | if (custom_name == "MaxUnpooling2D") { |
| 299 | return std::string("tfl.max_unpooling_2d"); |
| 300 | } |
| 301 | // Use an unsupported op name instead of throwing an error here in case the |
| 302 | // op is pruned during the import. |
| 303 | return std::string( |
| 304 | llvm::Twine("tfl.UNSUPPORTED_custom_", opcode.custom_code).str()); |
| 305 | } |
| 306 | if (opcode.builtin_code == tflite::BuiltinOperator_IF) { |
| 307 | return std::string("tf.If"); |
| 308 | } |
| 309 | if (opcode.builtin_code == tflite::BuiltinOperator_WHILE) { |
| 310 | return std::string("tf.While"); |
| 311 | } |
| 312 | |
| 313 | const char* op_name = tflite::EnumNameBuiltinOperator(opcode.builtin_code); |
| 314 | std::string lowered_name = llvm::StringRef(op_name).lower(); |
| 315 | return llvm::Twine("tfl.", lowered_name).str(); |
| 316 | } |
| 317 | |
| 318 | // The buffers in TFLite flatbuffers have their contents stored as a vector of |
| 319 | // bytes that represent little-endian values. |
no test coverage detected