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

Function GenerateFileContent

tensorflow/lite/tools/gen_op_registration_main.cc:51–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49namespace {
50
51void GenerateFileContent(const std::string& tflite_path,
52 const std::string& filename,
53 const std::vector<string>& builtin_ops,
54 const std::vector<string>& custom_ops) {
55 std::ofstream fout(filename);
56
57 fout << "#include \"" << tflite_path << "/model.h\"\n";
58 fout << "#include \"" << tflite_path << "/op_resolver.h\"\n";
59
60 fout << "namespace tflite {\n";
61 fout << "namespace ops {\n";
62 if (!builtin_ops.empty()) {
63 fout << "namespace builtin {\n";
64 fout << "// Forward-declarations for the builtin ops.\n";
65 for (const auto& op : builtin_ops) {
66 fout << "TfLiteRegistration* Register_" << op << "();\n";
67 }
68 fout << "} // namespace builtin\n";
69 }
70
71 if (!custom_ops.empty()) {
72 fout << "namespace custom {\n";
73 fout << "// Forward-declarations for the custom ops.\n";
74 for (const auto& op : custom_ops) {
75 fout << "TfLiteRegistration* Register_"
76 << ::tflite::NormalizeCustomOpName(op) << "();\n";
77 }
78 fout << "} // namespace custom\n";
79 }
80 fout << "} // namespace ops\n";
81 fout << "} // namespace tflite\n";
82
83 fout << "void RegisterSelectedOps(::tflite::MutableOpResolver* resolver) {\n";
84 for (const auto& op : builtin_ops) {
85 fout << " resolver->AddBuiltin(::tflite::BuiltinOperator_" << op
86 << ", ::tflite::ops::builtin::Register_" << op << "());\n";
87 }
88 for (const auto& op : custom_ops) {
89 fout << " resolver->AddCustom(\"" << op
90 << "\", ::tflite::ops::custom::Register_"
91 << ::tflite::NormalizeCustomOpName(op) << "());\n";
92 }
93 fout << "}\n";
94 fout.close();
95}
96} // namespace
97
98int main(int argc, char** argv) {

Callers 1

mainFunction · 0.85

Calls 3

NormalizeCustomOpNameFunction · 0.85
closeMethod · 0.65
emptyMethod · 0.45

Tested by

no test coverage detected