[GitHub] anirudhacharya commented on a change in pull request #11213: [MXNET-533] MXNet-ONNX export

2018-06-28 Thread GitBox
anirudhacharya commented on a change in pull request #11213: [MXNET-533] 
MXNet-ONNX export
URL: https://github.com/apache/incubator-mxnet/pull/11213#discussion_r198989213
 
 

 ##
 File path: tests/python-pytest/onnx/export/backend.py
 ##
 @@ -0,0 +1,98 @@
+# Licensed to the Apache Software Foundation (ASF) under one
 
 Review comment:
   in the future if there is another component that is built into MXNet that 
uses pytest instead of nosetests, then what will we do?
   
   the point of naming it python-pytest is separate them from the other tests 
which uses nosetests framework? 
   
   And this naming was part of a previous PR 
https://github.com/apache/incubator-mxnet/pull/9963 and was suggested by 
@marcoabreu during the review process.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] anirudhacharya commented on a change in pull request #11213: [MXNET-533] MXNet-ONNX export

2018-06-12 Thread GitBox
anirudhacharya commented on a change in pull request #11213: [MXNET-533] 
MXNet-ONNX export
URL: https://github.com/apache/incubator-mxnet/pull/11213#discussion_r194879799
 
 

 ##
 File path: python/mxnet/contrib/onnx/__init__.py
 ##
 @@ -18,3 +18,4 @@
 
 from ._import.import_model import import_model, get_model_metadata
 
 Review comment:
   ``import`` is a reserved keyword, we cant have a folder called import. we 
can probably rename the two folders to onnx_import and onnx_export and make its 
member files private, except for the modules that we are exposing to the user.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] anirudhacharya commented on a change in pull request #11213: [MXNET-533] MXNet-ONNX export

2018-06-11 Thread GitBox
anirudhacharya commented on a change in pull request #11213: [MXNET-533] 
MXNet-ONNX export
URL: https://github.com/apache/incubator-mxnet/pull/11213#discussion_r194521430
 
 

 ##
 File path: python/mxnet/contrib/onnx/_export/export_onnx.py
 ##
 @@ -0,0 +1,267 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# Based on
+# 
https://github.com/NVIDIA/mxnet_to_onnx/blob/master/mx2onnx_converter/mx2onnx_converter.py#
+#  Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#  * Redistributions of source code must retain the above copyright
+#notice, this list of conditions and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+#  * Neither the name of NVIDIA CORPORATION nor the names of its
+#contributors may be used to endorse or promote products derived
+#from this software without specific prior written permission.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+#  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+#  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+#  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+#  OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# coding: utf-8
+# pylint: disable=invalid-name,too-many-locals,no-self-use,too-many-arguments,
+# pylint: disable=maybe-no-member,too-many-nested-blocks
+"""MXNet to ONNX graph converter functions"""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
+import json
+import numpy as np
+
+from onnx import (checker, helper, onnx_pb2)
+from onnx.helper import make_tensor_value_info
+
+from  import context
+from  import ndarray as nd
+from  import io
+from  import module as mod
+
+
+class MXNetGraph(object):
+"""Class to convert MXNet to ONNX graph"""
+registry_ = {}
+input_output_maps_ = {}
+
+def __init__(self):
+# topologically sorted nodes
+self.nodes = []
+self.input_tensors = []
+self.output_tensors = []
+
+@staticmethod
+def register(op_name):
+"""Register operator"""
+def wrapper(func):
+"""Helper function to map functions"""
+MXNetGraph.registry_[op_name] = func
+return func
+
+return wrapper
+
+@staticmethod
+def convert_layer(node, **kwargs):
+"""Convert MXNet layer to ONNX"""
+op = str(node["op"])
+if op not in MXNetGraph.registry_:
+raise AttributeError("No conversion function registered for op 
type %s yet." % op)
+convert_fun = MXNetGraph.registry_[op]
 
 Review comment:
   change the name to convert_func


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:
us...@infra.apache.org


With regards,
Apache Git Services