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/05/15 03:52:14 UTC

[GitHub] juliusshufan commented on a change in pull request #10921: Test cases improvement for MKLDNN on Gluon

juliusshufan commented on a change in pull request #10921: Test cases improvement for MKLDNN on Gluon
URL: https://github.com/apache/incubator-mxnet/pull/10921#discussion_r188159032
 
 

 ##########
 File path: tests/python/mkl/test_mkldnn.py
 ##########
 @@ -95,122 +110,1147 @@ def __getitem__(self, key):
         assert_almost_equal(y[0, 0, 0, 0], 0.016711406)
         break
 
+def test_mkldnn_sum_inplace_with_cpu_layout():
+
+    x_shape = (32, 3, 224, 224)
+    x_npy = np.ones(x_shape)
+    y_shape = (32, 32, 222, 222)
+    y_npy = np.ones(y_shape)
+    x = mx.sym.Variable("x")
+    y = mx.sym.Variable("y")
+    z = mx.symbol.Convolution(data=x, num_filter=32, kernel=(3, 3))
+    z = mx.sym.add_n(z, y)
+    exe = z.simple_bind(ctx=mx.cpu(), x=x_shape, y=y_shape)
+    out = exe.forward(is_train=False, x=x_npy, y=y_npy)[0]
+    assert_almost_equal(out[0].asnumpy()[0, 0, 0], 1.0)
+
+@with_seed()
+def test_conv2d_mkldnn():
+    chn_list = [16, 32, 64, 128, 256, 512, 1024]
+    kernel_list = np.random.randint(low=1, high=224, size=9).tolist()
+    kernel_list.append(224)
+    batch_size = 32
+    class Net(gluon.HybridBlock):
+        def __init__(self,
+                     chn_num,
+                     kernel,
+                     **kwargs):
+            super(Net, self).__init__(**kwargs)
+            with self.name_scope():
+                self.conv0 = gluon.nn.Conv2D(chn_num, (kernel, kernel))
+
+        def hybrid_forward(self, F, x):
+            out = self.conv0(x)
+            return out
+
+    x = mx.nd.random.uniform(-1.0, 1.0, shape=(batch_size, 3, 224, 224))
+    for i in range(len(chn_list)):
+        for j in range(len(kernel_list)):
+            net = Net(chn_list[i], kernel_list[j])
+            check_layer_forward(net, x)
 
 Review comment:
   @zheng-da this is a kind of data coverage test cases, specifically covering the 16X channel and different spatial size from 1 to 299(these sizes normally used with cnn networks on imagenet), the existing conv2d cases not covering the 16x channel and diversified spatial size. Thanks.

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