marcoabreu commented on a change in pull request #9963: [MXNET-34] Onnx Module 
to import onnx models into mxnet
URL: https://github.com/apache/incubator-mxnet/pull/9963#discussion_r174191587
 
 

 ##########
 File path: tests/python-pytest/onnx/onnx_test.py
 ##########
 @@ -0,0 +1,138 @@
+# 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.
+
+"""
+Tests for individual operators
+This module contains operator tests which currently do not exist on
+ONNX backend test framework. Once we have PRs on the ONNX repo and get
+those PRs merged, this file will get EOL'ed.
+"""
+from __future__ import absolute_import
+import sys
+import os
+import unittest
+import logging
+import numpy as np
+import numpy.testing as npt
+from onnx import helper
+import backend as mxnet_backend
+CURR_PATH = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
+sys.path.insert(0, os.path.join(CURR_PATH, '../../python/unittest'))
+from common import with_seed
+
+# set up logger
+logging.basicConfig()
+LOGGER = logging.getLogger()
+LOGGER.setLevel(logging.INFO)
+
+@with_seed()
+def test_reduce_max():
+    """Test for ReduceMax operator"""
+    node_def = helper.make_node("ReduceMax", ["input1"], ["output"], axes=[1, 
0], keepdims=1)
+    input1 = np.random.ranf([3, 10]).astype("float32")
+    output = mxnet_backend.run_node(node_def, [input1])[0]
+    numpy_op = np.max(input1, axis=(1, 0), keepdims=True)
+    npt.assert_almost_equal(output, numpy_op)
+
+@with_seed()
+def test_reduce_mean():
+    """Test for ReduceMean operator"""
+    node_def = helper.make_node("ReduceMean", ["input1"], ["output"], axes=[1, 
0], keepdims=1)
+    input1 = np.random.ranf([3, 10]).astype("float32")
+    output = mxnet_backend.run_node(node_def, [input1])[0]
+    numpy_op = np.mean(input1, axis=(1, 0), keepdims=True)
+    npt.assert_almost_equal(output, numpy_op, decimal=5)
+
+@with_seed()
+def test_reduce_min():
+    """Test for ReduceMin operator"""
+    node_def = helper.make_node("ReduceMin", ["input1"], ["output"], axes=[1, 
0], keepdims=1)
+    input1 = np.random.ranf([3, 10]).astype("float32")
+    output = mxnet_backend.run_node(node_def, [input1])[0]
+    numpy_op = np.min(input1, axis=(1, 0), keepdims=True)
+    npt.assert_almost_equal(output, numpy_op)
+
+@with_seed()
+def test_reduce_sum():
+    """Test for ReduceSum operator"""
+    node_def = helper.make_node("ReduceSum", ["input1"], ["output"], axes=[1, 
0], keepdims=1)
+    input1 = np.random.ranf([3, 10]).astype("float32")
+    output = mxnet_backend.run_node(node_def, [input1])[0]
+    numpy_op = np.sum(input1, axis=(1, 0), keepdims=True)
+    npt.assert_almost_equal(output, numpy_op, decimal=5)
+
+@with_seed()
+def test_reduce_prod():
+    """Test for ReduceProd operator"""
+    node_def = helper.make_node("ReduceProd", ["input1"], ["output"], axes=[1, 
0], keepdims=1)
+    input1 = np.random.ranf([3, 10]).astype("float32")
+    output = mxnet_backend.run_node(node_def, [input1])[0]
+    numpy_op = np.prod(input1, axis=(1, 0), keepdims=True)
+    npt.assert_almost_equal(output, numpy_op, decimal=5)
+
+@with_seed()
+def test_squeeze():
+    """Test for Squeeze operator"""
+    node_def = helper.make_node("Squeeze", ["input1"], ["output"], axes=[1, 3])
+    input1 = np.random.ranf([3, 1, 2, 1, 4]).astype("float32")
+    output = mxnet_backend.run_node(node_def, [input1])[0]
+    npt.assert_almost_equal(output, np.squeeze(input1, axis=[1, 3]))
+
+def test_super_resolution():
 
 Review comment:
   test_super_resolution_example

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

Reply via email to