From 8af7685f5e5f5f383ca4c35e12a780204a27181b Mon Sep 17 00:00:00 2001 From: Yizhi Liu Date: Wed, 14 Aug 2019 16:24:20 +0800 Subject: [PATCH] enable tvm_op for ci --- Makefile | 6 +++--- ci/docker/install/ubuntu_python.sh | 2 +- ci/docker/runtime_functions.sh | 12 ++++++++++++ tests/python/unittest/test_tvm_op.py | 15 +++++++-------- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index a14c29452f6e..bb66d33d3e05 100644 --- a/Makefile +++ b/Makefile @@ -617,14 +617,14 @@ lib/libtvm_runtime.so: cmake -DUSE_LLVM="$(LLVM_PATH)/bin/llvm-config" \ -DUSE_SORT=OFF -DUSE_CUDA=$(TVM_USE_CUDA) -DUSE_CUDNN=OFF ..; \ $(MAKE) VERBOSE=1; \ - cp $(TVM_PATH)/build/libtvm_runtime.so $(ROOTDIR)/lib/libtvm_runtime.so; \ + cp $(TVM_PATH)/build/libtvm_runtime.so lib/libtvm_runtime.so; \ cd $(ROOTDIR) lib/libtvmop.so: lib/libtvm_runtime.so $(wildcard contrib/tvmop/*/*.py contrib/tvmop/*.py) echo "Compile TVM operators" - PYTHONPATH=$(TVM_PATH)/python:$(TVM_PATH)/topi/python:$(ROOTDIR)/contrib:$PYTHONPATH \ + PYTHONPATH=$(TVM_PATH)/python:$(TVM_PATH)/topi/python:$(ROOTDIR)/contrib \ LD_LIBRARY_PATH=lib \ - python3 $(ROOTDIR)/contrib/tvmop/compile.py -o $(ROOTDIR)/lib/libtvmop.so + python3 $(ROOTDIR)/contrib/tvmop/compile.py -o lib/libtvmop.so endif NNVM_INC = $(wildcard $(NNVM_PATH)/include/*/*.h) diff --git a/ci/docker/install/ubuntu_python.sh b/ci/docker/install/ubuntu_python.sh index 2ca0cceec515..b8626d3037d5 100755 --- a/ci/docker/install/ubuntu_python.sh +++ b/ci/docker/install/ubuntu_python.sh @@ -31,4 +31,4 @@ python3 get-pip.py python2 get-pip.py pip2 install nose cpplint==1.3.0 'numpy>1.16.0,<2.0.0' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3 Cython==0.29.7 -pip3 install nose cpplint==1.3.0 pylint==2.3.1 'numpy>1.16.0,<2.0.0' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3 Cython==0.29.7 +pip3 install nose cpplint==1.3.0 pylint==2.3.1 'numpy>1.16.0,<2.0.0' nose-timer 'requests<2.19.0,>=2.18.4' h5py==2.8.0rc1 scipy==1.0.1 boto3 Cython==0.29.7 decorator diff --git a/ci/docker/runtime_functions.sh b/ci/docker/runtime_functions.sh index 2518f4c7c64f..58fb350c68c5 100755 --- a/ci/docker/runtime_functions.sh +++ b/ci/docker/runtime_functions.sh @@ -374,6 +374,7 @@ build_ubuntu_cpu_openblas() { build_ccache_wrappers make \ DEV=1 \ + USE_TVM_OP=1 \ ENABLE_TESTCOVERAGE=1 \ USE_CPP_PACKAGE=1 \ USE_BLAS=openblas \ @@ -395,6 +396,7 @@ build_ubuntu_cpu_mkl() { ENABLE_TESTCOVERAGE=1 \ USE_CPP_PACKAGE=1 \ USE_BLAS=mkl \ + USE_TVM_OP=1 \ USE_MKLDNN=0 \ USE_INTEL_PATH=/opt/intel \ USE_DIST_KVSTORE=1 \ @@ -412,6 +414,7 @@ build_ubuntu_cpu_cmake_debug() { -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DENABLE_TESTCOVERAGE=ON \ -DUSE_CUDA=OFF \ + -DUSE_TVM_OP=ON \ -DUSE_MKL_IF_AVAILABLE=OFF \ -DUSE_OPENMP=OFF \ -DUSE_OPENCV=ON \ @@ -559,6 +562,7 @@ build_ubuntu_cpu_mkldnn() { DEV=1 \ ENABLE_TESTCOVERAGE=1 \ USE_CPP_PACKAGE=1 \ + USE_TVM_OP=1 \ USE_BLAS=openblas \ USE_SIGNAL_HANDLER=1 \ -j$(nproc) @@ -573,6 +577,7 @@ build_ubuntu_cpu_mkldnn_mkl() { DEV=1 \ ENABLE_TESTCOVERAGE=1 \ USE_CPP_PACKAGE=1 \ + USE_TVM_OP=1 \ USE_BLAS=mkl \ USE_SIGNAL_HANDLER=1 \ -j$(nproc) @@ -657,6 +662,7 @@ build_ubuntu_gpu_mkldnn() { USE_CUDA=1 \ USE_CUDA_PATH=/usr/local/cuda \ USE_CUDNN=1 \ + USE_TVM_OP=1 \ CUDA_ARCH="$CI_CUDA_COMPUTE_CAPABILITIES" \ USE_SIGNAL_HANDLER=1 \ -j$(nproc) @@ -674,6 +680,7 @@ build_ubuntu_gpu_mkldnn_nocudnn() { USE_CUDA=1 \ USE_CUDA_PATH=/usr/local/cuda \ USE_CUDNN=0 \ + USE_TVM_OP=1 \ CUDA_ARCH="$CI_CUDA_COMPUTE_CAPABILITIES" \ USE_SIGNAL_HANDLER=1 \ -j$(nproc) @@ -690,6 +697,7 @@ build_ubuntu_gpu_cuda101_cudnn7() { USE_CUDA=1 \ USE_CUDA_PATH=/usr/local/cuda \ USE_CUDNN=1 \ + USE_TVM_OP=1 \ USE_CPP_PACKAGE=1 \ USE_DIST_KVSTORE=1 \ CUDA_ARCH="$CI_CUDA_COMPUTE_CAPABILITIES" \ @@ -733,6 +741,7 @@ build_ubuntu_gpu_cmake_mkldnn() { -DENABLE_TESTCOVERAGE=ON \ -DUSE_CUDA=1 \ -DUSE_CUDNN=1 \ + -DUSE_TVM_OP=1 \ -DUSE_MKLML_MKL=1 \ -DCMAKE_BUILD_TYPE=Release \ -DCUDA_ARCH_NAME=Manual \ @@ -758,6 +767,7 @@ build_ubuntu_gpu_cmake() { -DENABLE_TESTCOVERAGE=ON \ -DUSE_CUDA=ON \ -DUSE_CUDNN=ON \ + -DUSE_TVM_OP=ON \ -DUSE_MKL_IF_AVAILABLE=OFF \ -DUSE_MKLML_MKL=OFF \ -DUSE_MKLDNN=OFF \ @@ -784,6 +794,7 @@ build_ubuntu_cpu_large_tensor() { -DENABLE_TESTCOVERAGE=ON \ -DUSE_CUDA=OFF \ -DUSE_CUDNN=OFF \ + -DUSE_TVM_OP=ON \ -DUSE_MKLDNN=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DUSE_INT64_TENSOR_SIZE=ON \ @@ -805,6 +816,7 @@ build_ubuntu_gpu_large_tensor() { -DENABLE_TESTCOVERAGE=ON \ -DUSE_CUDA=ON \ -DUSE_CUDNN=ON \ + -DUSE_TVM_OP=ON \ -DUSE_MKL_IF_AVAILABLE=OFF \ -DUSE_MKLML_MKL=OFF \ -DUSE_MKLDNN=OFF \ diff --git a/tests/python/unittest/test_tvm_op.py b/tests/python/unittest/test_tvm_op.py index 3ab2a25bc20e..cb007f416b11 100644 --- a/tests/python/unittest/test_tvm_op.py +++ b/tests/python/unittest/test_tvm_op.py @@ -24,14 +24,13 @@ @with_seed() def test_tvm_broadcast_add(): - if _features.is_enabled("TVM_OP"): - a_shape = rand_shape_nd(4) - b_shape = (1,) + a_shape[1:2] + (1, 1) - a = mx.nd.normal(shape=a_shape) - b = mx.nd.normal(shape=b_shape) - c = mx.nd.contrib.tvm_vadd(a, b) - c_np = a.asnumpy() + b.asnumpy() - assert same(c.asnumpy(), c_np) + a_shape = rand_shape_nd(4) + b_shape = (1,) + a_shape[1:2] + (1, 1) + a = mx.nd.normal(shape=a_shape) + b = mx.nd.normal(shape=b_shape) + c = mx.nd.contrib.tvm_vadd(a, b) + c_np = a.asnumpy() + b.asnumpy() + assert same(c.asnumpy(), c_np) if __name__ == '__main__': import nose