Skip to content

Commit

Permalink
fixed seed for mkldnn test (apache#17386)
Browse files Browse the repository at this point in the history
* fix seed for mkldnn test

* use fixed seed for mkldnn test
  • Loading branch information
heaseny authored and leezu committed Jan 25, 2020
1 parent d9ad61d commit cba4a53
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/python/mkl/test_mkldnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def get_tensors(args, shapes, ctx):
except: # pylint: disable=bare-except
assert 0, "test_mkldnn_model exception in bind and execution"

@with_seed(1234)
def test_mkldnn_ndarray_slice():
ctx = mx.cpu()
net = gluon.nn.HybridSequential()
Expand All @@ -71,8 +72,9 @@ def test_mkldnn_ndarray_slice():
y = net(x)

# trigger computation on ndarray slice
assert_almost_equal(y[0].asnumpy()[0, 0, 0], np.array(0.3376348))
assert_almost_equal(y[0].asnumpy()[0, 0, 0], np.array(0.056331709))

@with_seed(1234)
def test_mkldnn_engine_threading():
net = gluon.nn.HybridSequential()
with net.name_scope():
Expand All @@ -94,8 +96,8 @@ def __getitem__(self, key):
# below line triggers different execution thread
for _ in loader:
y = net(mx.nd.array(np.ones(X))).asnumpy()
# output should be 016711406 (non-mkldnn mode output)
assert_almost_equal(y[0, 0, 0, 0], np.array(0.016711406))
# output should be 056331709 (non-mkldnn mode output)
assert_almost_equal(y[0, 0, 0, 0], np.array(0.056331709))
break

@with_seed()
Expand Down

0 comments on commit cba4a53

Please sign in to comment.