Skip to content

Commit

Permalink
Add unit test for LayerRegistry::CreateLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdonahue committed Jan 22, 2015
1 parent ed04cb0 commit cb50d6d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/caffe/test/test_layer_factory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <map>
#include <string>

#include "gtest/gtest.h"

#include "caffe/common.hpp"
#include "caffe/layer.hpp"
#include "caffe/layer_factory.hpp"

#include "caffe/test/test_caffe_main.hpp"

namespace caffe {

template <typename TypeParam>
class LayerFactoryTest : public MultiDeviceTest<TypeParam> {};

TYPED_TEST_CASE(LayerFactoryTest, TestDtypesAndDevices);

TYPED_TEST(LayerFactoryTest, TestCreateLayer) {
typedef typename TypeParam::Dtype Dtype;
typename LayerRegistry<Dtype>::CreatorRegistry& registry =
LayerRegistry<Dtype>::Registry();
shared_ptr<Layer<Dtype> > layer;
LayerParameter layer_param;
for (typename LayerRegistry<Dtype>::CreatorRegistry::iterator iter =
registry.begin(); iter != registry.end(); ++iter) {
layer_param.set_type(iter->first);
layer.reset(LayerRegistry<Dtype>::CreateLayer(layer_param));
EXPECT_EQ(iter->first, layer->type());
}
}

} // namespace caffe

0 comments on commit cb50d6d

Please sign in to comment.