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

Method TestInitValueConstructor

tensorflow/compiler/xla/shape_tree_test.cc:87–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87void ShapeTreeTest::TestInitValueConstructor(const Shape& shape,
88 int expected_num_nodes) {
89 ShapeTree<int> tree(shape, 42);
90 int num_nodes = 0;
91 tree.ForEachElement([&num_nodes](const ShapeIndex& /*index*/, int data) {
92 EXPECT_EQ(42, data);
93 ++num_nodes;
94 });
95 EXPECT_EQ(expected_num_nodes, num_nodes);
96
97 num_nodes = 0;
98 tree.ForEachMutableElement(
99 [&num_nodes](const ShapeIndex& /*index*/, int* data) {
100 EXPECT_EQ(42, *data);
101 *data = num_nodes;
102 ++num_nodes;
103 });
104 EXPECT_EQ(expected_num_nodes, num_nodes);
105
106 num_nodes = 0;
107 tree.ForEachElement([&num_nodes](const ShapeIndex& /*index*/, int data) {
108 EXPECT_EQ(num_nodes, data);
109 ++num_nodes;
110 });
111 EXPECT_EQ(expected_num_nodes, num_nodes);
112}
113
114TEST_F(ShapeTreeTest, InitValueConstructor) {
115 TestInitValueConstructor(array_shape_, 1);

Callers

nothing calls this directly

Calls 2

ForEachElementMethod · 0.45
ForEachMutableElementMethod · 0.45

Tested by

no test coverage detected