| 96 | }; |
| 97 | |
| 98 | TEST_F(LRNFloatTest, Depth96) { |
| 99 | TF_ASSERT_OK(NodeDefBuilder("lrn_op", "LRN") |
| 100 | .Input(FakeInput()) |
| 101 | .Attr("depth_radius", 5) |
| 102 | .Attr("bias", 1.0f) |
| 103 | .Attr("alpha", 0.1f) |
| 104 | .Attr("beta", 2.0f) |
| 105 | .Finalize(node_def())); |
| 106 | TF_ASSERT_OK(InitOp()); |
| 107 | AddInput<float>(TensorShape({1, 1, 1, 96}), |
| 108 | [](int i) -> float { return i + 1; }); |
| 109 | TF_ASSERT_OK(RunOpKernel()); |
| 110 | auto actual = GetOutput(0)->tensor<float, 4>(); |
| 111 | |
| 112 | // Output for Node 0 with Value 1: |
| 113 | // 1 / (1 + 0.1*(1^2 + 2^2 + 3^2 + 4^2 + 5^2 + 6^2))^2 |
| 114 | EXPECT_NEAR(1. / (10.1 * 10.1), actual(0, 0, 0, 0), tol_); |
| 115 | |
| 116 | // Output for Node 5 with Value 6: |
| 117 | // 6 / (1 + 0.1*(1^2 + 2^2 + 3^2 + 4^2 + 5^2 + 6^2 ... + 11^2))^2 |
| 118 | EXPECT_NEAR(6. / (51.6 * 51.6), actual(0, 0, 0, 5), tol_); |
| 119 | |
| 120 | // Output for Node 63 with value 64: |
| 121 | // 64 / (1 + 0.1*(59^2 + 60^2 + 61^2 + 62^2 + 63^2 + 64^2))^2 |
| 122 | EXPECT_NEAR(64. / (2272.1 * 2272.1), actual(0, 0, 0, 63), tol_); |
| 123 | |
| 124 | // Output for Node 64 with value 65: |
| 125 | // 65 / (1 + 0.1*(65^2 + 66^2 + 67^2 + 68^2 + 69^2 + 70^2))^2 |
| 126 | EXPECT_NEAR(65. / (2736.5 * 2736.5), actual(0, 0, 0, 64), tol_); |
| 127 | |
| 128 | // Output for Node 95 with value 96: |
| 129 | // 96 / (1 + 0.1*(91^2 + 92^2 + 93^2 + 94^2 + 95^2 + 96^2))^2 |
| 130 | EXPECT_NEAR(96. / (5248.1 * 5248.1), actual(0, 0, 0, 95), tol_); |
| 131 | EXPECT_TRUE(Compare()); |
| 132 | } |
| 133 | |
| 134 | TEST_F(LRNFloatTest, Depth16) { |
| 135 | TF_ASSERT_OK(NodeDefBuilder("lrn_op", "LRN") |
nothing calls this directly
no test coverage detected