From 08055a26622ed4c1e260100812e87114e02dfc8d Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 13 Sep 2016 15:19:39 +0200 Subject: [PATCH] debug --- src/tensor.h | 20 +++++++++++++++++++- src/test.cu | 6 +++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/tensor.h b/src/tensor.h index fdae329a..c9125b8c 100644 --- a/src/tensor.h +++ b/src/tensor.h @@ -5,6 +5,7 @@ #include #include #include +#include #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 @@ -214,6 +226,12 @@ class Tensor { operator bool() { return pimpl_ != nullptr; } + + std::string Debug() const + { + return pimpl_->Debug(); + } + }; -} \ No newline at end of file +} diff --git a/src/test.cu b/src/test.cu index a7b5d874..db3ec9d3 100644 --- a/src/test.cu +++ b/src/test.cu @@ -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;