diff options
Diffstat (limited to 'tensorflow/cc/gradients/nn_grad_test.cc')
-rw-r--r-- | tensorflow/cc/gradients/nn_grad_test.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tensorflow/cc/gradients/nn_grad_test.cc b/tensorflow/cc/gradients/nn_grad_test.cc index eab5b44626..a02d36549b 100644 --- a/tensorflow/cc/gradients/nn_grad_test.cc +++ b/tensorflow/cc/gradients/nn_grad_test.cc @@ -47,6 +47,15 @@ class NNGradTest : public ::testing::Test { EXPECT_LT(max_error, 1e-4); } + void RunTest(const OutputList& xs, const std::vector<TensorShape>& x_shapes, + const OutputList& ys, const std::vector<TensorShape>& y_shapes) { + TF_ASSERT_OK(scope_.status()); + float max_error; + TF_ASSERT_OK( + ComputeGradientError(scope_, xs, x_shapes, ys, y_shapes, &max_error)); + EXPECT_LT(max_error, 1e-4); + } + Scope scope_; }; @@ -113,5 +122,14 @@ TEST_F(NNGradTest, SeluGrad) { RunTest(x, x_init_value, y, shape); } +TEST_F(NNGradTest, BiasAddGradHelper) { + TensorShape shape({4, 5}); + TensorShape bias_shape({5}); + auto x = Placeholder(scope_, DT_FLOAT, Placeholder::Shape(shape)); + auto bias = Placeholder(scope_, DT_FLOAT, Placeholder::Shape(bias_shape)); + auto y = BiasAdd(scope_, x, bias); + RunTest({x,bias}, {shape, bias_shape}, {y}, {shape}); +} + } // namespace } // namespace tensorflow |