diff --git a/src/LayerData.cpp b/src/LayerData.cpp index 120f3c3..3b12418 100644 --- a/src/LayerData.cpp +++ b/src/LayerData.cpp @@ -10,10 +10,9 @@ using namespace fmri; using namespace std; -LayerData::LayerData(const string& name, const vector& shape, const DType* data, Type type) : +LayerData::LayerData(const string& name, const vector& shape, const DType* data) : name_(name), - shape_(shape), - type_(type) + shape_(shape) { const auto dataSize = numEntries(); // Compute the dimension of the data area @@ -25,7 +24,7 @@ LayerData::LayerData(const string& name, const vector& shape, const DType* size_t LayerData::numEntries() const { - return accumulate(shape_.begin(), shape_.end(), 1, multiplies<>()); + return static_cast(accumulate(shape_.begin(), shape_.end(), 1, multiplies<>())); } const vector& LayerData::shape() const @@ -33,11 +32,6 @@ const vector& LayerData::shape() const return shape_; } -typename LayerData::Type LayerData::type() const -{ - return type_; -} - const string& LayerData::name() const { return name_; @@ -48,22 +42,6 @@ DType const * LayerData::data() const return data_.get(); } -LayerData::Type LayerData::typeFromString(string_view typeName) -{ - if (typeName == "Input") { - return Type::Input; - } else if (typeName == "Convolution") { - return Type::Convolutional; - } else if (typeName == "ReLU") { - return Type::ReLU; - } else if (typeName == "Pooling") { - return Type::Pooling; - } else { - LOG(INFO) << "Received unknown layer type: " << typeName << endl; - return Type::Other; - } -} - ostream& operator<< (ostream& o, const LayerData& layer) { o << layer.name() << '('; diff --git a/src/LayerData.hpp b/src/LayerData.hpp index 1c2bdb3..c4630d9 100644 --- a/src/LayerData.hpp +++ b/src/LayerData.hpp @@ -20,17 +20,7 @@ namespace fmri class LayerData { public: - enum class Type - { - Input, - Convolutional, - ReLU, - Pooling, - Output, - Other - }; - - LayerData(const string &name, const vector &shape, const DType *data, Type type); + LayerData(const string &name, const vector &shape, const DType *data); LayerData(const LayerData &) = delete; LayerData(LayerData &&) = default; @@ -38,18 +28,13 @@ namespace fmri LayerData &operator=(LayerData &&) = default; const string &name() const; - Type type() const; const vector &shape() const; DType const *data() const; size_t numEntries() const; - - static Type typeFromString(string_view name); - private: string name_; vector shape_; unique_ptr data_; - Type type_; }; } diff --git a/src/LayerInfo.cpp b/src/LayerInfo.cpp index 8ef9a2d..53ad8f4 100644 --- a/src/LayerInfo.cpp +++ b/src/LayerInfo.cpp @@ -31,3 +31,8 @@ const std::string &LayerInfo::name() const { return name_; } + +LayerInfo::Type LayerInfo::type() const +{ + return type_; +} diff --git a/src/LayerInfo.hpp b/src/LayerInfo.hpp index d0019b8..24d4787 100644 --- a/src/LayerInfo.hpp +++ b/src/LayerInfo.hpp @@ -24,6 +24,7 @@ namespace fmri const std::vector>> ¶meters); const std::string& name() const; + Type type() const; static Type typeByName(std::string_view name); diff --git a/src/Simulator.cpp b/src/Simulator.cpp index 9b5dbcd..568096f 100644 --- a/src/Simulator.cpp +++ b/src/Simulator.cpp @@ -9,7 +9,6 @@ #include #include "Simulator.hpp" -#include "utils.hpp" using namespace caffe; using namespace std; @@ -92,8 +91,6 @@ void Simulator::Impl::loadMeans(const string &means_file) vector Simulator::Impl::simulate(const string& image_file) { - typedef LayerData::Type LType; - cv::Mat im = cv::imread(image_file, -1); assert(!im.empty()); @@ -115,7 +112,7 @@ vector Simulator::Impl::simulate(const string& image_file) CHECK_EQ(results[i].size(), 1) << "Multiple outputs per layer are not supported!" << endl; const auto blob = results[i][0]; - result.emplace_back(names[i], blob->shape(), blob->cpu_data(), LayerData::typeFromString(layers[i]->type())); + result.emplace_back(names[i], blob->shape(), blob->cpu_data()); } return result; diff --git a/src/main.cpp b/src/main.cpp index 75a00a0..37f713d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,6 +20,7 @@ using namespace fmri; struct { optional> labels; + map layerInfo; vector> data; vector>::iterator currentData; vector> layerVisualisations; @@ -30,6 +31,7 @@ static vector> getSimulationData(const Options &options) vector> results; auto dumper = options.imageDumper(); Simulator simulator(options.model(), options.weights(), options.means()); + rendererData.layerInfo = simulator.layerInfo(); for (const auto &image : options.inputs()) { results.emplace_back(simulator.simulate(image));