ShichengChen commented on a change in pull request #416: singa-onnx
URL: https://github.com/apache/incubator-singa/pull/416#discussion_r264102222
 
 

 ##########
 File path: python/singa/sonnx.py
 ##########
 @@ -257,24 +255,28 @@ def to_onnx_model(inputs, y, model_name='sonnx'):
         the onnx model
     '''
     node = []
-    inputsx=inputs
     dependency = autograd.infer_dependency(y.creator)
     ready = deque([y.creator])
 
-    def output_name(op, index):
-        return '{}:{}'.format(op.name, index)
+    def output_name(op):
+        return '{}'.format(op.name)
 
     input_ids = set(id(x) for x in inputs)
     X = []
+    for x in inputs:
+        dtype = TensorProto.FLOAT
+        if y.dtype == tensor.int32:
+            dtype = TensorProto.INT
+        X.append(helper.make_tensor_value_info(x.name, dtype, x.shape))
     Y = [helper.make_tensor_value_info(
-        output_name(y.creator, 0), TensorProto.FLOAT, y.shape)]
+        output_name(y.creator), TensorProto.FLOAT, y.shape)]
 
     while len(ready) > 0:
         op = ready.pop()
         assert not isinstance(op, autograd.Dummy)
-        outputs = [output_name(op, idx)
+        outputs = [output_name(op)
 
 Review comment:
   [(<singa.autograd.Sigmoid object at 0x7fd5ec09cb90>, 140556764852432, None, 
False),
   (<singa.autograd.Dummy object at 0x7fd5ec09c390>, 140556764824208, 
<singa.tensor.Tensor object at 0x7fd5ec09c290>, True),
    (<singa.autograd.Dummy object at 0x7fd5ec09c490>, 140556764824528,
    <singa.tensor.Tensor object at 0x7fd5ec09c3d0>, True),
   (<singa.autograd.Dummy object at 0x7fd5ec09c590>, 140556764824784, None, 
False),
   (<singa.autograd.Dummy object at 0x7fd5ec09c690>, 140556764825040, None, 
False)])
   two dummy operators do not have values, so take the values from handle

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to