You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@singa.apache.org by wa...@apache.org on 2020/08/12 01:54:03 UTC

[singa] branch dev updated: fix sonnx last layers

This is an automated email from the ASF dual-hosted git repository.

wangwei pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/singa.git


The following commit(s) were added to refs/heads/dev by this push:
     new 675eae0  fix sonnx last layers
     new ff0b239  Merge pull request #774 from joddiy/fix-sonnx-last-layers
675eae0 is described below

commit 675eae06f4392ec4754ff540a04b73193e37891f
Author: joddiy <jo...@qq.com>
AuthorDate: Mon Jul 27 03:07:28 2020 +0800

    fix sonnx last layers
---
 python/singa/sonnx.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/python/singa/sonnx.py b/python/singa/sonnx.py
index 34dc6c1..fa6d41f 100755
--- a/python/singa/sonnx.py
+++ b/python/singa/sonnx.py
@@ -2048,9 +2048,11 @@ class SingaRep(BackendRep):
         outputs_dict = OrderedDict([])
 
         # last_layers means we run this model until the last #N layers
-        last_layers = kwargs.get('last_layers', len(self._layers))
-        if last_layers != len(self._layers):
-            for outp in self._layers[last_layers - 1].outputs:
+        last_layers = kwargs.get('last_layers', len(self._layers) - 1)
+        last_layers = last_layers if last_layers >= 0 else (
+            last_layers + 1) % len(self._layers)
+        if last_layers != len(self._layers) - 1:
+            for outp in self._layers[last_layers].outputs:
                 outputs_dict[outp] = None
         else:
             for outp in self.outputs:
@@ -2064,7 +2066,7 @@ class SingaRep(BackendRep):
         self.init_tensor_count()
 
         # run the layer by the topo order
-        for node in self._layers[:last_layers]:
+        for node in self._layers[:last_layers + 1]:
             op = self.__dict__[node.name]
             self.handle_special_ops(node, op, tensor_dict)
             # make input