-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for LayerRegistry::CreateLayer
- Loading branch information
1 parent
ed04cb0
commit cb50d6d
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |