From 24d2b08713dbc5ccfaeca4aef69c71bd5a7e781f Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 13 Sep 2016 14:05:07 +0200 Subject: [PATCH 1/3] eclipse --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 31013dc8..f51f9aec 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,7 @@ with operator overloading. In honour of Marian Rejewski, a Polish mathematician and cryptologist. + mkdir build + cd build + cmake .. + make -j From 7b9555b1de2b4a9b36d2754de17e8f24ce336710 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 13 Sep 2016 14:32:25 +0200 Subject: [PATCH 2/3] tweak --- README.md | 1 + src/test.cu | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c0761ad8..6bee418b 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Exporting some paths for CuDNN may be required (put it, for example, in your `.b Compilation with `cmake > 3.5`: mkdir build + cd build cmake .. make -j diff --git a/src/test.cu b/src/test.cu index 56156fee..a7b5d874 100644 --- a/src/test.cu +++ b/src/test.cu @@ -6,14 +6,14 @@ int main(int argc, char** argv) { using namespace marian; using namespace keywords; - auto x = input(shape={whatevs, 784}, name="X"); - auto y = input(shape={whatevs, 10}, name="Y"); + Expr x = input(shape={whatevs, 784}, name="X"); + Expr y = input(shape={whatevs, 10}, name="Y"); - auto w = param(shape={784, 10}, name="W0"); - auto b = param(shape={1, 10}, name="b0"); + Expr w = param(shape={784, 10}, name="W0"); + Expr b = param(shape={1, 10}, name="b0"); - auto lr = softmax(dot(x, w) + b, axis=1, name="pred"); - auto graph = -mean(sum(y * log(lr), axis=1), axis=0, name="cost"); + Expr lr = softmax(dot(x, w) + b, axis=1, name="pred"); + Expr graph = -mean(sum(y * log(lr), axis=1), axis=0, name="cost"); Tensor tx({500, 784}, 1); Tensor ty({500, 10}, 1); @@ -46,4 +46,4 @@ int main(int argc, char** argv) { //opt.run(); return 0; -} \ No newline at end of file +} From 08055a26622ed4c1e260100812e87114e02dfc8d Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 13 Sep 2016 15:19:39 +0200 Subject: [PATCH 3/3] 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;