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/06/01 19:22:33 UTC

[GitHub] anirudhacharya commented on a change in pull request #10605: [MXNET-310] [ONNX-MXNet] API to import ONNX models into Gluon.

anirudhacharya commented on a change in pull request #10605: [MXNET-310] [ONNX-MXNet] API to import ONNX models into Gluon.
URL: https://github.com/apache/incubator-mxnet/pull/10605#discussion_r192492519
 
 

 ##########
 File path: tests/python-pytest/onnx/import/gluon_backend_test.py
 ##########
 @@ -0,0 +1,55 @@
+# 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.
+
+"""ONNX test backend wrapper"""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
+import unittest
+try:
+    import onnx.backend.test
+except ImportError:
+    raise ImportError("Onnx and protobuf need to be installed. Instructions to"
+                      + " install - https://github.com/onnx/onnx#installation")
+
+import gluon_backend
+import test_cases
+
+# This is a pytest magic variable to load extra plugins
+pytest_plugins = "onnx.backend.test.report",
+
+BACKEND_TESTS = onnx.backend.test.BackendTest(gluon_backend, __name__)
+
+for op_tests in test_cases.IMPLEMENTED_OPERATORS_TEST:
+    BACKEND_TESTS.include(op_tests)
+
+for std_model_test in test_cases.STANDARD_MODEL:
+    BACKEND_TESTS.include(std_model_test)
+
+for basic_model_test in test_cases.BASIC_MODEL_TESTS:
+    BACKEND_TESTS.include(basic_model_test)
+
+BACKEND_TESTS.exclude('.*broadcast.*')
+BACKEND_TESTS.exclude('.*bcast.*')
 
 Review comment:
   Because there is an issue with the way broadcast operator tests are written in ONNX. 
   
   For example, if we try to broadcast (5,) dim array on (3,4,5) dim array then mxnet's forward pass will fail because the mxnet's interface expects the same batch size on the two arrays, i.e. (1,5) and (1,3,4,5)
   
   So 
   ```
   x = mx.nd.array(np.random.rand(3,4,5))
   y = mx.nd.array(np.random.rand(5,))
   mx.nd.broadcast_add(x,y)
   ```
   will pass, but the following will fail
   ```
   xvar = mx.sym.var('x')
   yvar = mx.sym.var('y')
   bcast_add = mx.sym.broadcast_add(xvar, yvar)
   ```
   
   There are broadcast operators in the various models that are being tested and they work fine, as the data in such models come with a valid batch_size.

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