You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by jx...@apache.org on 2018/04/26 23:00:31 UTC

[incubator-mxnet] 02/02: add unittest for gluon mkldnn ndarray slice computation

This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit f236687cbb146c792c576d8467ff45f643860f19
Author: Ashok Emani <as...@intel.com>
AuthorDate: Wed Apr 25 13:47:37 2018 -0700

    add unittest for gluon mkldnn ndarray slice computation
---
 tests/python/mkl/test_mkldnn.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/python/mkl/test_mkldnn.py b/tests/python/mkl/test_mkldnn.py
index a4c9c45..5a621b0 100644
--- a/tests/python/mkl/test_mkldnn.py
+++ b/tests/python/mkl/test_mkldnn.py
@@ -22,6 +22,8 @@ MKL-DNN related test cases
 import logging
 import os
 from sys import platform
+import numpy as np
+from mxnet.test_utils import assert_almost_equal
 
 
 def test_mkldnn_install():
@@ -90,5 +92,23 @@ def test_mkldnn_model():
         assert 0, "test_mkldnn_model exception in bind and execution"
 
 
+def test_mkldnn_ndarray_slice():
+    """
+    This test will trigger gluon computation on mkldnn with ndarray slice
+    """
+
+    import mxnet as mx
+    from mxnet import gluon
+    ctx = mx.cpu()
+    net = gluon.nn.HybridSequential()
+    with net.name_scope():
+        net.add(gluon.nn.Conv2D(channels=32, kernel_size=3, activation=None))
+        net.collect_params().initialize(ctx=ctx)
+        x = mx.nd.array(np.ones([32, 3, 224, 224]), ctx)
+        y = net(x)
+
+        # trigger computation on ndarray slice
+        assert_almost_equal(y[0].asnumpy()[0,0,0], 0.3376348)
+
 if __name__ == '__main__':
     test_mkldnn_install()

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.