You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@singa.apache.org by ch...@apache.org on 2018/05/05 13:00:10 UTC

[1/4] incubator-singa git commit: SINGA-350 Error from python3 test

Repository: incubator-singa
Updated Branches:
  refs/heads/master 3a373987a -> f73ae5a5f


SINGA-350 Error from python3 test

Update the minimum version of swig to 3.0.10, which is required
to fix the bugs (related to string) from py3.

Add comments in model_layer.i for handling strings.


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

Branch: refs/heads/master
Commit: 72b1a69df14a7e14a2456f32eb6e3e0730d325d9
Parents: fb7b0d3
Author: Wang Wei <dc...@nus.edu.sg>
Authored: Tue May 1 23:42:40 2018 +0800
Committer: Wang Wei <dc...@nus.edu.sg>
Committed: Tue May 1 23:42:40 2018 +0800

----------------------------------------------------------------------
 cmake/Dependencies.cmake |  2 +-
 python/singa/layer.py    |  2 +-
 src/api/model_layer.i    | 21 +++++++++++++++++++++
 3 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/72b1a69d/cmake/Dependencies.cmake
----------------------------------------------------------------------
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index 187d467..e221aa8 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -128,7 +128,7 @@ IF(USE_PYTHON)
         set(Python_ADDITIONAL_VERSIONS 3.6 3.5 3.4)        
         FIND_PACKAGE(PythonInterp 3 REQUIRED)
         FIND_PACKAGE(PythonLibs 3 REQUIRED)
-	    FIND_PACKAGE(SWIG 3.0.8 REQUIRED)
+	    FIND_PACKAGE(SWIG 3.0.10 REQUIRED)
     ELSE()        
         FIND_PACKAGE(PythonInterp 2.7 REQUIRED)
         FIND_PACKAGE(PythonLibs 2.7 REQUIRED)

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/72b1a69d/python/singa/layer.py
----------------------------------------------------------------------
diff --git a/python/singa/layer.py b/python/singa/layer.py
index c6ff30a..1f3cb56 100644
--- a/python/singa/layer.py
+++ b/python/singa/layer.py
@@ -1354,4 +1354,4 @@ def get_layer_list():
     """ Return a list of strings which include the identifiers (tags) of all
     supported layers
     """
-    return singa_wrap.GetRegisteredLayers()
+    return [str(l) for l in singa_wrap.GetRegisteredLayers()]

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/72b1a69d/src/api/model_layer.i
----------------------------------------------------------------------
diff --git a/src/api/model_layer.i b/src/api/model_layer.i
index 4760da3..d449f24 100644
--- a/src/api/model_layer.i
+++ b/src/api/model_layer.i
@@ -29,7 +29,28 @@
 
 
 %{
+// To make the code compatible between py2 and py3, the follow 
+// macro is required, which forces the 
+// interface (function) to accept byte string (from python) and 
+// return byte string (in python) in py3. Otherwise the strings 
+// should be unicode strings in py3.
+// Note that by default the strings in python3 are of type unicode.
+// You have to encode it with the correct encoding (default is utf-8) 
+// to convert it into bytes. Sometimes, the string is already byte string
+// e.g. from protobuf SerializeToString, then there is no need to do
+// conversion. The output byte strings should be decoded into unicode.
+// For python2, the default type of string is byte string. 
+//
+// Because protobuf::SerializeToString cannot be decoded into unicode 
+// string, we cannot use SWIG_PYTHON_2_UNICODE which forces the 
+// interface (function) to accept unicode strings as input args 
+// and return unicode strings.
+//
+// TODO(wangwei) make strings compatible between py2 and py3.
+
 #define SWIG_PYTHON_STRICT_BYTE_CHAR
+
+
 #include "singa/model/layer.h"
 #include "../src/model/layer/rnn.h"
 #include "../src/model/layer/cudnn_rnn.h"


[2/4] incubator-singa git commit: SINGA-350 Error from python3 test

Posted by ch...@apache.org.
SINGA-350 Error from python3 test

Add encode() back in optimizer.py


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

Branch: refs/heads/master
Commit: 2d2556135bc04282f382ad3fc5071fc51a6aad28
Parents: 72b1a69
Author: Wang Wei <dc...@nus.edu.sg>
Authored: Wed May 2 21:39:28 2018 +0800
Committer: Wang Wei <dc...@nus.edu.sg>
Committed: Wed May 2 21:39:28 2018 +0800

----------------------------------------------------------------------
 python/singa/optimizer.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/2d255613/python/singa/optimizer.py
----------------------------------------------------------------------
diff --git a/python/singa/optimizer.py b/python/singa/optimizer.py
index 5cb02e5..975641a 100644
--- a/python/singa/optimizer.py
+++ b/python/singa/optimizer.py
@@ -206,7 +206,7 @@ class SGD(Optimizer):
         if self.momentum is not None:
             conf.momentum = self.momentum
         conf.type = 'sgd'
-        self.opt = singa.CreateOptimizer('SGD')
+        self.opt = singa.CreateOptimizer('SGD'.encode())
         self.opt.Setup(conf.SerializeToString())
 
     def apply_with_lr(self, epoch, lr, grad, value, name, step=-1):
@@ -216,7 +216,7 @@ class SGD(Optimizer):
             epoch, value, grad, name, step)
         if name is not None and name in self.learning_rate_multiplier:
             lr = lr * self.learning_rate_multiplier[name]
-        self.opt.Apply(epoch, lr, name, grad.data,
+        self.opt.Apply(epoch, lr, name.encode(), grad.data,
                        value.data)
         return value
 
@@ -235,7 +235,7 @@ class Nesterov(Optimizer):
         if self.momentum is not None:
             conf.momentum = momentum
         conf.type = 'nesterov'
-        self.opt = singa.CreateOptimizer('Nesterov')
+        self.opt = singa.CreateOptimizer('Nesterov'.encode())
         self.opt.Setup(conf.SerializeToString())
 
     def apply_with_lr(self, epoch, lr, grad, value, name, step=-1):
@@ -246,7 +246,7 @@ class Nesterov(Optimizer):
             epoch, value, grad, name, step)
         if name is not None and name in self.learning_rate_multiplier:
             lr = lr * self.learning_rate_multiplier[name]
-        self.opt.Apply(epoch, lr, name, grad.data,
+        self.opt.Apply(epoch, lr, name.encode(), grad.data,
                        value.data)
         return value
 
@@ -268,7 +268,7 @@ class RMSProp(Optimizer):
         conf = model_pb2.OptimizerConf()
         conf.rho = rho
         conf.delta = epsilon
-        self.opt = singa.CreateOptimizer('RMSProp')
+        self.opt = singa.CreateOptimizer('RMSProp'.encode())
         self.opt.Setup(conf.SerializeToString())
 
     def apply_with_lr(self, epoch, lr, grad, value, name, step=-1):
@@ -279,7 +279,7 @@ class RMSProp(Optimizer):
             epoch, value, grad, name, step)
         if name is not None and name in self.learning_rate_multiplier:
             lr = lr * self.learning_rate_multiplier[name]
-        self.opt.Apply(step, lr,  name, grad.data,
+        self.opt.Apply(step, lr,  name.encode(), grad.data,
                        value.data)
         return value
 
@@ -300,7 +300,7 @@ class AdaGrad(Optimizer):
         conf = model_pb2.OptimizerConf()
         conf.delta = epsilon
         conf.type = 'adagrad'
-        self.opt = singa.CreateOptimizer('AdaGrad')
+        self.opt = singa.CreateOptimizer('AdaGrad'.encode())
         self.opt.Setup(conf.SerializeToString())
 
     def apply_with_lr(self, epoch, lr, grad, value, name, step=-1):
@@ -311,7 +311,7 @@ class AdaGrad(Optimizer):
             epoch, value, grad, name, step)
         if name is not None and name in self.learning_rate_multiplier:
             lr = lr * self.learning_rate_multiplier[name]
-        self.opt.Apply(epoch, lr,  name, grad.data,
+        self.opt.Apply(epoch, lr,  name.encode(), grad.data,
                        value.data)
         return value
 


[4/4] incubator-singa git commit: Merge branch 'pr358'

Posted by ch...@apache.org.
Merge branch 'pr358'


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

Branch: refs/heads/master
Commit: f73ae5a5f73cbfebaa208aa269bfe0b9a6b4a1af
Parents: 3a37398 bd774b5
Author: Chonho Lee <le...@raizin.ais.cmc.osaka-u.ac.jp>
Authored: Fri May 4 23:50:14 2018 +0900
Committer: Chonho Lee <le...@raizin.ais.cmc.osaka-u.ac.jp>
Committed: Fri May 4 23:50:14 2018 +0900

----------------------------------------------------------------------
 cmake/Dependencies.cmake  |  2 +-
 python/singa/layer.py     |  2 +-
 python/singa/optimizer.py | 16 ++++++++--------
 src/api/model_layer.i     | 21 +++++++++++++++++++++
 tool/conda/build.sh       |  5 +++--
 5 files changed, 34 insertions(+), 12 deletions(-)
----------------------------------------------------------------------



[3/4] incubator-singa git commit: SINGA-350 Error from python3 test

Posted by ch...@apache.org.
SINGA-350 Error from python3 test

update the conda build script to fix a bug in CUDNN_PATH check.


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

Branch: refs/heads/master
Commit: bd774b56c18c15ee690909102239fdc60f356bce
Parents: 2d25561
Author: Wang Wei <dc...@nus.edu.sg>
Authored: Thu May 3 22:36:23 2018 +0800
Committer: Wang Wei <dc...@nus.edu.sg>
Committed: Thu May 3 23:39:50 2018 +0800

----------------------------------------------------------------------
 tool/conda/build.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/bd774b56/tool/conda/build.sh
----------------------------------------------------------------------
diff --git a/tool/conda/build.sh b/tool/conda/build.sh
index baa7ac3..91a2f3b 100644
--- a/tool/conda/build.sh
+++ b/tool/conda/build.sh
@@ -24,10 +24,11 @@ export CMAKE_INCLUDE_PATH=$PREFIX/include:$CMAKE_INCLUDE_PATH
 export CMAKE_LIBRARY_PATH=$PREFIX/lib:$CMAKE_LIBRARY_PATH
 
 
-USE_CUDA=OFF
 if [ -z ${CUDNN_PATH+x} ]; then
+	USE_CUDA=OFF
+else
 	USE_CUDA=ON
-	cp $CUDNN_PATH/include $PREFIX/include 
+	cp -r $CUDNN_PATH/include $PREFIX/include 
 	cp -P $CUDNN_PATH/lib64/libcudnn.so* $PREFIX/lib/
 fi