Implement a debug print for LayerData.

This commit is contained in:
2017-11-16 14:13:01 +01:00
parent b781960632
commit dc2f945f48
2 changed files with 59 additions and 33 deletions

View File

@@ -63,3 +63,23 @@ LayerData::Type LayerData::typeFromString(string_view typeName)
return Type::Other; return Type::Other;
} }
} }
ostream& operator<< (ostream& o, const LayerData& layer)
{
o << layer.name() << '(';
bool first = true;
for (auto d : layer.shape()) {
if (!first) {
o << ", ";
} else {
first = false;
}
o << d;
}
o << ')';
return o;
}

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include <iostream>
#include <memory> #include <memory>
#include <string> #include <string>
#include <string_view> #include <string_view>
@@ -7,8 +8,10 @@
#include "utils.hpp" #include "utils.hpp"
namespace fmri { namespace fmri
{
using std::ostream;
using std::string; using std::string;
using std::string_view; using std::string_view;
using std::unique_ptr; using std::unique_ptr;
@@ -17,7 +20,8 @@ namespace fmri {
class LayerData class LayerData
{ {
public: public:
enum class Type { enum class Type
{
Input, Input,
Convolutional, Convolutional,
ReLU, ReLU,
@@ -26,17 +30,17 @@ namespace fmri {
Other Other
}; };
LayerData(const string& name, const vector<int>& shape, const DType* data, Type type); LayerData(const string &name, const vector<int> &shape, const DType *data, Type type);
LayerData(const LayerData&) = delete; LayerData(const LayerData &) = delete;
LayerData(LayerData&&) = default;
LayerData& operator=(const LayerData&) = delete; LayerData(LayerData &&) = default;
LayerData& operator=(LayerData&&) = default; LayerData &operator=(const LayerData &) = delete;
LayerData &operator=(LayerData &&) = default;
const string& name() const; const string &name() const;
Type type() const; Type type() const;
const vector<int>& shape() const; const vector<int> &shape() const;
DType const * data() const; DType const *data() const;
size_t numEntries() const; size_t numEntries() const;
static Type typeFromString(string_view name); static Type typeFromString(string_view name);
@@ -48,3 +52,5 @@ namespace fmri {
Type type_; Type type_;
}; };
} }
std::ostream& operator<<(std::ostream&, const fmri::LayerData&);