Commit 8b71a282 by Bing Xu Committed by Leyuan Wang

[Relay] C++ GraphRuntimeCodegen, Deprecate Python2 (#2986)

* [Relay] C++ GraphRuntimeCodegen

* [Test] Deprecate Python2

* [Python3] Add Py2 check

* Update _pyversion.py

* [Python3] Update test
parent b9349cb0
......@@ -84,6 +84,7 @@ else(MSVC)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
message("Build in Debug mode")
set(CMAKE_C_FLAGS "-O0 -g -Wall -fPIC ${CMAKE_C_FLAGS} -rdynamic")
set(CMAKE_CXX_FLAGS "-O0 -g -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS} -rdynamic")
else()
......
......@@ -216,7 +216,7 @@ stage('Build') {
}
stage('Unit Test') {
parallel 'python2/3: GPU': {
parallel 'python3: GPU': {
node('GPU') {
ws('workspace/tvm/ut-python-gpu') {
init_git()
......@@ -228,7 +228,7 @@ stage('Unit Test') {
}
}
},
'python2/3: i386': {
'python3: i386': {
node('CPU') {
ws('workspace/tvm/ut-python-i386') {
init_git()
......
......@@ -18,6 +18,8 @@
"""TVM: Low level DSL/IR stack for tensor computation."""
from __future__ import absolute_import as _abs
from . import _pyversion
from . import tensor
from . import arith
from . import expr
......
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""Python2 version check
"""
import sys
if not (sys.version_info[0] >= 3 and sys.version_info[1] >= 5):
PY3STATEMENT = """TVM project proudly dropped support of Python2.
The minimal Python requirement is Python 3.5
"""
raise Exception(PY3STATEMENT)
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*!
* Copyright (c) 2018 by Contributors
* \file relay/backend/utils.h
* \brief Utils function for backend
*/
#ifndef TVM_RELAY_BACKEND_UTILS_H_
#define TVM_RELAY_BACKEND_UTILS_H_
#include <dmlc/json.h>
#include <tvm/relay/expr.h>
#include <tvm/relay/pass.h>
#include <tvm/relay/type.h>
#include <tvm/tvm.h>
#include <tvm/build_module.h>
#include <tvm/codegen.h>
#include <tvm/ir_pass.h>
#include <tvm/operation.h>
#include <typeinfo>
#include <string>
namespace tvm {
namespace relay {
namespace backend {
/*!
* \brief Get the Packed Func
*
* \param func_name
* \return const PackedFunc*
*/
inline const PackedFunc* GetPackedFunc(const std::string& func_name) {
return tvm::runtime::Registry::Get(func_name);
}
/*!
* \brief Convert type to string
*
* \param typ
* \return std::string string format of type
*/
inline std::string DType2String(const tvm::Type typ) {
std::ostringstream os;
auto tvm_type = Type2TVMType(typ);
if (tvm_type.code == kDLFloat) {
os << "float";
} else if (tvm_type.code == kDLInt) {
os << "int";
} else if (tvm_type.code == kDLUInt) {
os << "uint";
} else {
LOG(FATAL) << "Unknown type";
}
os << typ.bits();
return os.str();
}
} // namespace backend
} // namespace relay
} // namespace tvm
#endif // TVM_RELAY_BACKEND_UTILS_H_
......@@ -32,7 +32,6 @@
#include <tvm/relay/expr.h>
#include <tvm/relay/attrs/nn.h>
#include <tvm/relay/attrs/transform.h>
#include <tvm/relay/attrs/nn.h>
#include <string>
......
......@@ -325,7 +325,9 @@ def test_fusible_network():
annotated_func = annotated()
expected_func = expected()
expected_index = [1, 1, 1, 2, 2, 1, 1, 2, 2]
ctx = tvm.context(device, 0)
dev_idx = ctx.device_type
expected_index = [1, 1, 1, dev_idx, dev_idx, 1, 1, dev_idx, dev_idx]
check_annotated_graph(annotated_func, expected_func)
test_runtime(target, device, annotated_func, fallback_device,
expected_index)
......@@ -401,7 +403,9 @@ def test_fusible_network():
annotated_func = annotated()
expected_func = expected()
expected_index = [2, 2, 2, 1, 1]
ctx = tvm.context(device, 0)
dev_idx = ctx.device_type
expected_index = [dev_idx, dev_idx, dev_idx, 1, 1]
check_annotated_graph(annotated_func, expected_func)
test_runtime(target, device, annotated_func, fallback_device,
expected_index)
......
......@@ -82,7 +82,7 @@ def test_dso_module_load():
fo.write(runtime_py)
subprocess.check_call(
"python %s %s %s" % (path_runtime_py, path_dso, dtype),
"python3 %s %s %s" % (path_runtime_py, path_dso, dtype),
shell=True)
......
......@@ -26,13 +26,13 @@ CURR_DIR=$(cd `dirname $0`; pwd)
SCRIPT_DIR=$CURR_DIR/../../jvm/core/src/test/scripts
TEMP_DIR=$(mktemp -d)
python $SCRIPT_DIR/test_add_cpu.py $TEMP_DIR
python $SCRIPT_DIR/test_add_gpu.py $TEMP_DIR
python $SCRIPT_DIR/test_graph_runtime.py $TEMP_DIR
python3 $SCRIPT_DIR/test_add_cpu.py $TEMP_DIR
python3 $SCRIPT_DIR/test_add_gpu.py $TEMP_DIR
python3 $SCRIPT_DIR/test_graph_runtime.py $TEMP_DIR
# start rpc proxy server
PORT=$(( ( RANDOM % 1000 ) + 9000 ))
python $SCRIPT_DIR/test_rpc_proxy_server.py $PORT 30 &
python3 $SCRIPT_DIR/test_rpc_proxy_server.py $PORT 30 &
make jvmpkg
make jvmpkg JVM_TEST_ARGS="-DskipTests=false \
......
......@@ -24,14 +24,12 @@ export PYTHONPATH=nnvm/python:python:topi/python
export OMP_NUM_THREADS=1
# Rebuild cython
make cython
make cython3
echo "Running relay TFLite frontend test..."
python3 -m nose -v tests/python/frontend/tflite
echo "Running nnvm unittest..."
python -m nose -v nnvm/tests/python/unittest
python3 -m nose -v nnvm/tests/python/unittest
echo "Running nnvm compiler test..."
......
......@@ -25,7 +25,6 @@ export LD_LIBRARY_PATH="build:${LD_LIBRARY_PATH:-}"
rm -rf python/tvm/*.pyc python/tvm/*/*.pyc python/tvm/*/*/*.pyc
# Test TVM
make cython
make cython3
# Test extern package
......@@ -33,14 +32,12 @@ cd apps/extension
rm -rf lib
make
cd ../..
python -m nose -v apps/extension/tests
TVM_FFI=cython python -m nose -v tests/python/integration
python3 -m nose -v apps/extension/tests
TVM_FFI=ctypes python3 -m nose -v tests/python/integration
TVM_FFI=cython python -m nose -v tests/python/contrib
TVM_FFI=ctypes python3 -m nose -v tests/python/contrib
TVM_FFI=cython python -m nose -v tests/python/relay
TVM_FFI=ctypes python3 -m nose -v tests/python/relay
# Do not enable OpenGL
......
......@@ -22,11 +22,9 @@ set -u
export PYTHONPATH=python:topi/python
# Rebuild cython
make cython
make cython3
rm -rf python/tvm/*.pyc python/tvm/*/*.pyc python/tvm/*/*/*.pyc
rm -rf topi/python/topi/*.pyc topi/python/topi/*/*.pyc topi/python/topi/*/*/*.pyc topi/python/topi/*/*/*/*.pyc
python -m nose -v topi/tests/python
python3 -m nose -v topi/tests/python
......@@ -23,9 +23,6 @@ export PYTHONPATH=python:topi/python
rm -rf python/tvm/*.pyc python/tvm/*/*.pyc python/tvm/*/*/*.pyc
TVM_FFI=ctypes python -m nose -v tests/python/unittest
TVM_FFI=ctypes python3 -m nose -v tests/python/unittest
make cython
make cython3
TVM_FFI=cython python -m nose -v tests/python/unittest
TVM_FFI=cython python3 -m nose -v tests/python/unittest
......@@ -25,13 +25,10 @@ rm -rf python/tvm/*.pyc python/tvm/*/*.pyc python/tvm/*/*/*.pyc python/tvm/*/*/*
rm -rf ~/.tvm
# Rebuild cython
make cython
make cython3
echo "Running unittest..."
python -m nose -v vta/tests/python/unittest
python3 -m nose -v vta/tests/python/unittest
echo "Running integration test..."
python -m nose -v vta/tests/python/integration
python3 -m nose -v vta/tests/python/integration
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment