You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/09/05 21:21:10 UTC

[GitHub] vandanavk commented on a change in pull request #12457: [MXNET-885] ONNX export - Clip operator

vandanavk commented on a change in pull request #12457: [MXNET-885] ONNX export - Clip operator
URL: https://github.com/apache/incubator-mxnet/pull/12457#discussion_r215429655
 
 

 ##########
 File path: python/mxnet/contrib/onnx/mx2onnx/_op_translations.py
 ##########
 @@ -1057,6 +1057,34 @@ def convert_flatten(node, **kwargs):
     )
     return [flatten_node]
 
+@mx_op.register("clip")
+def convert_clip(node, **kwargs):
+    """Map MXNet's Clip operator attributes to onnx's Clip operator
+    and return the created node.
+    """
+    helper, _, _ = import_onnx_modules()
+    name = node["name"]
+    input_idx = kwargs["index_lookup"][node["inputs"][0][0]]
+    proc_nodes = kwargs["proc_nodes"]
+    input_node = proc_nodes[input_idx].name
+    attrs = node["attrs"]
+    if 'a_max' not in attrs:
+        attrs['a_max'] = np.inf
+    if 'a_min' not in attrs:
+        attrs['a_min'] = -np.inf
+    a_min = float(attrs["a_min"])
 
 Review comment:
   Thanks @anirudhacharya. I was planning to change it to 
   
   `a_min = float(attrs["a_min"]) if "a_min" in attrs else -np.inf`
   
   But I think I'll go ahead with your suggestion.

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


With regards,
Apache Git Services