singa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wang...@apache.org
Subject [7/8] incubator-singa git commit: SINGA-247 Add windows support for singa
Date Mon, 10 Oct 2016 15:46:13 GMT
SINGA-247 Add windows support for singa

Remove dynamic lib generation on windows.
Fix some warnings and a typo in instructions.


Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/901e885b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/901e885b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/901e885b

Branch: refs/heads/master
Commit: 901e885b18f430205397a79e740d72cffb63712c
Parents: 8531af5
Author: xiezl <xiezhongle@comp.nus.edu.sg>
Authored: Wed Oct 5 21:04:32 2016 +0800
Committer: Wei Wang <wangwei@comp.nus.edu.sg>
Committed: Mon Oct 10 17:44:54 2016 +0800

----------------------------------------------------------------------
 cmake/Templates/singa_config.h.in       |  2 --
 doc/en/docs/dependencies.md             |  2 +-
 src/CMakeLists.txt                      | 18 +++++++++++-------
 src/core/device/opencl_device.cc        |  6 ++++--
 src/core/device/platform.cc             |  6 +++++-
 src/core/memory/memory.cc               |  5 +++--
 src/core/tensor/sparse_tensor.cc        |  2 --
 src/io/jpg_decoder.cc                   |  6 +++++-
 src/io/jpg_encoder.cc                   |  6 +++++-
 src/io/lmdb_reader.cc                   |  6 +++++-
 src/io/lmdb_writer.cc                   |  7 +++++--
 src/model/optimizer/local_all_reduce.cc |  2 --
 test/CMakeLists.txt                     |  4 ++--
 test/singa/test_accuracy.cc             |  2 +-
 test/singa/test_activation.cc           |  2 +-
 test/singa/test_adagrad.cc              |  4 ++--
 test/singa/test_batchnorm.cc            |  2 +-
 test/singa/test_cross_entropy.cc        |  2 +-
 test/singa/test_csv.cc                  |  2 +-
 test/singa/test_dropout.cc              |  2 +-
 test/singa/test_image_transformer.cc    |  8 ++++----
 test/singa/test_lrn.cc                  | 16 ++++++++--------
 test/singa/test_mse.cc                  |  2 +-
 test/singa/test_nesterov.cc             |  4 ++--
 test/singa/test_rmsprop.cc              |  8 ++++----
 test/singa/test_sgd.cc                  |  8 ++++----
 test/singa/test_snapshot.cc             |  4 ++--
 test/singa/test_tensor_math.cc          |  2 +-
 28 files changed, 80 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/cmake/Templates/singa_config.h.in
----------------------------------------------------------------------
diff --git a/cmake/Templates/singa_config.h.in b/cmake/Templates/singa_config.h.in
index 324f7a3..f3500d0 100644
--- a/cmake/Templates/singa_config.h.in
+++ b/cmake/Templates/singa_config.h.in
@@ -40,8 +40,6 @@
 
 #cmakedefine ENABLE_DIST
 
-#cmakedefine DISABLE_WARNINGS
-
 // lmdb
 #cmakedefine USE_LMDB
 

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/doc/en/docs/dependencies.md
----------------------------------------------------------------------
diff --git a/doc/en/docs/dependencies.md b/doc/en/docs/dependencies.md
index d7da27d..5216900 100644
--- a/doc/en/docs/dependencies.md
+++ b/doc/en/docs/dependencies.md
@@ -56,7 +56,7 @@ Step 5: Done.
 ### CBLAS
 
 There are ready-to-use binary packages online
-([link](https://sourceforge.net/projects/openblas/files/). However, we still install
+([link](https://sourceforge.net/projects/openblas/files/)). However, we still install
 OpenBLAS with version 0.2.18 as test:
 
 Step 1: Download and decompress the source code.

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ce3e792..b9526a3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -79,19 +79,23 @@ ENDFOREACH()
 
 ADD_LIBRARY(singa_objects OBJECT ${singa_sources})
 IF(WIN32) 
+  ADD_LIBRARY(singa STATIC $<TARGET_OBJECTS:singa_objects> ${cuda_objs})
+  TARGET_LINK_LIBRARIES(singa ${SINGA_LINKER_LIBS})
   IF (MSVC)
 	ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
-	#SET_TARGET_PROPERTIES(singa_objects 
-	#  PROPERTIES COMPILE_FLAGS "/wd4244 /wd4267 /wd4018 /wd4005 /wd4804 /wd4800")
+	IF(DISABLE_WARNINGS)
+	  ADD_DEFINITIONS(-DDISABLE_WARNINGS)
+	  SET_TARGET_PROPERTIES(singa_objects 
+	    PROPERTIES COMPILE_FLAGS "/wd4244 /wd4267 /wd4018 /wd4005 /wd4804 /wd4800")
+	ENDIF()
   ENDIF()
 ENDIF()
 ADD_DEPENDENCIES(singa_objects copy_protobuf)
 
-ADD_LIBRARY(singa SHARED $<TARGET_OBJECTS:singa_objects> ${cuda_objs})
-TARGET_LINK_LIBRARIES(singa ${SINGA_LINKER_LIBS})
-
-ADD_LIBRARY(singa_static STATIC $<TARGET_OBJECTS:singa_objects> ${cuda_objs})
-TARGET_LINK_LIBRARIES(singa_static ${SINGA_LINKER_LIBS})
+IF(UNIX OR APPLE)
+  ADD_LIBRARY(singa SHARED $<TARGET_OBJECTS:singa_objects> ${cuda_objs})
+  TARGET_LINK_LIBRARIES(singa ${SINGA_LINKER_LIBS})
+ENDIF()
 
 #pass configure infor to swig 
 FILE(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/api/config.i")

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/src/core/device/opencl_device.cc
----------------------------------------------------------------------
diff --git a/src/core/device/opencl_device.cc b/src/core/device/opencl_device.cc
index c9c2211..e0d4ff3 100644
--- a/src/core/device/opencl_device.cc
+++ b/src/core/device/opencl_device.cc
@@ -15,8 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-#ifdef USE_OPENCL
+#ifndef DISABLE_WARNINGS
 
 #include <iostream>
 #include <fstream>
@@ -27,6 +26,7 @@
 #include "singa/utils/tinydir.h"
 #include "singa/utils/opencl_utils.h"
 
+#ifdef USE_OPENCL
 
 using namespace viennacl;
 using namespace viennacl::backend::opencl;
@@ -170,3 +170,5 @@ void OpenclDevice::Free(void* p) {
 } // namespace singa
 
 #endif // USE_OPENCL
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/src/core/device/platform.cc
----------------------------------------------------------------------
diff --git a/src/core/device/platform.cc b/src/core/device/platform.cc
index 3392492..eb02c5b 100644
--- a/src/core/device/platform.cc
+++ b/src/core/device/platform.cc
@@ -15,11 +15,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifdef USE_CUDA
+#ifndef DISABLE_WARNINGS
 
 #include "singa/core/device.h"
 #include "singa/singa_config.h"
 
+#ifdef USE_CUDA
+
 namespace singa {
 
 int Platform::GetNumGPUs() {
@@ -138,3 +140,5 @@ Platform::CreateCudaGPUsOn(const vector<int> &devices, size_t
init_size) {
 }  // namespace singa
 
 #endif  // USE_CUDA
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/src/core/memory/memory.cc
----------------------------------------------------------------------
diff --git a/src/core/memory/memory.cc b/src/core/memory/memory.cc
index 2dd1cbe..0fb8511 100644
--- a/src/core/memory/memory.cc
+++ b/src/core/memory/memory.cc
@@ -17,12 +17,13 @@
  */
 #ifndef DISABLE_WARNINGS
 
-#ifdef USE_CUDA
 #include "singa/core/memory.h"
 #include "singa/utils/logging.h"
 #include "singa/proto/core.pb.h"
 #include <iostream>
 
+#ifdef USE_CUDA
+
 namespace singa {
 std::atomic<int> CnMemPool::pool_count(0);
 std::pair<size_t, size_t> CnMemPool::GetMemUsage() {
@@ -111,4 +112,4 @@ void CudaMemPool::Free(void *ptr) {
 }
 #endif
 
-#endif
\ No newline at end of file
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/src/core/tensor/sparse_tensor.cc
----------------------------------------------------------------------
diff --git a/src/core/tensor/sparse_tensor.cc b/src/core/tensor/sparse_tensor.cc
index 68021d1..46ea850 100644
--- a/src/core/tensor/sparse_tensor.cc
+++ b/src/core/tensor/sparse_tensor.cc
@@ -15,8 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include "singa/singa_config.h"
-
 #ifndef DISABLE_WARNINGS
 
 #include "singa/core/tensor.h"

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/src/io/jpg_decoder.cc
----------------------------------------------------------------------
diff --git a/src/io/jpg_decoder.cc b/src/io/jpg_decoder.cc
index e0d458c..c6aca19 100644
--- a/src/io/jpg_decoder.cc
+++ b/src/io/jpg_decoder.cc
@@ -15,10 +15,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifdef USE_OPENCV
+#ifndef DISABLE_WARNINGS
 
 #include "singa/io/decoder.h"
 
+#ifdef USE_OPENCV
+
 #include <opencv2/highgui/highgui.hpp>
 #include <opencv2/imgproc/imgproc.hpp>
 
@@ -72,3 +74,5 @@ std::vector<Tensor> JPGDecoder::Decode(std::string value) {
 }
 }  // namespace singa
 #endif
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/src/io/jpg_encoder.cc
----------------------------------------------------------------------
diff --git a/src/io/jpg_encoder.cc b/src/io/jpg_encoder.cc
index 4a4ee85..e4ab144 100644
--- a/src/io/jpg_encoder.cc
+++ b/src/io/jpg_encoder.cc
@@ -15,10 +15,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifdef USE_OPENCV
+#ifndef DISABLE_WARNINGS
 
 #include "singa/io/encoder.h"
 
+#ifdef USE_OPENCV
+
 #include <opencv2/highgui/highgui.hpp>
 #include <opencv2/imgproc/imgproc.hpp>
 
@@ -81,3 +83,5 @@ std::string JPGEncoder::Encode(vector<Tensor>& data) {
 }
 }  // namespace singa
 #endif  // USE_OPENCV
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/src/io/lmdb_reader.cc
----------------------------------------------------------------------
diff --git a/src/io/lmdb_reader.cc b/src/io/lmdb_reader.cc
index 8bb82c0..44b097c 100644
--- a/src/io/lmdb_reader.cc
+++ b/src/io/lmdb_reader.cc
@@ -15,11 +15,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifdef USE_LMDB
+#ifndef DISABLE_WARNINGS
 
 #include "singa/io/reader.h"
 #include "singa/utils/logging.h"
 
+#ifdef USE_LMDB
+
 namespace singa {
 namespace io {
 bool LMDBReader::Open(const std::string& path) {
@@ -116,3 +118,5 @@ inline void LMDBReader::MDB_CHECK(int mdb_status) {
 }  // namespace io
 }  // namespace singa
 #endif  // USE_LMDB
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/src/io/lmdb_writer.cc
----------------------------------------------------------------------
diff --git a/src/io/lmdb_writer.cc b/src/io/lmdb_writer.cc
index 3e6d5f8..ec0e002 100644
--- a/src/io/lmdb_writer.cc
+++ b/src/io/lmdb_writer.cc
@@ -15,12 +15,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-#ifdef USE_LMDB
+#ifndef DISABLE_WARNINGS
 
 #include "singa/io/writer.h"
 #include "singa/utils/logging.h"
 
+#ifdef USE_LMDB
+
 namespace singa {
 namespace io {
 bool LMDBWriter::Open(const std::string& path, Mode mode) {
@@ -132,3 +133,5 @@ inline void LMDBWriter::MDB_CHECK(int mdb_status) {
 }  // namespace io
 }  // namespace singa
 #endif  // USE_LMDB
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/src/model/optimizer/local_all_reduce.cc
----------------------------------------------------------------------
diff --git a/src/model/optimizer/local_all_reduce.cc b/src/model/optimizer/local_all_reduce.cc
index e496efa..9cda321 100644
--- a/src/model/optimizer/local_all_reduce.cc
+++ b/src/model/optimizer/local_all_reduce.cc
@@ -15,8 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include "singa/singa_config.h"
-
 #ifndef DISABLE_WARNINGS
 
 #ifndef SRC_MODEL_OPTIMIZER_LOCAL_ALL_REDUCE_H_

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index a996413..e1487d2 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -31,9 +31,9 @@ AUX_SOURCE_DIRECTORY(singa singa_test_source)
 LIST(REMOVE_ITEM singa_test_source "singa/test_ep.cc")
 
 ADD_EXECUTABLE(test_singa "gtest/gtest_main.cc" ${singa_test_source})
-ADD_DEPENDENCIES(test_singa singa_static)
+ADD_DEPENDENCIES(test_singa singa)
 #MESSAGE(STATUS "link libs" ${singa_linker_libs})
-TARGET_LINK_LIBRARIES(test_singa gtest singa_static ${SINGA_LINKER_LIBS})
+TARGET_LINK_LIBRARIES(test_singa gtest singa ${SINGA_LINKER_LIBS})
 IF(UNIX AND (NOT APPLE))
     LIST(APPEND LINK_FLAGS "-pthread")
 ENDIF()

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_accuracy.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_accuracy.cc b/test/singa/test_accuracy.cc
index 5d337fb..5b8067d 100644
--- a/test/singa/test_accuracy.cc
+++ b/test/singa/test_accuracy.cc
@@ -26,7 +26,7 @@ TEST(Accuracy, Compute) {
   singa::Accuracy acc;
   singa::Tensor p(singa::Shape{2, 3});
   singa::Tensor t(singa::Shape{2}, singa::kInt);
-  const float pdat[6] = {0.1, 0.3, 0.6, 0.3, 0.2, 0.5};
+  const float pdat[6] = {0.1f, 0.3f, 0.6f, 0.3f, 0.2f, 0.5f};
   const int tdat[2] = {1, 2};  // one wrong, one correct
   p.CopyDataFromHostPtr(pdat, sizeof(pdat) / sizeof(float));
   t.CopyDataFromHostPtr(tdat, sizeof(tdat) / sizeof(int));

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_activation.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_activation.cc b/test/singa/test_activation.cc
index bb8ad84..ee7a44e 100644
--- a/test/singa/test_activation.cc
+++ b/test/singa/test_activation.cc
@@ -116,7 +116,7 @@ TEST(Activation, Backward) {
     float* dx = new float[n];
     if (acti.Mode() == "sigmoid") {
       for (size_t i = 0; i < n; i++)
-        dx[i] = grad[i] * yptr[i] * (1. - yptr[i]);
+        dx[i] = grad[i] * yptr[i] * (1.0f - yptr[i]);
     }
     else if (acti.Mode() == "tanh") {
       for (size_t i = 0; i < n; i++)

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_adagrad.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_adagrad.cc b/test/singa/test_adagrad.cc
index f12ec68..7408411 100644
--- a/test/singa/test_adagrad.cc
+++ b/test/singa/test_adagrad.cc
@@ -27,8 +27,8 @@
 TEST(AdaGrad, ApplyCPU) {
   singa::AdaGrad adagrad;
   float lr = 0.1f;
-  const float v[4] = {0.1, 0.2, 0.3, 0.4};
-  const float g[4] = {0.01, 0.02, 0.03, 0.04};
+  const float v[4] = {0.1f, 0.2f, 0.3f, 0.4f};
+  const float g[4] = {0.01f, 0.02f, 0.03f, 0.04f};
 
   singa::Tensor value(singa::Shape{4}), grad(singa::Shape{4});
   value.CopyDataFromHostPtr(v, 4);

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_batchnorm.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_batchnorm.cc b/test/singa/test_batchnorm.cc
index a61f6f3..c8efbf9 100644
--- a/test/singa/test_batchnorm.cc
+++ b/test/singa/test_batchnorm.cc
@@ -34,7 +34,7 @@ TEST(BatchNorm, Setup) {
   batchnorm_conf->set_factor(0.01);
   batchnorm.Setup(Shape{2, 4, 4}, conf);
 
-  EXPECT_FLOAT_EQ(0.01, batchnorm.factor());
+  EXPECT_FLOAT_EQ(0.01f, batchnorm.factor());
   EXPECT_EQ(2u, batchnorm.channels());
   EXPECT_EQ(4u, batchnorm.height());
   EXPECT_EQ(4u, batchnorm.width());

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_cross_entropy.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_cross_entropy.cc b/test/singa/test_cross_entropy.cc
index 8235766..d63695e 100644
--- a/test/singa/test_cross_entropy.cc
+++ b/test/singa/test_cross_entropy.cc
@@ -47,7 +47,7 @@ TEST_F(TestSoftmaxCrossEntropy, CppForward) {
   const Tensor& loss = cross_entropy.Forward(singa::kEval, p, t);
   auto ldat = loss.data<float>();
 
-  const float result_test = -log(0.25);
+  const float result_test = (float) -log(0.25);
   EXPECT_FLOAT_EQ(ldat[0], result_test);
   EXPECT_FLOAT_EQ(ldat[1], result_test);
 }

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_csv.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_csv.cc b/test/singa/test_csv.cc
index d8dbe69..77f5baa 100644
--- a/test/singa/test_csv.cc
+++ b/test/singa/test_csv.cc
@@ -36,7 +36,7 @@ TEST(CSV, EncoderDecode) {
   decoder.Setup(decoder_conf);
   EXPECT_EQ(true, decoder.has_label());
 
-  float in_data[] = {1.23, 4.5, 5.1, 3.33, 0.44};
+  float in_data[] = {1.23f, 4.5f, 5.1f, 3.33f, 0.44f};
   std::string in_str = "2, 1.23, 4.5, 5.1, 3.33, 0.44";
   int in_label = 2;
   size_t size = 5;

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_dropout.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_dropout.cc b/test/singa/test_dropout.cc
index b0c34a3..047762e 100644
--- a/test/singa/test_dropout.cc
+++ b/test/singa/test_dropout.cc
@@ -30,7 +30,7 @@ TEST(Dropout, Setup) {
 
   singa::LayerConf conf;
   singa::DropoutConf* dropconf = conf.mutable_dropout_conf();
-  dropconf->set_dropout_ratio(0.8);
+  dropconf->set_dropout_ratio(0.8f);
 
   drop.Setup(Shape{3}, conf);
   EXPECT_EQ(0.8f, drop.dropout_ratio());

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_image_transformer.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_image_transformer.cc b/test/singa/test_image_transformer.cc
index 4540aa8..016da72 100644
--- a/test/singa/test_image_transformer.cc
+++ b/test/singa/test_image_transformer.cc
@@ -58,7 +58,7 @@ TEST(ImageTransformer, Apply3D) {
   float* x = new float[n];
   size_t channel = 3, height = 6, width = 10;
   singa::Tensor in(singa::Shape{height, width, channel});
-  srand(time(NULL));
+  srand((unsigned int)time(NULL));
   for (size_t i = 0; i < n; i++) x[i] = (float)(rand() % 256);
   in.CopyDataFromHostPtr<float>(x, n);
   int resize_height = 4, resize_width = 6;
@@ -125,7 +125,7 @@ TEST(ImageTransformer, Apply2D) {
   float* x = new float[n];
   size_t height = 6, width = 10;
   singa::Tensor in(singa::Shape{height, width});
-  srand(time(NULL));
+  srand((unsigned int)time(NULL));
   for (size_t i = 0; i < n; i++) x[i] = (float)(rand() % 256);
   in.CopyDataFromHostPtr<float>(x, n);
   int resize_height = 4, resize_width = 6;
@@ -219,7 +219,7 @@ TEST(ImageTransformer, Crop) {
   float* x = new float[n];
   size_t channel = 3, height = 6, width = 10;
   singa::Tensor in(singa::Shape{channel, height, width});
-  srand(time(NULL));
+  srand((unsigned int)time(NULL));
   for (size_t i = 0; i < n; i++) x[i] = (float)(rand() % 256);
   in.CopyDataFromHostPtr<float>(x, n);
   size_t crop_height = 3, crop_width = 4,
@@ -244,7 +244,7 @@ TEST(ImageTransformer, Mirror) {
   float* x = new float[n];
   size_t channel = 3, height = 2, width = 5;
   singa::Tensor in(singa::Shape{height, width, channel});
-  srand(time(NULL));
+  srand((unsigned int)time(NULL));
   for (size_t i = 0; i < n; i++) x[i] = (float)(rand() % 256);
   in.CopyDataFromHostPtr<float>(x, n);
   singa::Tensor out = singa::mirror(in, true, false, "HWC");

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_lrn.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_lrn.cc b/test/singa/test_lrn.cc
index 454e1a9..6a389e1 100644
--- a/test/singa/test_lrn.cc
+++ b/test/singa/test_lrn.cc
@@ -32,14 +32,14 @@ TEST(LRN, Setup) {
   LRNConf *lrn_conf = conf.mutable_lrn_conf();
   lrn_conf->set_k(1.0);
   lrn_conf->set_local_size(3);
-  lrn_conf->set_alpha(0.1);
-  lrn_conf->set_beta(0.75);
+  lrn_conf->set_alpha(0.1f);
+  lrn_conf->set_beta(0.75f);
   lrn.Setup(Shape{1}, conf);
 
   EXPECT_FLOAT_EQ(1.0, lrn.k());
   EXPECT_EQ(3, lrn.local_size());
-  EXPECT_FLOAT_EQ(0.1, lrn.alpha());
-  EXPECT_FLOAT_EQ(0.75, lrn.beta());
+  EXPECT_FLOAT_EQ(0.1f, lrn.alpha());
+  EXPECT_FLOAT_EQ(0.75f, lrn.beta());
 }
 
 TEST(LRN, Forward) {
@@ -52,8 +52,8 @@ TEST(LRN, Forward) {
   singa::LRNConf *lrn_conf = conf.mutable_lrn_conf();
   lrn_conf->set_k(1.0);
   lrn_conf->set_local_size(3);
-  lrn_conf->set_alpha(0.1);
-  lrn_conf->set_beta(0.75);
+  lrn_conf->set_alpha(0.1f);
+  lrn_conf->set_beta(0.75f);
   lrn.Setup(Shape{4, 1, 1}, conf);
 
   Tensor out = lrn.Forward(kTrain, in);
@@ -85,8 +85,8 @@ TEST(LRN, Backward) {
   singa::LRNConf *lrn_conf = conf.mutable_lrn_conf();
   lrn_conf->set_k(1.0);
   lrn_conf->set_local_size(3);
-  lrn_conf->set_alpha(0.1);
-  lrn_conf->set_beta(0.75);
+  lrn_conf->set_alpha(0.1f);
+  lrn_conf->set_beta(0.75f);
   lrn.Setup(Shape{4, 1, 1}, conf);
 
   Tensor out = lrn.Forward(kTrain, in);

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_mse.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_mse.cc b/test/singa/test_mse.cc
index 9cf0e9c..7aa3326 100644
--- a/test/singa/test_mse.cc
+++ b/test/singa/test_mse.cc
@@ -51,7 +51,7 @@ TEST_F(TestMSE, CppForward) {
       l += (pdat[k] - tdat[k]) * (pdat[k] - tdat[k]);
       k++;
     }
-    EXPECT_FLOAT_EQ(ldat[i], 0.5 * l);
+    EXPECT_FLOAT_EQ(ldat[i], 0.5f * l);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_nesterov.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_nesterov.cc b/test/singa/test_nesterov.cc
index 7c76784..3ae3181 100644
--- a/test/singa/test_nesterov.cc
+++ b/test/singa/test_nesterov.cc
@@ -28,8 +28,8 @@ TEST(Nesterov, ApplyCPU) {
   float lr = 0.1f;
   auto func = [](int step) { return step <= 5 ? 0.5f : 0.9f; };
   nesterov.SetMomentumGenerator(func);
-  const float v[4] = {0.1, 0.2, 0.3, 0.4};
-  const float g[4] = {0.01, 0.02, 0.03, 0.04};
+  const float v[4] = {0.1f, 0.2f, 0.3f, 0.4f};
+  const float g[4] = {0.01f, 0.02f, 0.03f, 0.04f};
 
   singa::Tensor value(singa::Shape{4}), grad(singa::Shape{4});
   value.CopyDataFromHostPtr(v, 4);

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_rmsprop.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_rmsprop.cc b/test/singa/test_rmsprop.cc
index d259592..f398355 100644
--- a/test/singa/test_rmsprop.cc
+++ b/test/singa/test_rmsprop.cc
@@ -26,13 +26,13 @@
 TEST(RMSProp, ApplyCPU) {
   singa::RMSProp rmsprop;
   float lr = 0.1f;
-  float rho = 0.9;
-  const float v[4] = {0.1, 0.2, 0.3, 0.4};
-  const float g[4] = {0.01, 0.02, 0.03, 0.04};
+  float rho = 0.9f;
+  const float v[4] = {0.1f, 0.2f, 0.3f, 0.4f};
+  const float g[4] = {0.01f, 0.02f, 0.03f, 0.04f};
 
   singa::OptimizerConf conf;
   conf.set_rho(rho);
-  conf.set_delta(1E-8);
+  conf.set_delta(1E-8f);
 
   singa::Tensor value(singa::Shape{4}), grad(singa::Shape{4});
   value.CopyDataFromHostPtr(v, 4);

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_sgd.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_sgd.cc b/test/singa/test_sgd.cc
index e6ed9bf..c25dfbd 100644
--- a/test/singa/test_sgd.cc
+++ b/test/singa/test_sgd.cc
@@ -25,8 +25,8 @@
 
 TEST(SGD, ApplyWithoutMomentum) {
   singa::SGD sgd;
-  const float v[4] = {0.1, 0.2, 0.3, 0.4};
-  const float g[4] = {0.1, 0.1, 0.1, 0.1};
+  const float v[4] = {0.1f, 0.2f, 0.3f, 0.4f};
+  const float g[4] = {0.1f, 0.1f, 0.1f, 0.1f};
 
   singa::Tensor value(singa::Shape{4}), grad(singa::Shape{4});
   value.CopyDataFromHostPtr(v, 4);
@@ -58,8 +58,8 @@ TEST(SGD, ApplyWithMomentum) {
   float lr = 0.1f;
   auto func = [](int step) { return step <=5 ? 0.5f: 0.9f;};
   sgd.SetMomentumGenerator(func);
-  const float v[4] = {0.1, 0.2, 0.3, 0.4};
-  const float g[4] = {0.01, 0.02, 0.03, 0.04};
+  const float v[4] = {0.1f, 0.2f, 0.3f, 0.4f};
+  const float g[4] = {0.01f, 0.02f, 0.03f, 0.04f};
 
   singa::Tensor value(singa::Shape{4}), grad(singa::Shape{4});
   value.CopyDataFromHostPtr(v, 4);

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_snapshot.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_snapshot.cc b/test/singa/test_snapshot.cc
index 33b57b9..a9e8ee6 100644
--- a/test/singa/test_snapshot.cc
+++ b/test/singa/test_snapshot.cc
@@ -28,8 +28,8 @@
 #include <fstream>
 
 const std::string prefix = "./snapshot_test";
-const float param_1_data[] = {0.1, 0.2, 0.3, 0.4};
-const float param_2_data[] = {0.2, 0.1, 0.4, 0.3};
+const float param_1_data[] = {0.1f, 0.2f, 0.3f, 0.4f};
+const float param_2_data[] = {0.2f, 0.1f, 0.4f, 0.3f};
 const std::string desc_1 =
     "parameter name: Param_1\tdata type: 0\tdim: 1\tshape: 4";
 const std::string desc_2 =

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/901e885b/test/singa/test_tensor_math.cc
----------------------------------------------------------------------
diff --git a/test/singa/test_tensor_math.cc b/test/singa/test_tensor_math.cc
index 267905d..c3a1039 100644
--- a/test/singa/test_tensor_math.cc
+++ b/test/singa/test_tensor_math.cc
@@ -152,7 +152,7 @@ TEST_F(TestTensorMath, SoftMax) {
   Tensor p1 = SoftMax(Reshape(e, Shape{1, 6}));
   const float *dptr1 = p1.data<float>();
   float sum = 0;
-  for (int i = 0; i < 6; i++) sum += exp(i + 1);
+  for (int i = 0; i < 6; i++) sum += (float)exp(i + 1);
   EXPECT_NEAR(exp(1) / sum, dptr1[0], 1e-5);
   EXPECT_NEAR(exp(3) / sum, dptr1[2], 1e-5);
   EXPECT_NEAR(exp(5) / sum, dptr1[4], 1e-5);


Mime
View raw message