message: fix the device_tracer_test where optimization remove the kernel launch.
diff: @@ -72,28 +72,25 @@ class DeviceTracerTest : public ::testing::Test {
  Tensor a_tensor(DT_FLOAT, TensorShape({2, 2}));
  test::FillValues<float>(&a_tensor, a_values);
  - Node* a = test::graph::Constant(&graph, a_tensor);
  - a->set_assigned_device_name("/job:localhost/replica:0/task:0/cpu:0");
  + Node* a = test::graph::HostConstant(&graph, a_tensor);
  Tensor x_tensor(DT_FLOAT, TensorShape({2, 1}));
  test::FillValues<float>(&x_tensor, {1, 1});
  - Node* x = test::graph::Constant(&graph, x_tensor);
  - x->set_assigned_device_name("/job:localhost/replica:0/task:0/device:GPU:0");
  + Node* x = test::graph::HostConstant(&graph, x_tensor);
  x_ = x->name();
  // y = A * x
  Node* y = test::graph::Matmul(&graph, a, x, false, false);
  - y->set_assigned_device_name("/job:localhost/replica:0/task:0/device:GPU:0");
  + y->set_assigned_device_name("/device:GPU:0");
  y_ = y->name();
  // Use an Identity op to force a memcpy to CPU and back to GPU.
  Node* i = test::graph::Identity(&graph, y);
  - i->set_assigned_device_name("/job:localhost/replica:0/task:0/cpu:0");
  + i->set_assigned_device_name("/cpu:0");
  Node* y_neg = test::graph::Unary(&graph, "Neg", i);
  y_neg_ = y_neg->name();
  - y_neg->set_assigned_device_name(
  - "/job:localhost/replica:0/task:0/device:GPU:0");
  + y_neg->set_assigned_device_name("/device:GPU:0");
  test::graph::ToGraphDef(&graph, &def_);
  }
  @@ -278,6 +275,9 @@ TEST_F(DeviceTracerTest, TraceToXSpace) {
  FindPlaneWithName(space, strings::StrCat(kGpuPlanePrefix, 0));
  ASSERT_NE(device_plane, nullptr); // Check if device plane is serialized.
  EXPECT_EQ(device_plane->id(), kGpuPlaneBaseId);
  + // one for MemcpyH2D, one for MemcpyD2H, two for Matmul (one from Eigen, one
  + // from cudnn).
  + EXPECT_EQ(device_plane->event_metadata_size(), 4);
  // Check if device capacity is serialized.
  XPlaneVisitor plane = CreateTfXPlaneVisitor(device_plane);
  EXPECT_NE(plane.GetStats(kDevCapClockRateKHz), nullptr);
  @@ -288,12 +288,15 @@ TEST_F(DeviceTracerTest, TraceToXSpace) {
  EXPECT_NE(plane.GetStats(kDevCapComputeCapMinor), nullptr);
  // Check if the device events timestamps are set.
  + int total_events = 0;
  plane.ForEachLine([&](const tensorflow::profiler::XLineVisitor& line) {
  line.ForEachEvent([&](const tensorflow::profiler::XEventVisitor& event) {
  EXPECT_GT(event.TimestampNs(), 0);
  EXPECT_GT(event.DurationNs(), 0);
  + ++total_events;
  });
  });
  + EXPECT_EQ(total_events, 5);
  }
  } // namespace
  