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 17:54:24 UTC

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

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

 ##########
 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"])
+    a_max = float(attrs["a_max"])
 
 Review comment:
   remove the if statement above and replace this line with -
   ```python
   a_max = np.float(attrs.get('a_max', np.inf))
   ```

----------------------------------------------------------------
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