SINGA-347 Create a function that supports einsum
1. fix some calculation error in the tensor mult function
2. by doing the fixing, the test using numpy could pass


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

Branch: refs/heads/master
Commit: 2ec06ed15951fdcd02e55b20757bc708f0081cb4
Parents: b09aed3
Author: sheyujian <[email protected]>
Authored: Wed Apr 18 15:35:20 2018 +0800
Committer: sheyujian <[email protected]>
Committed: Wed Apr 18 15:44:41 2018 +0800

----------------------------------------------------------------------
 python/singa/tensor.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/2ec06ed1/python/singa/tensor.py
----------------------------------------------------------------------
diff --git a/python/singa/tensor.py b/python/singa/tensor.py
index e81f3ab..e6502fc 100644
--- a/python/singa/tensor.py
+++ b/python/singa/tensor.py
@@ -1098,6 +1098,8 @@ def tensormult(A, B, sum=None, multiply=None):
 
     Return: (Singa.Tensor)
         The output of the tensormult calculation
+
+    fix some error of source code in the nils-werner/sparse
     '''
     if sum is None:
         sum = [[], []]
@@ -1117,8 +1119,12 @@ def tensormult(A, B, sum=None, multiply=None):
         post_multiply[v] += i
 
 
-    for i in post_multiply:
+#    for i in post_multiply:
+#        A = diag(A,i)
+    for i in sorted(post_multiply):
+
         A = diag(A,i)
+        sum[0] = [x+1 if x >= i else x for x in sum[0]]
 
     sum[0] += post_multiply
     sum[1] += multiply[1]

Reply via email to