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

Function TEST

tensorflow/core/kernels/eigen_spatial_convolutions_test.cc:29–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27static int ceil_div(int a, int b) { return (a + b - 1) / b; }
28
29TEST(EigenSpatialConvolutionsTest, Simple) {
30 const int input_depth = 7;
31 const int input_rows = 4;
32 const int input_cols = 5;
33 const int output_depth = 10;
34 const int patch_rows = 3;
35 const int patch_cols = 4;
36 const int output_rows = input_rows;
37 const int output_cols = input_cols;
38
39 Tensor<float, 3> input(input_depth, input_rows, input_cols);
40 Tensor<float, 4> kernel(output_depth, input_depth, patch_rows, patch_cols);
41 Tensor<float, 3> result(output_depth, output_rows, output_cols);
42
43 input = input.constant(11.0f) + input.random();
44 kernel = kernel.constant(2.0f) + kernel.random();
45 result.setRandom();
46
47 result = SpatialConvolution(input, kernel);
48
49 EXPECT_EQ(result.dimension(0), output_depth);
50 EXPECT_EQ(result.dimension(1), output_rows);
51 EXPECT_EQ(result.dimension(2), output_cols);
52
53 for (int od = 0; od < output_depth; ++od) {
54 for (int i = 0; i < output_rows; ++i) {
55 for (int j = 0; j < output_cols; ++j) {
56 float expected = 0.0f;
57 for (int c = 0; c < patch_cols; ++c) {
58 for (int r = 0; r < patch_rows; ++r) {
59 for (int id = 0; id < input_depth; ++id) {
60 if (r - 1 + i >= 0 && c - 1 + j >= 0 && r - 1 + i < output_rows &&
61 c - 1 + j < output_cols) {
62 expected +=
63 input(id, r - 1 + i, c - 1 + j) * kernel(od, id, r, c);
64 }
65 }
66 }
67 }
68 EigenApprox(result(od, i, j), expected);
69 }
70 }
71 }
72}
73
74TEST(EigenSpatialConvolutionsTest, SimpleRowMajor) {
75 const int input_depth = 7;

Callers

nothing calls this directly

Calls 11

reshapeMethod · 0.80
SpatialConvolutionClass · 0.70
EigenApproxFunction · 0.70
CuboidConvolutionClass · 0.70
ceil_divFunction · 0.70
constantMethod · 0.45
dimensionMethod · 0.45
sizeMethod · 0.45
reverseMethod · 0.45
dimensionsMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected