aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/cc/gradients/math_grad_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/cc/gradients/math_grad_test.cc')
-rw-r--r--tensorflow/cc/gradients/math_grad_test.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/tensorflow/cc/gradients/math_grad_test.cc b/tensorflow/cc/gradients/math_grad_test.cc
index 011e119353..bd78331309 100644
--- a/tensorflow/cc/gradients/math_grad_test.cc
+++ b/tensorflow/cc/gradients/math_grad_test.cc
@@ -684,7 +684,7 @@ class CWiseUnaryComplexGradTest : public ::testing::Test {
CWiseUnaryComplexGradTest()
: scope_(Scope::NewRootScope().WithDevice("/cpu:0")) {}
- enum UnaryOpType { REAL, IMAG, CONJ };
+ enum UnaryOpType { REAL, IMAG, ANGLE, CONJ };
void TestCWiseGradComplex(UnaryOpType op_type, const Tensor& x,
const Tensor& dy, const Tensor& dx_expected) {
@@ -696,6 +696,9 @@ class CWiseUnaryComplexGradTest : public ::testing::Test {
case IMAG:
y = Imag(scope_, x);
break;
+ case ANGLE:
+ y = Angle(scope_, x);
+ break;
case CONJ:
y = Conj(scope_, x);
break;
@@ -730,6 +733,21 @@ TEST_F(CWiseUnaryComplexGradTest, Imag) {
TestCWiseGradComplex(IMAG, x, dy, dx_expected);
}
+TEST_F(CWiseUnaryComplexGradTest, Angle) {
+ Tensor x = test::AsTensor<complex64>(
+ {{1, -1}, {-2, 2}, {3, -3}, {-4, 4}, {8, -8}, {-9, 9}}, {2, 3});
+ Tensor dy = test::AsTensor<float>({11, -12, 13, -14, 15, -16}, {2, 3});
+ Tensor dx_expected =
+ test::AsTensor<complex64>({{5.5, 5.5},
+ {3, 3},
+ {2.1666666666666665, 2.1666666666666665},
+ {1.75, 1.75},
+ {0.9375, 0.9375},
+ {0.8888888888888888, 0.8888888888888888}},
+ {2, 3});
+ TestCWiseGradComplex(ANGLE, x, dy, dx_expected);
+}
+
TEST_F(CWiseUnaryComplexGradTest, Conj) {
Tensor x = test::AsTensor<complex64>(
{{1, -1}, {-2, 2}, {3, -3}, {-4, 4}, {8, -8}, {-9, 9}}, {2, 3});