Skip to content

Commit

Permalink
add test that all V1 layer type enum values upgrade to valid V2 string
Browse files Browse the repository at this point in the history
types
  • Loading branch information
jeffdonahue committed Jan 22, 2015
1 parent b709774 commit 573e8c7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/caffe/test/test_upgrade_proto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "caffe/blob.hpp"
#include "caffe/common.hpp"
#include "caffe/layer.hpp"
#include "caffe/util/upgrade_proto.hpp"

#include "caffe/test/test_caffe_main.hpp"
Expand Down Expand Up @@ -2848,4 +2849,21 @@ TEST_F(NetUpgradeTest, TestImageNet) {
this->RunV1UpgradeTest(expected_v1_proto, expected_v2_proto);
} // NOLINT(readability/fn_size)

TEST_F(NetUpgradeTest, TestUpgradeV1LayerType) {
LayerParameter layer_param;
shared_ptr<Layer<float> > layer;
for (int i = 0; i < V1LayerParameter_LayerType_LayerType_ARRAYSIZE; ++i) {
ASSERT_TRUE(V1LayerParameter_LayerType_IsValid(i));
V1LayerParameter_LayerType v1_type = V1LayerParameter_LayerType(i);
string v2_layer_type(UpgradeV1LayerType(v1_type));
if (v2_layer_type == "") {
EXPECT_EQ(V1LayerParameter_LayerType_NONE, v1_type);
continue; // Empty string isn't actually a valid layer type.
}
layer_param.set_type(v2_layer_type);
layer.reset(LayerRegistry<float>::CreateLayer(layer_param));
EXPECT_EQ(v2_layer_type, layer->type());
}
}

} // NOLINT(readability/fn_size) // namespace caffe

0 comments on commit 573e8c7

Please sign in to comment.