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

Function ImportGraphDef

tensorflow/compiler/mlir/python/mlir.cc:30–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28namespace tensorflow {
29
30std::string ImportGraphDef(const std::string &proto,
31 const std::string &pass_pipeline,
32 TF_Status *status) {
33 GraphDef graphdef;
34 auto s = tensorflow::LoadProtoFromBuffer(proto, &graphdef);
35 if (!s.ok()) {
36 Set_TF_Status_from_Status(status, s);
37 return "// error";
38 }
39 GraphDebugInfo debug_info;
40 GraphImportConfig specs;
41 mlir::MLIRContext context;
42 auto module = ConvertGraphdefToMlir(graphdef, debug_info, specs, &context);
43 if (!module.ok()) {
44 Set_TF_Status_from_Status(status, module.status());
45 return "// error";
46 }
47
48 // Run the pass_pipeline on the module if not empty.
49 if (!pass_pipeline.empty()) {
50 mlir::PassManager pm(&context);
51 std::string error;
52 llvm::raw_string_ostream error_stream(error);
53 if (failed(mlir::parsePassPipeline(pass_pipeline, pm, error_stream))) {
54 TF_SetStatus(status, TF_INVALID_ARGUMENT,
55 ("Invalid pass_pipeline: " + error_stream.str()).c_str());
56 return "// error";
57 }
58
59 mlir::StatusScopedDiagnosticHandler statusHandler(&context);
60 if (failed(pm.run(*module.ValueOrDie()))) {
61 Set_TF_Status_from_Status(status, statusHandler.ConsumeStatus());
62 return "// error";
63 }
64 }
65 return MlirModuleToString(*module.ConsumeValueOrDie());
66}
67
68std::string ExperimentalConvertSavedModelToMlir(
69 const std::string &saved_model_path, const std::string &exported_names_str,

Callers 4

FoldConstantsFunction · 0.50
InlineAllFunctionsFunction · 0.50
c_api.ccFile · 0.50
CopyGraphFunction · 0.50

Calls 12

LoadProtoFromBufferFunction · 0.85
ConvertGraphdefToMlirFunction · 0.85
TF_SetStatusFunction · 0.85
MlirModuleToStringFunction · 0.85
c_strMethod · 0.80
ConsumeStatusMethod · 0.80
ConsumeValueOrDieMethod · 0.80
okMethod · 0.45
statusMethod · 0.45
emptyMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected