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

Function TEST_F

tensorflow/core/debug/grpc_session_debug_test.cc:151–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149};
150
151TEST_F(GrpcSessionDebugTest, FileDebugURL) {
152 GraphDef graph;
153 string node_names[3];
154 CreateGraphDef(&graph, node_names);
155
156 std::unique_ptr<test::TestCluster> cluster;
157 TF_CHECK_OK(test::TestCluster::MakeTestCluster(Devices(1, 0), 2, &cluster));
158
159 auto session = NewRemote(Options(cluster->targets()[0], 1));
160 TF_CHECK_OK(session->Create(graph));
161
162 // Iteration 0: No watch.
163 // Iterations 1 and 2: Watch one Tensor.
164 // Iterations 3 and 4: Watch two Tensors.
165 // Iteration 5: No watch.
166 for (size_t i = 0; i < 6; ++i) {
167 RunOptions options;
168 if (i >= 1 && i < 5) {
169 DebugOptions* debug_options = options.mutable_debug_options();
170 DebugTensorWatch* watch = debug_options->add_debug_tensor_watch_opts();
171 watch->set_node_name(node_names[0]);
172 watch->set_output_slot(0);
173 watch->add_debug_ops("DebugIdentity");
174 watch->add_debug_urls(GetDebugURL());
175
176 if (i >= 3) {
177 watch = debug_options->add_debug_tensor_watch_opts();
178 watch->set_node_name(node_names[1]);
179 watch->set_output_slot(0);
180 watch->add_debug_ops("DebugIdentity");
181 watch->add_debug_urls(GetDebugURL());
182 }
183 }
184
185 RunMetadata metadata;
186 std::vector<Tensor> outputs;
187 TF_CHECK_OK(
188 session->Run(options, {}, {node_names[2]}, {}, &outputs, &metadata));
189 ASSERT_EQ(1, outputs.size());
190 IsSingleFloatValue(outputs[0], 4.0);
191
192 std::vector<Tensor> dumped_tensors;
193 LoadTensorDumps(io::JoinPath(DebugNodeKey::DeviceNameToDevicePath(
194 cluster->devices()[0].name()),
195 "n"),
196 &dumped_tensors);
197
198 if (i == 0 || i == 5) {
199 ASSERT_EQ(0, dumped_tensors.size());
200 } else {
201 if (i == 1 || i == 2) {
202 ASSERT_EQ(1, dumped_tensors.size());
203 ASSERT_EQ(TensorShape({1, 2}), dumped_tensors[0].shape());
204 ASSERT_EQ(1.0, dumped_tensors[0].flat<float>()(0));
205 ASSERT_EQ(2.0, dumped_tensors[0].flat<float>()(1));
206 } else {
207 ASSERT_EQ(2, dumped_tensors.size());
208 }

Callers

nothing calls this directly

Calls 15

targetsMethod · 0.80
CreateGraphDefFunction · 0.70
DevicesFunction · 0.70
NewRemoteFunction · 0.70
OptionsFunction · 0.70
IsSingleFloatValueFunction · 0.70
SetDeviceFunction · 0.70
nameMethod · 0.65
JoinPathFunction · 0.50
TensorShapeClass · 0.50
ConstantFunction · 0.50
IdentityFunction · 0.50

Tested by

no test coverage detected