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

Function LoadGraph

tensorflow/examples/speech_commands/label_wav.cc:39–54  ·  view source on GitHub ↗

Reads a model graph definition from disk, and creates a session object you can use to run it.

Source from the content-addressed store, hash-verified

37// Reads a model graph definition from disk, and creates a session object you
38// can use to run it.
39Status LoadGraph(const string& graph_file_name,
40 std::unique_ptr<tensorflow::Session>* session) {
41 tensorflow::GraphDef graph_def;
42 Status load_graph_status =
43 ReadBinaryProto(tensorflow::Env::Default(), graph_file_name, &graph_def);
44 if (!load_graph_status.ok()) {
45 return tensorflow::errors::NotFound("Failed to load compute graph at '",
46 graph_file_name, "'");
47 }
48 session->reset(tensorflow::NewSession(tensorflow::SessionOptions()));
49 Status session_create_status = (*session)->Create(graph_def);
50 if (!session_create_status.ok()) {
51 return session_create_status;
52 }
53 return Status::OK();
54}
55
56// Takes a file name, and loads a list of labels from it, one per line, and
57// returns a vector of the strings.

Callers 1

mainFunction · 0.70

Calls 8

ReadBinaryProtoFunction · 0.85
DefaultFunction · 0.85
NotFoundFunction · 0.85
NewSessionFunction · 0.50
SessionOptionsStruct · 0.50
okMethod · 0.45
resetMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected