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

Commit

Permalink
recover original Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
haojin2 committed Oct 29, 2019
1 parent 2a7094a commit 7d82ee3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ endif
# be JIT-compiled by the updated driver from the included PTX.
ifeq ($(USE_CUDA), 1)
ifeq ($(CUDA_ARCH),)
KNOWN_CUDA_ARCHS := 52
KNOWN_CUDA_ARCHS := 30 35 50 52 60 61 70 75
# Run nvcc on a zero-length file to check architecture-level support.
# Create args to include SASS in the fat binary for supported levels.
CUDA_ARCH := $(foreach arch,$(KNOWN_CUDA_ARCHS), \
Expand Down
21 changes: 12 additions & 9 deletions tests/python/unittest/test_numpy_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# pylint: skip-file
from __future__ import absolute_import
from __future__ import division
import itertools
import os
import unittest
import numpy as _np
Expand Down Expand Up @@ -475,9 +476,6 @@ def test_np_grad_ndarray_type():
@with_seed()
@use_np
def test_np_ndarray_astype():
mx_data = np.array([2, 3, 4, 5], dtype=_np.int32)
np_data = mx_data.asnumpy()

class TestAstype(HybridBlock):
def __init__(self, dtype, copy):
super(TestAstype, self).__init__()
Expand All @@ -487,24 +485,29 @@ def __init__(self, dtype, copy):
def hybrid_forward(self, F, x):
return x.astype(dtype=self._dtype, copy=self._copy)

def check_astype_equal(dtype, copy, expect_zero_copy=False, hybridize=False):
test_astype = TestAstype(dtype, copy)
def check_astype_equal(itype, otype, copy, expect_zero_copy=False, hybridize=False):
expect_zero_copy = copy is False and itype == otype
mx_data = np.array([2, 3, 4, 5], dtype=itype)
np_data = mx_data.asnumpy()
test_astype = TestAstype(otype, copy)
if hybridize:
test_astype.hybridize()
mx_ret = test_astype(mx_data)
assert type(mx_ret) is np.ndarray
np_ret = np_data.astype(dtype=dtype, copy=copy)
np_ret = np_data.astype(dtype=otype, copy=copy)
assert mx_ret.dtype == np_ret.dtype
assert same(mx_ret.asnumpy(), np_ret)
if expect_zero_copy and not hybridize:
assert id(mx_ret) == id(mx_data)
assert id(np_ret) == id(np_data)

for dtype in [np.int8, np.uint8, np.int32, np.float16, np.float32, np.float64, np.bool, np.bool_,
'int8', 'uint8', 'int32', 'float16', 'float32', 'float64', 'bool']:
dtypes = [np.int8, np.uint8, np.int32, np.float16, np.float32, np.float64, np.bool, np.bool_,
'int8', 'uint8', 'int32', 'float16', 'float32', 'float64', 'bool']

for itype, otype in itertools.product(dtypes, dtypes):
for copy in [True, False]:
for hybridize in [True, False]:
check_astype_equal(dtype, copy, copy is False and mx_data.dtype == dtype, hybridize)
check_astype_equal(itype, otype, copy, hybridize)


@with_seed()
Expand Down

0 comments on commit 7d82ee3

Please sign in to comment.