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

Function TEST

tensorflow/core/kernels/eigen_pooling_test.cc:27–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25} // namespace
26
27TEST(EigenPoolingTest, Simple) {
28 const int depth = 10;
29 const int input_rows = 5;
30 const int input_cols = 5;
31 const int num_batches = 13;
32 const int patch_rows = 4;
33 const int patch_cols = 4;
34 const int output_rows = 2;
35 const int output_cols = 2;
36
37 Tensor<float, 4> input(depth, input_rows, input_cols, num_batches);
38 Tensor<float, 4> result(depth, output_rows, output_cols, num_batches);
39 input = input.constant(11.0f) + input.random();
40 result.setRandom();
41 result = result.constant(-1000.f);
42
43 // Max pooling using a 4x4 window and a stride of 1.
44 const int stride = 1;
45 result = SpatialMaxPooling(input, patch_rows, patch_cols, stride, stride,
46 PADDING_VALID);
47
48 EXPECT_EQ(result.dimension(0), depth);
49 EXPECT_EQ(result.dimension(1), output_rows);
50 EXPECT_EQ(result.dimension(2), output_cols);
51 EXPECT_EQ(result.dimension(3), num_batches);
52
53 for (int b = 0; b < num_batches; ++b) {
54 for (int d = 0; d < depth; ++d) {
55 for (int i = 0; i < output_rows; ++i) {
56 for (int j = 0; j < output_cols; ++j) {
57 float expected = -10000.f;
58 for (int r = 0; r < patch_rows; ++r) {
59 for (int c = 0; c < patch_cols; ++c) {
60 expected = (std::max)(expected, input(d, r + i, c + j, b));
61 }
62 }
63 if (result(d, i, j, b) != expected) {
64 std::cout << "at d=" << d << " b=" << b << " i=" << i << " j=" << j
65 << " " << result(d, i, j, b) << " vs " << expected
66 << std::endl;
67 }
68 EigenApprox(result(d, i, j, b), expected);
69 }
70 }
71 }
72 }
73}
74
75TEST(EigenPoolingTest, SimpleRowMajor) {
76 const int depth = 10;

Callers

nothing calls this directly

Calls 4

SpatialMaxPoolingClass · 0.85
EigenApproxFunction · 0.70
constantMethod · 0.45
dimensionMethod · 0.45

Tested by

no test coverage detected