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

Function TEST

tensorflow/core/util/stat_summarizer_test.cc:30–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28namespace {
29
30TEST(StatSummarizerTest, ExtractsOpTypes) {
31 // GraphDef for a single constant name 'myconstant'
32 const std::string graph_def_str(R"EOF(
33node {
34 name: "myconstant"
35 op: "Const"
36 attr {
37 key: "dtype"
38 value {
39 type: DT_FLOAT
40 }
41 }
42 attr {
43 key: "value"
44 value {
45 tensor {
46 dtype: DT_FLOAT
47 tensor_shape {
48 }
49 float_val: 1.0
50 }
51 }
52 }
53}
54versions {
55 producer: 21
56}
57 )EOF");
58 GraphDef graph_def;
59 ASSERT_TRUE(protobuf::TextFormat::ParseFromString(graph_def_str, &graph_def));
60
61 std::unique_ptr<Session> session(NewSession(SessionOptions()));
62 ASSERT_TRUE(session != nullptr);
63 TF_ASSERT_OK(session->Create(graph_def));
64
65 RunOptions run_options;
66 run_options.set_trace_level(RunOptions::FULL_TRACE);
67
68 RunMetadata run_metadata;
69 std::vector<Tensor> outputs;
70 TF_ASSERT_OK(session->Run(run_options, {}, {"myconstant:0"}, {}, &outputs,
71 &run_metadata));
72
73 StatSummarizer stats(graph_def);
74 stats.ProcessStepStats(run_metadata.step_stats());
75
76 const std::string output = stats.GetOutputString();
77 const std::string by_node_type = stats.GetStatsByNodeType();
78
79 // output should contain both the node type and node name.
80 ASSERT_TRUE(output.find("Const") != std::string::npos) << output;
81 ASSERT_TRUE(output.find("myconstant") != std::string::npos) << output;
82 // stats by node type should include the type.
83 ASSERT_TRUE(by_node_type.find("Const") != std::string::npos) << by_node_type;
84}
85
86} // namespace
87} // namespace tensorflow

Callers

nothing calls this directly

Calls 8

ProcessStepStatsMethod · 0.80
NewSessionFunction · 0.50
SessionOptionsClass · 0.50
CreateMethod · 0.45
RunMethod · 0.45
GetOutputStringMethod · 0.45
GetStatsByNodeTypeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected