summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Shelhamer <shelhamer@imaginarynumber.net>2015-09-23 20:40:24 (GMT)
committerEvan Shelhamer <shelhamer@imaginarynumber.net>2015-09-24 03:24:11 (GMT)
commitb8c81bd2bfbc5bc2e394395bf2c1f435cb32b2a1 (patch)
treed4aeee9aac6f92cc6a6fd86d263d63c9e5fb61a5
parentae77b15495d4c2a83202c49991bfc0885765de03 (diff)
downloadcaffeonacl-b8c81bd2bfbc5bc2e394395bf2c1f435cb32b2a1.zip
caffeonacl-b8c81bd2bfbc5bc2e394395bf2c1f435cb32b2a1.tar.gz
caffeonacl-b8c81bd2bfbc5bc2e394395bf2c1f435cb32b2a1.tar.bz2
[test] TestReshape: check that shapes actually change
Check that output spatial shape varies with input shape while the output num matches the input num.
-rw-r--r--src/caffe/test/test_net.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/caffe/test/test_net.cpp b/src/caffe/test/test_net.cpp
index 16c1d35..ab4afba 100644
--- a/src/caffe/test/test_net.cpp
+++ b/src/caffe/test/test_net.cpp
@@ -2262,8 +2262,8 @@ TEST_F(FilterNetTest, TestFilterInOutByExcludeMultiRule) {
TYPED_TEST(NetTest, TestReshape) {
typedef typename TypeParam::Dtype Dtype;
// We set up bottom blobs of two different sizes, switch between
- // them, and check that forward and backward both run and the results
- // are the same.
+ // them, check that forward and backward both run and the results
+ // are the same, and check that the output shapes change.
Caffe::set_random_seed(this->seed_);
Caffe::set_mode(Caffe::CPU);
FillerParameter filler_param;
@@ -2317,6 +2317,18 @@ TYPED_TEST(NetTest, TestReshape) {
for (int i = 0; i < output2.count(); ++i) {
EXPECT_FLOAT_EQ(*(output2.cpu_data() + i), *(output_blob->cpu_data() + i));
}
+
+ EXPECT_EQ(output1.num(), blob1.num());
+ EXPECT_EQ(output2.num(), blob2.num());
+ bool same_spatial_shape = true;
+ const int kFirstSpatialAxis = 2;
+ for (int i = kFirstSpatialAxis; i < output1.num_axes(); ++i) {
+ if (output1.shape(i) != output2.shape(i)) {
+ same_spatial_shape = false;
+ break;
+ }
+ }
+ EXPECT_FALSE(same_spatial_shape);
}
TYPED_TEST(NetTest, TestSkipPropagateDown) {