aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/kernels/crop_and_resize_op_test.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2016-06-29 15:32:57 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-06-29 16:48:22 -0700
commit1d92cfcbf5c157b3e4069741ae5bdbbea6666dc5 (patch)
tree414fef12a20b9be5e9b5826327bfb7c9424d5e5b /tensorflow/core/kernels/crop_and_resize_op_test.cc
parente8974bac93f18e249676f4cd2e9bdbac2c813add (diff)
Correct bug in crop_and_resize which caused failures to some tests.
Change: 126246458
Diffstat (limited to 'tensorflow/core/kernels/crop_and_resize_op_test.cc')
-rw-r--r--tensorflow/core/kernels/crop_and_resize_op_test.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/tensorflow/core/kernels/crop_and_resize_op_test.cc b/tensorflow/core/kernels/crop_and_resize_op_test.cc
index 38f3c1adb2..68e077e44d 100644
--- a/tensorflow/core/kernels/crop_and_resize_op_test.cc
+++ b/tensorflow/core/kernels/crop_and_resize_op_test.cc
@@ -189,6 +189,24 @@ TEST_F(CropAndResizeOpTest, TestCropAndResize2x2To3x3Extrapolated) {
test::ExpectTensorEqual<float>(expected, *GetOutput(0));
}
+TEST_F(CropAndResizeOpTest, TestCropAndResize2x2To3x3NoCrop) {
+ MakeOp(0);
+ // Input:
+ // 1, 2
+ // 3, 4
+ AddInputFromArray<float>(TensorShape({1, 2, 2, 1}), {1, 2, 3, 4});
+ AddInputFromArray<float>(TensorShape({0, 4}), {});
+ AddInputFromArray<int32>(TensorShape({0}), {});
+ AddInputFromArray<int32>(TensorShape({2}), {3, 3});
+ TF_ASSERT_OK(RunOpKernel());
+
+ Tensor expected(allocator(), DT_FLOAT, TensorShape({0, 3, 3, 1}));
+ // clang-format off
+ test::FillValues<float>(&expected, {});
+ // clang-format on
+ test::ExpectTensorEqual<float>(expected, *GetOutput(0));
+}
+
TEST_F(CropAndResizeOpTest, TestInvalidInputShape) {
MakeOp(0);
AddInputFromArray<float>(TensorShape({2, 2, 1}), {1, 2, 3, 4});
@@ -201,6 +219,19 @@ TEST_F(CropAndResizeOpTest, TestInvalidInputShape) {
<< s;
}
+TEST_F(CropAndResizeOpTest, TestInvalidBoxIndexShape) {
+ MakeOp(0);
+ AddInputFromArray<float>(TensorShape({1, 2, 2, 1}), {1, 2, 3, 4});
+ AddInputFromArray<float>(TensorShape({1, 4}), {0, 0, 1, 1});
+ AddInputFromArray<int32>(TensorShape({2}), {0, 0});
+ AddInputFromArray<int32>(TensorShape({2}), {4, 4});
+ Status s = RunOpKernel();
+ ASSERT_FALSE(s.ok());
+ EXPECT_TRUE(
+ StringPiece(s.ToString()).contains("box_ind has incompatible shape"))
+ << s;
+}
+
TEST_F(CropAndResizeOpTest, TestInvalidBoxIndex) {
MakeOp(0);
AddInputFromArray<float>(TensorShape({1, 2, 2, 1}), {1, 2, 3, 4});