Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 11bc95d

Browse files
committedSep 5, 2019
change docker install script
update test script to use pytest instead of nose fix mybfloat16 do save fix test fix test
1 parent 66235d1 commit 11bc95d

38 files changed

+134
-184
lines changed
 

‎conda/tvm/meta.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ test:
5050
- topi
5151
- nnvm
5252
requires:
53-
- nose
53+
- pytest
5454
- scipy
5555
source_files:
5656
- tests/python
5757
commands:
58-
- python -m nose -v tests/python/integration
58+
- python -m pytest -v tests/python/integration
5959

6060
about:
6161
home: https://github.com/dmlc/tvm

‎docker/Dockerfile.conda_cpu

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-lat
3030
# Cache some of the packages for the builds
3131
RUN /opt/conda/bin/conda install --download-only cmake make zlib && \
3232
/opt/conda/bin/conda install --download-only -c numba llvmdev=8.0.0 && \
33-
/opt/conda/bin/conda create -n py35 --download-only nose scipy numpy=1.11 cython decorator python=3.5 && \
34-
/opt/conda/bin/conda create -n py36 --download-only nose scipy numpy=1.11 cython decorator python=3.6 && \
35-
/opt/conda/bin/conda create -n py37 --download-only nose scipy numpy=1.11 cython decorator python=3.7
33+
/opt/conda/bin/conda create -n py35 --download-only pytest scipy numpy=1.11 cython decorator python=3.5 && \
34+
/opt/conda/bin/conda create -n py36 --download-only pytest scipy numpy=1.11 cython decorator python=3.6 && \
35+
/opt/conda/bin/conda create -n py37 --download-only pytest scipy numpy=1.11 cython decorator python=3.7
3636

3737
ENV PATH /opt/conda/bin:$PATH
3838
ENV CONDA_BLD_PATH /tmp

‎docker/Dockerfile.demo_cpu

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RUN bash /install/ubuntu_install_core.sh
2626

2727
# Python: basic dependencies
2828
RUN apt-get update && apt-get install -y python3-dev python3-pip
29-
RUN pip3 install numpy nose-timer cython decorator scipy
29+
RUN pip3 install numpy pytest cython decorator scipy
3030

3131
# LLVM
3232
RUN echo deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main \

‎docker/Dockerfile.demo_gpu

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RUN bash /install/ubuntu_install_core.sh
2626

2727
# Python: basic dependencies
2828
RUN apt-get update && apt-get install -y python3-dev python3-pip
29-
RUN pip3 install numpy nose-timer cython decorator scipy
29+
RUN pip3 install numpy pytest cython decorator scipy
3030

3131
# LLVM
3232
RUN echo deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main \

‎docker/Dockerfile.demo_opencl

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ RUN apt-get install -y libopenblas-dev
4242

4343
RUN echo "Installing Python"
4444
RUN apt-get install -y python3-dev python3-pip
45-
RUN pip3 install setuptools numpy nose-timer cython decorator scipy tornado psutil xgboost
45+
RUN pip3 install setuptools numpy pytest cython decorator scipy tornado psutil xgboost
4646

4747
RUN echo "Installing Jupyter notebook"
4848
RUN pip3 install matplotlib Image Pillow jupyter[notebook]

‎docker/install/ubuntu_install_python_package.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
# to you under the Apache License, Version 2.0 (the
77
# "License"); you may not use this file except in compliance
88
# with the License. You may obtain a copy of the License at
9-
#
9+
#
1010
# http://www.apache.org/licenses/LICENSE-2.0
11-
#
11+
#
1212
# Unless required by applicable law or agreed to in writing,
1313
# software distributed under the License is distributed on an
1414
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -21,5 +21,4 @@ set -u
2121
set -o pipefail
2222

2323
# install libraries for python package on ubuntu
24-
pip2 install nose pylint==1.9.4 six numpy nose-timer cython decorator scipy tornado typing antlr4-python2-runtime attrs packaging
25-
pip3 install nose pylint==1.9.4 six numpy nose-timer cython decorator scipy tornado typed_ast pytest mypy orderedset antlr4-python3-runtime attrs requests Pillow packaging
24+
pip3 install pylint==1.9.4 six numpy pytest cython decorator scipy tornado typed_ast pytest mypy orderedset antlr4-python3-runtime attrs requests Pillow packaging

‎docs/contribute/pull_request.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Necessary dependencies:
9696

9797
.. code:: bash
9898
99-
pip install --user nose Cython
99+
pip install --user pytest Cython
100100
101101
If you want to run all tests:
102102

@@ -118,4 +118,4 @@ If you want to run a single test:
118118
export PYTHONPATH=python:topi/python
119119
rm -rf python/tvm/*.pyc python/tvm/*/*.pyc python/tvm/*/*/*.pyc
120120
121-
TVM_FFI=ctypes python -m nose -v tests/python/unittest/test_pass_storage_rewrite.py
121+
TVM_FFI=ctypes python -m pytest -v tests/python/unittest/test_pass_storage_rewrite.py

‎nnvm/tests/python/frontend/mxnet/test_forward.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
def verify_mxnet_frontend_impl(mx_symbol, data_shape=(1, 3, 224, 224), out_shape=(1, 1000),
3333
gluon_impl=False, name=None, dtype='float32'):
34-
"""Use name different from test to avoid let nose pick it up"""
34+
"""Use name different from test to avoid pytest picking it up"""
3535
if gluon_impl:
3636
def get_gluon_output(name, x):
3737
net = vision.get_model(name)

‎tests/python/contrib/test_mxnet_bridge.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
def mxnet_check():
1818
"""This is a simple test function for MXNet bridge
1919
20-
It is not included as nosetests, because of its dependency on mxnet
20+
It is not included as pytests, because of its dependency on mxnet
2121
2222
User can directly run this script to verify correctness.
2323
"""

‎tests/python/contrib/test_nnpack.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import numpy as np
1919
import scipy.signal
2020
from tvm.contrib import nnpack
21-
from nose import SkipTest
21+
import pytest
2222

2323

2424
def test_fully_connected_inference():
@@ -34,11 +34,11 @@ def test_fully_connected_inference():
3434

3535
def verify(target="llvm"):
3636
if not tvm.module.enabled(target):
37-
raise SkipTest("skip because %s is not enabled..." % target)
37+
pytest.skip("%s is not enabled..." % target)
3838
if not tvm.get_global_func("tvm.contrib.nnpack.fully_connected_inference", True):
39-
raise SkipTest("skip because extern function is not available")
39+
pytest.skip("extern function is not available")
4040
if not nnpack.is_available():
41-
raise SkipTest("skip because nnpack is not available")
41+
pytest.skip("nnpack is not available")
4242

4343
ctx = tvm.cpu(0)
4444
f = tvm.build(s, [A, B, D, bias], target)
@@ -112,11 +112,11 @@ def verify(target="llvm",
112112
algorithm=nnpack.ConvolutionAlgorithm.AUTO,
113113
with_bias=True):
114114
if not tvm.module.enabled(target):
115-
raise SkipTest("skip because %s is not enabled..." % target)
115+
pytest.skip("%s is not enabled..." % target)
116116
if not tvm.get_global_func("tvm.contrib.nnpack.fully_connected_inference", True):
117-
raise SkipTest("skip because extern function is not available")
117+
pytest.skip("extern function is not available")
118118
if not nnpack.is_available():
119-
raise SkipTest("skip because nnpack is not available")
119+
pytest.skip("nnpack is not available")
120120

121121
ctx = tvm.cpu(0)
122122
output = nnpack.convolution_inference(
@@ -174,11 +174,11 @@ def verify(target="llvm",
174174
algorithm=nnpack.ConvolutionAlgorithm.AUTO,
175175
with_bias=True):
176176
if not tvm.module.enabled(target):
177-
raise SkipTest("skip because %s is not enabled..." % target)
177+
pytest.skip("%s is not enabled..." % target)
178178
if not tvm.get_global_func("tvm.contrib.nnpack.fully_connected_inference", True):
179-
raise SkipTest("skip because extern function is not available")
179+
pytest.skip("extern function is not available")
180180
if not nnpack.is_available():
181-
raise SkipTest("skip because nnpack is not available")
181+
pytest.skip("nnpack is not available")
182182

183183
ctx = tvm.cpu(0)
184184
transformed_kernel = nnpack.convolution_inference_weight_transform(
@@ -209,5 +209,4 @@ def verify(target="llvm",
209209

210210

211211
if __name__ == "__main__":
212-
import nose
213-
nose.runmodule()
212+
pytest.main()

‎tests/python/contrib/test_rpc_proxy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
def rpc_proxy_check():
2525
"""This is a simple test function for RPC Proxy
2626
27-
It is not included as nosetests, because:
27+
It is not included as pytests, because:
2828
- It depends on tornado
2929
- It relies on the fact that Proxy starts before client and server connects,
3030
which is often the case but not always

‎tests/python/frontend/mxnet/test_forward.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def verify_mxnet_frontend_impl(mx_symbol,
3434
gluon_impl=False,
3535
name=None,
3636
dtype='float32'):
37-
"""Use name different from test to avoid let nose pick it up"""
37+
"""Use name different from test to avoid pytest picking it up"""
3838
if gluon_impl:
3939
def get_gluon_output(name, x):
4040
net = vision.get_model(name)

‎tests/python/integration/test_winograd_nnpack.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import topi
2424
import topi.testing
2525
from topi.util import get_const_tuple
26-
from nose import SkipTest
26+
from pytest import skip
2727

2828

2929
def verify_conv2d_nchw(batch, in_channel, in_size, num_filter, kernel, stride, padding, dilation=1, add_bias=False, add_relu=False,
@@ -60,7 +60,7 @@ def get_ref_data():
6060
def check_device(device):
6161
ctx = tvm.context(device, 0)
6262
if not ctx.exist:
63-
raise SkipTest("Skip because %s is not enabled" % device)
63+
skip("s is not enabled" % device)
6464
print("Running on target: %s" % device)
6565
with tvm.target.create(device):
6666
C = topi.nn.conv2d(A, W, stride, padding, dilation, layout='NCHW', out_dtype=dtype)
@@ -99,10 +99,10 @@ def _query_inside(self, target, workload):
9999

100100
def test_conv2d_nchw():
101101
if not tvm.get_global_func("tvm.contrib.nnpack.convolution_inference_without_weight_transform", True):
102-
raise SkipTest("skip because extern function is not available")
102+
skip("extern function is not available")
103103

104104
if not nnpack.is_available():
105-
raise SkipTest("skip because nnpack is not available")
105+
skip("nnpack is not available")
106106

107107
devices = ['llvm -device=arm_cpu']
108108
autotvm.DispatchContext.current.silent = True
@@ -139,5 +139,5 @@ def test_conv2d_nchw():
139139

140140

141141
if __name__ == "__main__":
142-
import nose
143-
nose.runmodule()
142+
import pytest
143+
pytest.main()

‎tests/python/relay/test_ir_parser.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
import tvm
1818
from tvm import relay
1919
from tvm.relay.analysis import alpha_equal, assert_alpha_equal
20-
from nose.tools import nottest, raises
20+
import pytest
2121
from numpy import isclose
2222
from typing import Union
2323
from functools import wraps
24-
raises_parse_error = raises(tvm._ffi.base.TVMError)
24+
raises_parse_error = pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
2525

2626
SEMVER = "v0.0.3"
2727

@@ -177,7 +177,7 @@ def test_op_assoc():
177177
assert alpha_equal(parse_text("1 == 1 < 1 + 1 * 1"), parse_text("1 == (1 < (1 + (1 * 1)))"))
178178

179179

180-
@nottest
180+
@pytest.mark.skip
181181
def test_vars():
182182
# temp vars won't work b/c they start with a digit
183183
# # temp var
@@ -529,11 +529,6 @@ def test_builtin_types():
529529
parse_text("let %_ : {} = (); ()".format(builtin_type))
530530

531531

532-
@nottest
533-
def test_call_type():
534-
assert False
535-
536-
537532
def test_tensor_type():
538533
assert parses_as(
539534
"let %_ : Tensor[(), float32] = (); ()",

‎tests/python/relay/test_op_level3.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
""" Support level3 operator test cases.
1818
"""
1919
import numpy as np
20-
from nose.tools import raises
20+
import pytest
2121
import tvm
2222
from tvm import relay
2323
from tvm.relay import create_executor, transform
@@ -220,8 +220,7 @@ def test_squeeze_infer_type():
220220
assert yy.checked_type == relay.TensorType(
221221
(4,), "float32")
222222

223-
224-
@raises(tvm._ffi.base.TVMError)
223+
@pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
225224
def test_squeeze_bad_axes_infer_type():
226225
n, t, d = 1, 4, 1
227226
x = relay.var("x", relay.TensorType((n, t, d), "float32"))

‎tests/python/relay/test_pass_check_kind.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
import tvm
1818
from tvm import relay
1919
from tvm.relay.analysis import check_kind
20-
from nose.tools import raises
21-
20+
import pytest
2221

2322
def test_typevar_kind():
2423
# returns the same kind
@@ -111,7 +110,7 @@ def test_typecall_kind():
111110
assert check_kind(call, new_mod) == relay.Kind.Type
112111

113112

114-
@raises(tvm._ffi.base.TVMError)
113+
@pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
115114
def test_invalid_tuple_kind():
116115
tp1 = relay.TypeVar('tp1', relay.Kind.Shape)
117116
tp2 = relay.TypeVar('tp2', relay.Kind.BaseType)
@@ -122,7 +121,7 @@ def test_invalid_tuple_kind():
122121
check_kind(tup_ty)
123122

124123

125-
@raises(tvm._ffi.base.TVMError)
124+
@pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
126125
def test_invalid_func_kind():
127126
tp1 = relay.TypeVar('tp1', relay.Kind.Shape)
128127
tp2 = relay.TypeVar('tp2', relay.Kind.BaseType)
@@ -137,14 +136,14 @@ def test_invalid_func_kind():
137136
check_kind(tf)
138137

139138

140-
@raises(tvm._ffi.base.TVMError)
139+
@pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
141140
def test_invalid_ref_kind():
142141
tp = relay.TypeVar('tp', relay.Kind.Shape)
143142
rt = relay.RefType(tp)
144143
check_kind(rt)
145144

146145

147-
@raises(tvm._ffi.base.TVMError)
146+
@pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
148147
def test_invalid_relation_kind():
149148
tp1 = relay.TypeVar('tp1', relay.Kind.Shape)
150149
tp2 = relay.TypeVar('tp2', relay.Kind.BaseType)
@@ -156,14 +155,14 @@ def test_invalid_relation_kind():
156155
check_kind(tr)
157156

158157

159-
@raises(tvm._ffi.base.TVMError)
158+
@pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
160159
def test_typecall_invalid_callee():
161160
# global type var must be an ADT handle
162161
gtv = relay.GlobalTypeVar('v1', relay.Kind.Type)
163162
check_kind(relay.TypeCall(gtv, []))
164163

165164

166-
@raises(tvm._ffi.base.TVMError)
165+
@pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
167166
def test_typecall_invalid_args():
168167
# args must all be type kind
169168
mod = relay.Module()
@@ -174,7 +173,7 @@ def test_typecall_invalid_args():
174173
check_kind(relay.TypeCall(gtv, [data]))
175174

176175

177-
@raises(tvm._ffi.base.TVMError)
176+
@pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
178177
def test_typecall_invalid_num_args():
179178
mod = relay.Module()
180179
gtv = relay.GlobalTypeVar('v1')
@@ -184,7 +183,7 @@ def test_typecall_invalid_num_args():
184183
check_kind(relay.TypeCall(gtv, []))
185184

186185

187-
@raises(tvm._ffi.base.TVMError)
186+
@pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
188187
def test_func_with_invalid_ret_type():
189188
tp1 = relay.TypeVar('tp1', relay.Kind.Type)
190189
tp2 = relay.TypeVar('tp2', relay.Kind.Shape)
@@ -193,7 +192,7 @@ def test_func_with_invalid_ret_type():
193192
check_kind(tf)
194193

195194

196-
@raises(tvm._ffi.base.TVMError)
195+
@pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
197196
def test_func_with_invalid_arg_types():
198197
tp1 = relay.TypeVar('tp1', relay.Kind.Shape)
199198
tp2 = relay.TypeVar('tp2', relay.Kind.Type)
@@ -202,7 +201,7 @@ def test_func_with_invalid_arg_types():
202201
check_kind(tf)
203202

204203

205-
@raises(tvm._ffi.base.TVMError)
204+
@pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
206205
def test_func_with_invalid_tuple():
207206
tp1 = relay.TypeVar('tp1', relay.Kind.Shape)
208207

@@ -212,7 +211,7 @@ def test_func_with_invalid_tuple():
212211
check_kind(tf)
213212

214213

215-
@raises(tvm._ffi.base.TVMError)
214+
@pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
216215
def test_func_with_invalid_relation():
217216
tp1 = relay.TypeVar('tp1', relay.Kind.Type)
218217
tp2 = relay.TypeVar('tp2', relay.Kind.Shape)
@@ -225,7 +224,7 @@ def test_func_with_invalid_relation():
225224
check_kind(tf)
226225

227226

228-
@raises(tvm._ffi.base.TVMError)
227+
@pytest.mark.xfail(raises=tvm._ffi.base.TVMError)
229228
def test_tuple_with_invalid_func():
230229
tensor_type = relay.TensorType(tvm.convert([1, 2, 3]), 'float32')
231230

There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.