Skip to content

Commit

Permalink
[test] TestReshape: check that shapes actually change
Browse files Browse the repository at this point in the history
Check that output spatial shape varies with input shape while the output
num matches the input num.
  • Loading branch information
shelhamer committed Sep 24, 2015
1 parent ae77b15 commit b8c81bd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/caffe/test/test_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b8c81bd

Please sign in to comment.