aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/kernels/gather_op_test.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <nobody@tensorflow.org>2016-04-15 14:43:11 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-04-15 15:51:42 -0700
commit5a6117908e8ddf563333459d5eea825db51cc6d0 (patch)
treea443a9ed8000a3c9380c47dbebfeb14fe0926171 /tensorflow/core/kernels/gather_op_test.cc
parent43f1c2633797040881b1cf99c785d044f30d9582 (diff)
The behavior of outer_dimensions was different than before when the selected indices had a 0. Making it emulate the old behavior because gather stopped working for length 0 Tensors.
e.g.: Gathering row 1 from a Tensor of shape [2, 0] should result in a [1, 0] Tensor, but instead resulted in an error like: AttributeError: index 1 is not in [0, 2) Change: 119998790
Diffstat (limited to 'tensorflow/core/kernels/gather_op_test.cc')
-rw-r--r--tensorflow/core/kernels/gather_op_test.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/tensorflow/core/kernels/gather_op_test.cc b/tensorflow/core/kernels/gather_op_test.cc
index bbf2683ff1..062e3863d9 100644
--- a/tensorflow/core/kernels/gather_op_test.cc
+++ b/tensorflow/core/kernels/gather_op_test.cc
@@ -78,6 +78,19 @@ TEST_F(GatherOpTest, Simple_TwoD32) {
test::ExpectTensorEqual<float>(expected, *GetOutput(0));
}
+TEST_F(GatherOpTest, ZeroSize_TwoD32) {
+ MakeOp(DT_INT32);
+
+ // Feed and run
+ AddInputFromArray<float>(TensorShape({5, 0}), {});
+ AddInputFromArray<int32>(TensorShape({4}), {0, 4, 0, 2});
+ TF_ASSERT_OK(RunOpKernel());
+
+ // Check the output.
+ Tensor expected(allocator(), DT_FLOAT, TensorShape({4, 0}));
+ test::ExpectTensorEqual<float>(expected, *GetOutput(0));
+}
+
TEST_F(GatherOpTest, Simple_TwoD64) {
MakeOp(DT_INT64);