Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
add unittest for gluon mkldnn ndarray slice computation
Browse files Browse the repository at this point in the history
  • Loading branch information
ashokei authored and piiswrong committed Apr 26, 2018
1 parent f3f2733 commit f236687
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/python/mkl/test_mkldnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import logging
import os
from sys import platform
import numpy as np
from mxnet.test_utils import assert_almost_equal


def test_mkldnn_install():
Expand Down Expand Up @@ -90,5 +92,23 @@ def get_tensors(args, shapes, ctx):
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()

0 comments on commit f236687

Please sign in to comment.