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

Function EmitGetBuiltinOpCode

tensorflow/compiler/mlir/lite/converter_gen.cc:218–234  ·  view source on GitHub ↗

Emits a function that returns builtin operator code for each TFLite op. The signature of the function is: llvm::Optional mlir::GetBuiltinOpCode(mlir::Operation* op); TODO(hinsu): Consider converting this to a static constant associative container instead of a series of if conditions, if required.

Source from the content-addressed store, hash-verified

216// TODO(hinsu): Consider converting this to a static constant associative
217// container instead of a series of if conditions, if required.
218static void EmitGetBuiltinOpCode(const std::vector<Record *> &defs,
219 raw_ostream *ostream) {
220 raw_ostream &os = *ostream;
221
222 os << "llvm::Optional<tflite::BuiltinOperator> "
223 "mlir::GetBuiltinOpCode(mlir::Operation* op) {\n";
224
225 for (const auto *def : defs) {
226 StringRef op_name = def->getName().drop_front(4);
227 os << " if (isa<mlir::TFL::" << op_name << ">(op))\n"
228 << " return tflite::BuiltinOperator_" << GetOperatorName(*def)
229 << ";\n";
230 }
231
232 os << " return llvm::None;\n"
233 "}\n";
234}
235
236// Emits a builder function that returns the packed FlatBuffer object given
237// a general mlir::Operation.

Callers 1

OperatorWritersMainFunction · 0.70

Calls 2

GetOperatorNameFunction · 0.70
getNameMethod · 0.45

Tested by

no test coverage detected