mirror of
https://github.com/marian-nmt/marian.git
synced 2024-08-15 01:00:23 +03:00
debug
This commit is contained in:
parent
7b9555b1de
commit
08055a2662
20
src/tensor.h
20
src/tensor.h
@ -5,6 +5,7 @@
|
||||
#include <thrust/device_vector.h>
|
||||
#include <thrust/functional.h>
|
||||
#include <numeric>
|
||||
#include <sstream>
|
||||
|
||||
#include "definitions.h"
|
||||
#include "exception.h"
|
||||
@ -139,6 +140,17 @@ class TensorImpl {
|
||||
void set(value_type value) {
|
||||
thrust::fill(data_.begin(), data_.end(), value);
|
||||
}
|
||||
|
||||
std::string Debug() const
|
||||
{
|
||||
std::stringstream strm;
|
||||
assert(shape_.size());
|
||||
strm << "shape=" << shape_[0];
|
||||
for (size_t i = 1; i < shape_.size(); ++i) {
|
||||
strm << "x" << shape_[i];
|
||||
}
|
||||
return strm.str();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Type>
|
||||
@ -214,6 +226,12 @@ class Tensor {
|
||||
operator bool() {
|
||||
return pimpl_ != nullptr;
|
||||
}
|
||||
|
||||
std::string Debug() const
|
||||
{
|
||||
return pimpl_->Debug();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
|
||||
#include "marian.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
using namespace marian;
|
||||
@ -17,7 +19,9 @@ int main(int argc, char** argv) {
|
||||
|
||||
Tensor tx({500, 784}, 1);
|
||||
Tensor ty({500, 10}, 1);
|
||||
|
||||
cerr << "tx=" << tx.Debug();
|
||||
cerr << "ty=" << ty.Debug();
|
||||
|
||||
x = tx;
|
||||
y = ty;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user