You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@singa.apache.org by zh...@apache.org on 2016/06/13 13:20:24 UTC
[31/50] [abbrv] incubator-singa git commit: SINGA-162 Transfer the
codebase for SINGA v1.0 into dev branch
SINGA-162 Transfer the codebase for SINGA v1.0 into dev branch
add guard flags in test file to support test without cuda
Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/04e23d1a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/04e23d1a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/04e23d1a
Branch: refs/heads/master
Commit: 04e23d1a60d5160ff319f63fe89d715feee53b57
Parents: 7a19165
Author: WANG Sheng <wa...@gmail.com>
Authored: Fri Jun 3 15:31:06 2016 +0800
Committer: WANG Sheng <wa...@gmail.com>
Committed: Fri Jun 3 15:31:06 2016 +0800
----------------------------------------------------------------------
test/singa/test_dense.cc | 8 ++++----
test/singa/test_mse.cc | 2 ++
test/singa/test_sgd.cc | 2 +-
test/singa/test_softmax.cc | 2 ++
test/singa/test_tensor_math.cc | 10 ++++++----
5 files changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/04e23d1a/test/singa/test_dense.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_dense.cc b/test/singa/test_dense.cc
index 606f819..5050d7e 100644
--- a/test/singa/test_dense.cc
+++ b/test/singa/test_dense.cc
@@ -37,7 +37,7 @@ TEST(Dense, Setup) {
EXPECT_EQ(3u, dense.num_output());
EXPECT_EQ(2u, dense.num_input());
}
-
+#ifdef USE_CBLAS
TEST(Dense, ForwardCpp) {
Dense dense;
@@ -75,9 +75,8 @@ TEST(Dense, ForwardCpp) {
x[i * 2 + 1] * we[j * 2 + 1] + bia[j]),
outptr1[i * 3 + j]);
}
-
-
-
+#endif // USE_CBLAS
+#ifdef USE_CUDA
TEST(Dense, BackwardCpp) {
Dense dense;
@@ -140,6 +139,7 @@ TEST(Dense, BackwardCpp) {
for (int i = 0; i < 3; i++)
EXPECT_FLOAT_EQ((dy[0 * 3 + i] + dy[1 * 3 + i] + dy[2 * 3 + i]), dbiasx[i]);
}
+#endif
#ifdef USE_CUDA
TEST(Dense, ForwardCuda) {
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/04e23d1a/test/singa/test_mse.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_mse.cc b/test/singa/test_mse.cc
index 67f583c..ccaab7a 100644
--- a/test/singa/test_mse.cc
+++ b/test/singa/test_mse.cc
@@ -66,6 +66,7 @@ TEST_F(TestMSE, CppBackward) {
EXPECT_FLOAT_EQ(gdat[i], (1.0f / p.shape().at(0)) * (pdat[i] - tdat[i]));
}
#endif
+#ifdef USE_CUDA
TEST_F(TestMSE, CudaForward) {
singa::MSE mse;
singa::CudaGPU dev;
@@ -98,3 +99,4 @@ TEST_F(TestMSE, CudaBackward) {
for (size_t i = 0; i < grad.Size(); i++)
EXPECT_FLOAT_EQ(gdat[i], (1.0f / p.shape().at(0)) * (pdat[i] - tdat[i]));
}
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/04e23d1a/test/singa/test_sgd.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_sgd.cc b/test/singa/test_sgd.cc
index a660556..c0b6e2b 100644
--- a/test/singa/test_sgd.cc
+++ b/test/singa/test_sgd.cc
@@ -82,7 +82,7 @@ TEST(SGD, ApplyWithMomentum) {
}
}
-#ifndef USE_CUDA
+#ifdef USE_CUDA
TEST(SGD, ApplyWithoutMomentumCuda) {
singa::SGD sgd;
const float v[4] = {0.1, 0.2, 0.3, 0.4};
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/04e23d1a/test/singa/test_softmax.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_softmax.cc b/test/singa/test_softmax.cc
index 6ee8b3f..c087605 100644
--- a/test/singa/test_softmax.cc
+++ b/test/singa/test_softmax.cc
@@ -36,6 +36,7 @@ TEST(Softmax, Setup) {
EXPECT_EQ(2, sft.Axis());
}
+#ifdef USE_CBLAS
TEST(Softmax, Forward) {
const float x[] = {1.0f, 2.0f, 0.0f, -2.0f, -3.0f, -1.0};
size_t n = sizeof(x) / sizeof(float);
@@ -108,3 +109,4 @@ TEST(Softmax, Backward) {
EXPECT_FLOAT_EQ(dx[4], xptr[4]);
EXPECT_FLOAT_EQ(dx[5], xptr[5]);
}
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/04e23d1a/test/singa/test_tensor_math.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_tensor_math.cc b/test/singa/test_tensor_math.cc
index 8368c55..170b96c 100644
--- a/test/singa/test_tensor_math.cc
+++ b/test/singa/test_tensor_math.cc
@@ -252,6 +252,7 @@ TEST_F(TestTensorMath, SumColumnsCpp) {
}
}
#endif
+#ifdef USE_CUDA
TEST_F(TestTensorMath, MultCuda) {
const float x[4] = {1.0f, 2.0f, 3.0f, 4.0f};
singa::CudaGPU dev;
@@ -337,7 +338,7 @@ TEST_F(TestTensorMath, SubColumnCuda) {
}
}
}
-
+#endif
TEST_F(TestTensorMath, MultColumnCpp) {
const float x[3] = {1.0f, 2.0f, 3.0f};
Tensor t(Shape{3});
@@ -351,7 +352,7 @@ TEST_F(TestTensorMath, MultColumnCpp) {
}
}
}
-
+#ifdef USE_CUDA
TEST_F(TestTensorMath, MultColumnCuda) {
const float x[3] = {1.0f, 2.0f, 3.0f};
singa::CudaGPU dev;
@@ -432,7 +433,7 @@ TEST_F(TestTensorMath, MultRowCuda) {
}
}
}
-
+#endif
TEST_F(TestTensorMath, DivRowCpp) {
const float x[2] = {1.1f, 2.1f};
Tensor t(Shape{2});
@@ -446,7 +447,7 @@ TEST_F(TestTensorMath, DivRowCpp) {
}
}
}
-
+#ifdef USE_CUDA
TEST_F(TestTensorMath, DivRowCuda) {
const float x[2] = {1.1f, 2.1f};
singa::CudaGPU dev;
@@ -495,3 +496,4 @@ TEST_F(TestTensorMath, SumColumnCuda) {
EXPECT_FLOAT_EQ(tptr[i], tmp);
}
}
+#endif