Implement a debug print for LayerData.
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -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,44 +8,49 @@
|
|||||||
|
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
|
||||||
namespace fmri {
|
namespace fmri
|
||||||
|
{
|
||||||
|
|
||||||
using std::string;
|
using std::ostream;
|
||||||
using std::string_view;
|
using std::string;
|
||||||
using std::unique_ptr;
|
using std::string_view;
|
||||||
using std::vector;
|
using std::unique_ptr;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
class LayerData
|
class LayerData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class Type {
|
enum class Type
|
||||||
Input,
|
{
|
||||||
Convolutional,
|
Input,
|
||||||
ReLU,
|
Convolutional,
|
||||||
Pooling,
|
ReLU,
|
||||||
Output,
|
Pooling,
|
||||||
Other
|
Output,
|
||||||
};
|
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);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string name_;
|
string name_;
|
||||||
vector<int> shape_;
|
vector<int> shape_;
|
||||||
unique_ptr<DType[]> data_;
|
unique_ptr<DType[]> data_;
|
||||||
Type type_;
|
Type type_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream&, const fmri::LayerData&);
|
||||||
|
|||||||
Reference in New Issue
Block a user