Restructure project sources.

This commit is contained in:
2018-03-26 12:17:52 +02:00
parent a206f81eb2
commit 8015b84311
41 changed files with 2 additions and 37 deletions

62
src/fmri/LayerInfo.cpp Normal file
View File

@@ -0,0 +1,62 @@
#include "LayerInfo.hpp"
using namespace std;
using namespace fmri;
const unordered_map<string_view, LayerInfo::Type> LayerInfo::NAME_TYPE_MAP = {
{"Input", Type::Input},
{"Convolution", Type::Convolutional},
{"ReLU", Type::ReLU},
{"Pooling", Type::Pooling},
{"InnerProduct", Type::InnerProduct},
{"Dropout", Type::DropOut},
{"LRN", Type::LRN},
{"Split", Type::Split},
{"Softmax", Type::Softmax}
};
LayerInfo::Type LayerInfo::typeByName(string_view name)
{
try {
return NAME_TYPE_MAP.at(name);
} catch (std::out_of_range &e) {
LOG(INFO) << "Received unknown layer type: " << name << endl;
return Type::Other;
}
}
LayerInfo::LayerInfo(string_view name, string_view type,
const vector<boost::shared_ptr<caffe::Blob<DType>>> &parameters)
: parameters_(parameters), type_(typeByName(type)), name_(name)
{
}
const std::string &LayerInfo::name() const
{
return name_;
}
LayerInfo::Type LayerInfo::type() const
{
return type_;
}
const std::vector<boost::shared_ptr<caffe::Blob<DType>>>& LayerInfo::parameters() const
{
return parameters_;
}
std::ostream &fmri::operator<<(std::ostream &out, LayerInfo::Type type)
{
for (auto i : LayerInfo::NAME_TYPE_MAP) {
if (i.second == type) {
out << i.first;
return out;
}
}
out << "ERROR! UNSUPPORTED TYPE";
return out;
}