diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 313b776b0824..849e4606834e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1 +1 @@ -Thanks for contributing to TVM! Please refer to guideline https://docs.tvm.ai/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from others in the community. +Thanks for contributing to TVM! Please refer to guideline https://docs.tvm.ai/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from [Reviewers](https://github.com/dmlc/tvm/blob/master/CONTRIBUTORS.md#reviewers). diff --git a/.gitignore b/.gitignore index 3c968eb3ed47..04dad2039860 100644 --- a/.gitignore +++ b/.gitignore @@ -91,10 +91,8 @@ ENV/ *~ *.pyc *~ -build config.mk config.cmake -build_* Win32 *.dir perf @@ -179,15 +177,39 @@ perf *.h5 synset.txt cat.jpg +cat.png docs.tgz cat.png *.mlmodel +tvm_u.* +tvm_t.* # Mac OS X .DS_Store -build* # Jetbrain .idea +.ipython +.jupyter +.nv +.pylint.d +.python_history +.pytest_cache +.local # tmp file .nfs* + +# keys +*.pem +*.p12 +*.pfx +*.cer +*.crt +*.der + +# patch sentinel +patched.txt + +# Python type checking +.mypy_cache/ +.pyre/ diff --git a/.gitmodules b/.gitmodules index 3f0b222a86c6..8011ec12d24b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ [submodule "dmlc-core"] - path = dmlc-core + path = 3rdparty/dmlc-core url = https://github.com/dmlc/dmlc-core [submodule "HalideIR"] - path = HalideIR + path = 3rdparty/HalideIR url = https://github.com/dmlc/HalideIR [submodule "dlpack"] - path = dlpack + path = 3rdparty/dlpack url = https://github.com/dmlc/dlpack diff --git a/3rdparty/HalideIR b/3rdparty/HalideIR new file mode 160000 index 000000000000..a08e26e5a97f --- /dev/null +++ b/3rdparty/HalideIR @@ -0,0 +1 @@ +Subproject commit a08e26e5a97f4ef4d566a42f6c78704b3f9c7b8a diff --git a/3rdparty/compiler-rt/builtin_fp16.h b/3rdparty/compiler-rt/builtin_fp16.h new file mode 100644 index 000000000000..1657d2830119 --- /dev/null +++ b/3rdparty/compiler-rt/builtin_fp16.h @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2009-2015 by llvm/compiler-rt contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + + * Copyright (c) 2018 by Contributors + * \file builtin_fp16.cc + * \brief Functions for conversion between fp32 and fp16, adopted from compiler-rt. + */ + +#include + +static inline uint32_t __clz(uint32_t x) { + // count leading zeros + int n = 32; + uint32_t y; + + y = x >>16; if (y) { n = n -16; x = y; } + y = x >> 8; if (y) { n = n - 8; x = y; } + y = x >> 4; if (y) { n = n - 4; x = y; } + y = x >> 2; if (y) { n = n - 2; x = y; } + y = x >> 1; if (y) return n - 2; + return n - x; +} + +template +static inline DST_T __truncXfYf2__(SRC_T a) { + // Various constants whose values follow from the type parameters. + // Any reasonable optimizer will fold and propagate all of these. + const int srcBits = sizeof(SRC_T) * 8; + const int srcExpBits = srcBits - SRC_SIG_BITS - 1; + const int srcInfExp = (1 << srcExpBits) - 1; + const int srcExpBias = srcInfExp >> 1; + + const SRC_REP_T srcMinNormal = SRC_REP_T(1) << SRC_SIG_BITS; + const SRC_REP_T srcSignificandMask = srcMinNormal - 1; + const SRC_REP_T srcInfinity = (SRC_REP_T)srcInfExp << SRC_SIG_BITS; + const SRC_REP_T srcSignMask = SRC_REP_T(1) << (SRC_SIG_BITS + srcExpBits); + const SRC_REP_T srcAbsMask = srcSignMask - 1; + const SRC_REP_T roundMask = (SRC_REP_T(1) << (SRC_SIG_BITS - DST_SIG_BITS)) - 1; + const SRC_REP_T halfway = SRC_REP_T(1) << (SRC_SIG_BITS - DST_SIG_BITS - 1); + const SRC_REP_T srcQNaN = SRC_REP_T(1) << (SRC_SIG_BITS - 1); + const SRC_REP_T srcNaNCode = srcQNaN - 1; + + const int dstBits = sizeof(DST_T) * 8; + const int dstExpBits = dstBits - DST_SIG_BITS - 1; + const int dstInfExp = (1 << dstExpBits) - 1; + const int dstExpBias = dstInfExp >> 1; + + const int underflowExponent = srcExpBias + 1 - dstExpBias; + const int overflowExponent = srcExpBias + dstInfExp - dstExpBias; + const SRC_REP_T underflow = (SRC_REP_T)underflowExponent << SRC_SIG_BITS; + const SRC_REP_T overflow = (SRC_REP_T)overflowExponent << SRC_SIG_BITS; + + const DST_REP_T dstQNaN = DST_REP_T(1) << (DST_SIG_BITS - 1); + const DST_REP_T dstNaNCode = dstQNaN - 1; + + // Break a into a sign and representation of the absolute value + const union { SRC_T f; SRC_REP_T i; } src_rep = {.f = a}; + const SRC_REP_T aRep = src_rep.i; + const SRC_REP_T aAbs = aRep & srcAbsMask; + const SRC_REP_T sign = aRep & srcSignMask; + DST_REP_T absResult; + + if (aAbs - underflow < aAbs - overflow) { + // The exponent of a is within the range of normal numbers in the + // destination format. We can convert by simply right-shifting with + // rounding and adjusting the exponent. + absResult = aAbs >> (SRC_SIG_BITS - DST_SIG_BITS); + absResult -= (DST_REP_T)(srcExpBias - dstExpBias) << DST_SIG_BITS; + + const SRC_REP_T roundBits = aAbs & roundMask; + // Round to nearest + if (roundBits > halfway) + absResult++; + // Ties to even + else if (roundBits == halfway) + absResult += absResult & 1; + } + else if (aAbs > srcInfinity) { + // a is NaN. + // Conjure the result by beginning with infinity, setting the qNaN + // bit and inserting the (truncated) trailing NaN field. + absResult = (DST_REP_T)dstInfExp << DST_SIG_BITS; + absResult |= dstQNaN; + absResult |= ((aAbs & srcNaNCode) >> (SRC_SIG_BITS - DST_SIG_BITS)) & dstNaNCode; + } + else if (aAbs >= overflow) { + // a overflows to infinity. + absResult = (DST_REP_T)dstInfExp << DST_SIG_BITS; + } + else { + // a underflows on conversion to the destination type or is an exact + // zero. The result may be a denormal or zero. Extract the exponent + // to get the shift amount for the denormalization. + const int aExp = aAbs >> SRC_SIG_BITS; + const int shift = srcExpBias - dstExpBias - aExp + 1; + + const SRC_REP_T significand = (aRep & srcSignificandMask) | srcMinNormal; + + // Right shift by the denormalization amount with sticky. + if (shift > SRC_SIG_BITS) { + absResult = 0; + } else { + const bool sticky = significand << (srcBits - shift); + SRC_REP_T denormalizedSignificand = significand >> shift | sticky; + absResult = denormalizedSignificand >> (SRC_SIG_BITS - DST_SIG_BITS); + const SRC_REP_T roundBits = denormalizedSignificand & roundMask; + // Round to nearest + if (roundBits > halfway) + absResult++; + // Ties to even + else if (roundBits == halfway) + absResult += absResult & 1; + } + } + + // Apply the signbit to (DST_T)abs(a). + const DST_REP_T result = absResult | sign >> (srcBits - dstBits); + const union { DST_T f; DST_REP_T i; } dst_rep = {.i = result}; + return dst_rep.f; +} + +template +static inline DST_T __extendXfYf2__(SRC_T a) { + // Various constants whose values follow from the type parameters. + // Any reasonable optimizer will fold and propagate all of these. + const int srcBits = sizeof(SRC_T) * 8; + const int srcExpBits = srcBits - SRC_SIG_BITS - 1; + const int srcInfExp = (1 << srcExpBits) - 1; + const int srcExpBias = srcInfExp >> 1; + + const SRC_REP_T srcMinNormal = SRC_REP_T(1) << SRC_SIG_BITS; + const SRC_REP_T srcInfinity = (SRC_REP_T)srcInfExp << SRC_SIG_BITS; + const SRC_REP_T srcSignMask = SRC_REP_T(1) << (SRC_SIG_BITS + srcExpBits); + const SRC_REP_T srcAbsMask = srcSignMask - 1; + const SRC_REP_T srcQNaN = SRC_REP_T(1) << (SRC_SIG_BITS - 1); + const SRC_REP_T srcNaNCode = srcQNaN - 1; + + const int dstBits = sizeof(DST_T)*8; + const int dstExpBits = dstBits - DST_SIG_BITS - 1; + const int dstInfExp = (1 << dstExpBits) - 1; + const int dstExpBias = dstInfExp >> 1; + + const DST_REP_T dstMinNormal = DST_REP_T(1) << DST_SIG_BITS; + + // Break a into a sign and representation of the absolute value + const union { SRC_T f; SRC_REP_T i; } src_rep = {.f = a}; + const SRC_REP_T aRep = src_rep.i; + const SRC_REP_T aAbs = aRep & srcAbsMask; + const SRC_REP_T sign = aRep & srcSignMask; + DST_REP_T absResult; + + // If sizeof(SRC_REP_T) < sizeof(int), the subtraction result is promoted + // to (signed) int. To avoid that, explicitly cast to SRC_REP_T. + if ((SRC_REP_T)(aAbs - srcMinNormal) < srcInfinity - srcMinNormal) { + // a is a normal number. + // Extend to the destination type by shifting the significand and + // exponent into the proper position and rebiasing the exponent. + absResult = (DST_REP_T)aAbs << (DST_SIG_BITS - SRC_SIG_BITS); + absResult += (DST_REP_T)(dstExpBias - srcExpBias) << DST_SIG_BITS; + } + + else if (aAbs >= srcInfinity) { + // a is NaN or infinity. + // Conjure the result by beginning with infinity, then setting the qNaN + // bit (if needed) and right-aligning the rest of the trailing NaN + // payload field. + absResult = (DST_REP_T)dstInfExp << DST_SIG_BITS; + absResult |= (DST_REP_T)(aAbs & srcQNaN) << (DST_SIG_BITS - SRC_SIG_BITS); + absResult |= (DST_REP_T)(aAbs & srcNaNCode) << (DST_SIG_BITS - SRC_SIG_BITS); + } + else if (aAbs) { + // a is denormal. + // renormalize the significand and clear the leading bit, then insert + // the correct adjusted exponent in the destination type. + const int scale = __clz(aAbs) - __clz(srcMinNormal); + absResult = (DST_REP_T)aAbs << (DST_SIG_BITS - SRC_SIG_BITS + scale); + absResult ^= dstMinNormal; + const int resultExponent = dstExpBias - srcExpBias - scale + 1; + absResult |= (DST_REP_T)resultExponent << DST_SIG_BITS; + } + else { + // a is zero. + absResult = 0; + } + + // Apply the signbit to (DST_T)abs(a). + const DST_REP_T result = absResult | (DST_REP_T)sign << (dstBits - srcBits); + const union { DST_T f; DST_REP_T i; } dst_rep = {.i = result}; + return dst_rep.f; +} diff --git a/3rdparty/dlpack b/3rdparty/dlpack new file mode 160000 index 000000000000..bee4d1dd8dc1 --- /dev/null +++ b/3rdparty/dlpack @@ -0,0 +1 @@ +Subproject commit bee4d1dd8dc1ee4a1fd8fa6a96476c2f8b7492a3 diff --git a/3rdparty/dmlc-core b/3rdparty/dmlc-core new file mode 160000 index 000000000000..519d013a213c --- /dev/null +++ b/3rdparty/dmlc-core @@ -0,0 +1 @@ +Subproject commit 519d013a213c0c447a971f51219473ef564d2348 diff --git a/CMakeLists.txt b/CMakeLists.txt index 39776d53d1f1..363b2056a87a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,8 +29,10 @@ tvm_option(USE_ROCM "Build with ROCM" OFF) tvm_option(ROCM_PATH "The path to rocm" /opt/rocm) tvm_option(USE_RPC "Build with RPC" ON) tvm_option(USE_LLVM "Build with LLVM, can be set to specific llvm-config path" OFF) +tvm_option(USE_STACKVM_RUNTIME "Include stackvm into the runtime" OFF) tvm_option(USE_GRAPH_RUNTIME "Build with tiny graph runtime" ON) tvm_option(USE_GRAPH_RUNTIME_DEBUG "Build with tiny graph runtime debug mode" OFF) +tvm_option(USE_SGX "Build with SGX" OFF) tvm_option(USE_RTTI "Build with RTTI" ON) tvm_option(USE_MSVC_MT "Build with MT" OFF) tvm_option(INSTALL_DEV "Install compiler infrastructure" OFF) @@ -45,21 +47,25 @@ tvm_option(USE_ROCBLAS "Build with ROCM:RoCBLAS" OFF) tvm_option(USE_SORT "Build with sort support" OFF) tvm_option(USE_NNPACK "Build with nnpack support" OFF) tvm_option(USE_RANDOM "Build with random support" OFF) +tvm_option(USE_ANTLR "Build with ANTLR for Relay parsing" OFF) # include directories include_directories("include") -include_directories("dlpack/include") -include_directories("dmlc-core/include") +include_directories("3rdparty/dlpack/include") +include_directories("3rdparty/dmlc-core/include") +include_directories("3rdparty/compiler-rt") # initial variables set(TVM_LINKER_LIBS "") set(TVM_RUNTIME_LINKER_LIBS "") +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Generic compilation options if(MSVC) add_definitions(-DWIN32_LEAN_AND_MEAN) add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_SCL_SECURE_NO_WARNINGS) + add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE) add_definitions(-DHalide_SHARED) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") @@ -76,8 +82,12 @@ if(MSVC) else(MSVC) include(CheckCXXCompilerFlag) check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11) - set(CMAKE_C_FLAGS "-O2 -Wall -fPIC ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS}") + if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + add_compile_options(-Wall -fPIC -std=c++11) + else() + set(CMAKE_C_FLAGS "-O2 -Wall -fPIC ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS}") + endif () if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) set(CMAKE_CXX_FLAGS "-faligned-new ${CMAKE_CXX_FLAGS}") @@ -85,8 +95,8 @@ else(MSVC) endif(MSVC) # add source group -FILE(GLOB_RECURSE GROUP_SOURCE "src/*.cc" "HalideIR/src/*.cpp" "nnvm/src/*.cc") -FILE(GLOB_RECURSE GROUP_INCLUDE "src/*.h" "include/*.h" "HalideIR/src/*.h" +FILE(GLOB_RECURSE GROUP_SOURCE "src/*.cc" "3rdparty/HalideIR/src/*.cpp" "nnvm/src/*.cc") +FILE(GLOB_RECURSE GROUP_INCLUDE "src/*.h" "include/*.h" "3rdparty/HalideIR/src/*.h" "nnvm/src/*.h" "nnvm/include/*.h") assign_source_group("Source" ${GROUP_SOURCE}) assign_source_group("Include" ${GROUP_INCLUDE}) @@ -97,13 +107,18 @@ file(GLOB COMPILER_SRCS src/arithmetic/*.cc src/autotvm/*.cc src/codegen/*.cc - src/codegen/stack_vm/*.cc src/lang/*.cc src/pass/*.cc src/op/*.cc src/schedule/*.cc ) +file(GLOB_RECURSE RELAY_SRCS + src/relay/*.cc + ) +list(APPEND COMPILER_SRCS ${RELAY_SRCS}) + + if(NOT MSVC) file(GLOB COMPILER_VERILOG_SRCS src/codegen/verilog/*.cc) list(APPEND COMPILER_SRCS ${COMPILER_VERILOG_SRCS}) @@ -120,7 +135,7 @@ file(GLOB_RECURSE NNVM_COMPILER_SRCS file(GLOB TOPI_SRCS topi/src/*.cc ) -file(GLOB_RECURSE HALIDEIR_SRCS HalideIR/src/*.cpp) +file(GLOB_RECURSE HALIDEIR_SRCS 3rdparty/HalideIR/src/*.cpp) list(APPEND COMPILER_SRCS ${HALIDEIR_SRCS}) file(GLOB RUNTIME_SRCS src/runtime/*.cc) @@ -135,12 +150,25 @@ if(USE_RPC) list(APPEND RUNTIME_SRCS ${RUNTIME_RPC_SRCS}) endif(USE_RPC) +file(GLOB STACKVM_RUNTIME_SRCS src/runtime/stackvm/*.cc) +file(GLOB STACKVM_CODEGEN_SRCS src/codegen/stackvm/*.cc) +list(APPEND COMPILER_SRCS ${STACKVM_CODEGEN_SRCS}) +if(USE_STACKVM_RUNTIME) + message(STATUS "Build with stackvm support in runtime...") + list(APPEND RUNTIME_SRCS ${STACKVM_RUNTIME_SRCS}) +else() + list(APPEND COMPILER_SRCS ${STACKVM_RUNTIME_SRCS}) +endif(USE_STACKVM_RUNTIME) + if(USE_GRAPH_RUNTIME) message(STATUS "Build with Graph runtime support...") file(GLOB RUNTIME_GRAPH_SRCS src/runtime/graph/*.cc) list(APPEND RUNTIME_SRCS ${RUNTIME_GRAPH_SRCS}) if(USE_GRAPH_RUNTIME_DEBUG) + message(STATUS "Build with Graph runtime debug support...") + file(GLOB RUNTIME_GRAPH_DEBUG_SRCS src/runtime/graph/debug/*.cc) + list(APPEND RUNTIME_SRCS ${RUNTIME_GRAPH_DEBUG_SRCS}) set_source_files_properties(${RUNTIME_GRAPH_SRCS} PROPERTIES COMPILE_DEFINITIONS "TVM_GRAPH_RUNTIME_DEBUG") endif(USE_GRAPH_RUNTIME_DEBUG) @@ -154,7 +182,9 @@ include(cmake/modules/OpenGL.cmake) include(cmake/modules/Vulkan.cmake) include(cmake/modules/Metal.cmake) include(cmake/modules/ROCM.cmake) +include(cmake/modules/SGX.cmake) include(cmake/modules/LLVM.cmake) +include(cmake/modules/ANTLR.cmake) include(cmake/modules/contrib/BLAS.cmake) include(cmake/modules/contrib/Random.cmake) include(cmake/modules/contrib/Sort.cmake) @@ -163,6 +193,11 @@ include(cmake/modules/contrib/NNPack.cmake) add_library(tvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS}) add_library(tvm_topi SHARED ${TOPI_SRCS}) add_library(tvm_runtime SHARED ${RUNTIME_SRCS}) +if(NOT USE_SGX STREQUAL "OFF") + add_dependencies(tvm sgx_edl) + add_dependencies(tvm_runtime sgx_edl tvm_t) + install(TARGETS tvm_t ARCHIVE DESTINATION lib${LIB_SUFFIX}) +endif() add_library(nnvm_compiler SHARED ${NNVM_COMPILER_SRCS}) target_link_libraries(tvm ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS}) @@ -173,7 +208,7 @@ target_link_libraries(nnvm_compiler tvm) # Related headers target_include_directories( tvm - PUBLIC "HalideIR/src" + PUBLIC "3rdparty/HalideIR/src" PUBLIC "topi/include") target_include_directories( tvm_topi @@ -186,7 +221,7 @@ target_include_directories( # Tests set(TEST_EXECS "") file(GLOB TEST_SRCS tests/cpp/*.cc) -find_library(GTEST_LIB gtest) +find_library(GTEST_LIB gtest "$ENV{GTEST_LIB}") if(GTEST_LIB) foreach(__srcpath ${TEST_SRCS}) @@ -223,12 +258,12 @@ if (INSTALL_DEV) PATTERN "*.h" ) install( - DIRECTORY "HalideIR/src/." DESTINATION "include/HalideIR" + DIRECTORY "3rdparty/HalideIR/src/." DESTINATION "include/HalideIR" FILES_MATCHING PATTERN "*.h" ) install( - DIRECTORY "dlpack/include/." DESTINATION "include" + DIRECTORY "3rdparty/dlpack/include/." DESTINATION "include" FILES_MATCHING PATTERN "*.h" ) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 6e3cf55b94b0..23d22686705b 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -5,38 +5,64 @@ contribute to, and influence the direction of the project. We actively invite co See the [community structure document](http://docs.tvm.ai/contribute/community.html) for the explanation of community structure and contribution guidelines. + ## Committers -- [Tianqi Chen](https://github.com/tqchen) (PMC) -- [Thierry Moreau](http://homes.cs.washington.edu/~moreau/) -- [Ziheng Jiang](https://github.com/ZihengJiang) -- [Haichen Shen](http://homes.cs.washington.edu/~haichen/) -- [Yizhi Liu](https://github.com/yzhliu) - -## Code Owners -- [Aditya Atluri](https://github.com/adityaatluri) ROCM -- [Leyuan Wang](https://github.com/Laurawly) TOPI -- [Yuwei Hu](https://github.com/Huyuwei) TOPI -- [Zhixun Tan](https://github.com/phisiart) OpenGL/WebGL backend -- [Nick Hynes](https://github.com/nhynes) SGX and secured computing + +We add tag along with committer name to show areas that they are familiar with. +We do encourage everyone to work anything they are interested in. + +- [Aditya Atluri](https://github.com/adityaatluri): @adityaatluri - rocm +- [Tianqi Chen](https://github.com/tqchen) (PMC): @tqchen - topi, compiler, relay, docs +- [Yuwei Hu](https://github.com/Huyuwei): @Huyuwei - topi, frontends +- [Nick Hynes](https://github.com/nhynes): @nhynes: - sgx, rust +- [Ziheng Jiang](https://github.com/ZihengJiang) (PMC): @ZihengJiang - relay, compiler +- [Yizhi Liu](https://github.com/yzhliu) (PMC): @yzhliu - jvm, topi, relay +- [Masahiro Masuda](https://github.com/masahi): @masahi - topi, relay +- [Thierry Moreau](https://github.com/tmoreau89) (PMC): @tmoreau89 - vta +- [Siva](https://github.com/srkreddy1238): @srkreddy1238 - frontends, golang +- [Haichen Shen](https://github.com/icemelon9) (PMC): @icemelon9 - relay, topi +- [Zhixun Tan](https://github.com/phisiart): @phisiart - opengl, web +- [Leyuan Wang](https://github.com/Laurawly): @Laurawly: - topi +- [Eddie Yan](https://github.com/eqy): @eqy - runtime, autotvm, rpc, topi +- [Lianmin Zheng](https://github.com/merrymercy): @merrymercy - autotvm, topi ## Reviewers -- [Masahiro Masuda](https://github.com/masahi) -- [Kazutaka Morita](https://github.com/kazum) -- [Pariksheet Pinjari](https://github.com/PariksheetPinjari909) -- [Siva](https://github.com/srkreddy1238) -- [Alex Weaver](https://github.com/alex-weaver) -- [Eddie Yan](https://github.com/eqy) -- [Joshua Z. Zhang](https://github.com/zhreshold) -- [Lianmin Zheng](https://github.com/merrymercy) + +- [Aditya Atluri](https://github.com/adityaatluri): @adityaatluri +- [Tianqi Chen](https://github.com/tqchen): @tqchen +- [Liangfu Chen](https://github.com/liangfu): @liangfu +- [Zhi Chen](https://github.com/zhiics): @zhiics +- [Nick Hynes](https://github.com/nhynes): @nhynes +- [Yuwei Hu](https://github.com/Huyuwei): @Huyuwei +- [Yizhi Liu](https://github.com/yzhliu) : @yzhliu +- [Zhixun Tan](https://github.com/phisiart): @phisiart +- [Zhi Chen](https://github.com/zhiics): @zhiics +- [Xiaoqiang Dan](https://github.com/xqdan): @xqdan +- [Ziheng Jiang](https://github.com/ZihengJiang): @ZihengJiang +- [Wuwei Lin](https://github.com/vinx13): @vinx13 +- [Masahiro Masuda](https://github.com/masahi): @masahi +- [Sergey Mironov](https://github.com/grwlf): @grwlf +- [Thierry Moreau](https://github.com/tmoreau89): @tmoreau89 +- [Kazutaka Morita](https://github.com/kazum): @kazum +- [Tatsuya Nishiyama](https://github.com/nishi-t): @nishi-t +- [Pariksheet Pinjari](https://github.com/PariksheetPinjari909): @PariksheetPinjari909 +- [Jared Roesch](https://github.com/jroesch): @jroesch +- [Siva](https://github.com/srkreddy1238): @srkreddy1238 +- [Siju Samuel](https://github.com/siju-samuel): @siju-samuel +- [Haichen Shen](https://github.com/icemelon9): @icemelon9 +- [Alex Weaver](https://github.com/alex-weaver): @alex-weaver +- [Yao Wang](https://github.com/kevinthesun): @kevinthesun +- [Leyuan Wang](https://github.com/Laurawly): @Laurawly +- [Jian Weng](https://github.com/were): @were +- [Eddie Yan](https://github.com/eqy): @eqy +- [Joshua Z. Zhang](https://github.com/zhreshold): @zhreshold +- [Lianmin Zheng](https://github.com/merrymercy): @merrymercy +- [Andrew Tulloch](https://github.com/ajtulloch): @ajtulloch ## List of Contributors - [Full List of Contributors](https://github.com/dmlc/tvm/graphs/contributors) - To contributors: please add your name to the list. - [Qiao Zhang](https://github.com/zhangqiaorjc) -- [Jian Weng](https://github.com/were) -- [Masahiro Masuda](https://github.com/masahi) - [Haolong Zhang](https://github.com/haolongzhangm) - [Cody Hao Yu](https://github.com/comaniac) - [Chris Nuernberger](https://github.com/cnuernber) -- [Tatsuya Nishiyama](https://github.com/nishi-t) -- [Kazutaka Morita](https://github.com/kazum) diff --git a/HalideIR b/HalideIR deleted file mode 160000 index a5a80bdc8232..000000000000 --- a/HalideIR +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a5a80bdc8232c9dbfe508bb5c46e8f58cdf7ec20 diff --git a/Jenkinsfile b/Jenkinsfile index bec0d2be5df8..f0c11426a078 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -96,6 +96,9 @@ stage('Build') { echo set\\(USE_RPC ON\\) >> config.cmake echo set\\(USE_SORT ON\\) >> config.cmake echo set\\(USE_GRAPH_RUNTIME ON\\) >> config.cmake + echo set\\(USE_STACKVM_RUNTIME ON\\) >> config.cmake + echo set\\(USE_GRAPH_RUNTIME_DEBUG ON\\) >> config.cmake + echo set\\(USE_ANTLR ON\\) >> config.cmake echo set\\(USE_BLAS openblas\\) >> config.cmake echo set\\(CMAKE_CXX_COMPILER g++\\) >> config.cmake echo set\\(CMAKE_CXX_FLAGS -Werror\\) >> config.cmake @@ -110,6 +113,7 @@ stage('Build') { echo set\\(USE_OPENCL ON\\) >> config.cmake echo set\\(USE_ROCM ON\\) >> config.cmake echo set\\(USE_VULKAN ON\\) >> config.cmake + echo set\\(USE_GRAPH_RUNTIME_DEBUG ON\\) >> config.cmake echo set\\(CMAKE_CXX_COMPILER clang-6.0\\) >> config.cmake echo set\\(CMAKE_CXX_FLAGS -Werror\\) >> config.cmake """ @@ -126,7 +130,11 @@ stage('Build') { cd build cp ../cmake/config.cmake . echo set\\(USE_SORT ON\\) >> config.cmake + echo set\\(USE_GRAPH_RUNTIME_DEBUG ON\\) >> config.cmake echo set\\(USE_LLVM llvm-config-4.0\\) >> config.cmake + echo set\\(USE_NNPACK ON\\) >> config.cmake + echo set\\(NNPACK_PATH /NNPACK/build/\\) >> config.cmake + echo set\\(USE_ANTLR ON\\) >> config.cmake echo set\\(CMAKE_CXX_COMPILER g++\\) >> config.cmake echo set\\(CMAKE_CXX_FLAGS -Werror\\) >> config.cmake """ @@ -135,6 +143,10 @@ stage('Build') { timeout(time: max_time, unit: 'MINUTES') { sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_cpp_unittest.sh" sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_python_vta.sh" + sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_rust.sh" + sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_golang.sh" + sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_python_unittest.sh" + sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_python_integration.sh" } } } @@ -149,6 +161,7 @@ stage('Build') { cp ../cmake/config.cmake . echo set\\(USE_SORT ON\\) >> config.cmake echo set\\(USE_RPC ON\\) >> config.cmake + echo set\\(USE_GRAPH_RUNTIME_DEBUG ON\\) >> config.cmake echo set\\(USE_LLVM llvm-config-5.0\\) >> config.cmake echo set\\(CMAKE_CXX_COMPILER g++\\) >> config.cmake echo set\\(CMAKE_CXX_FLAGS -Werror\\) >> config.cmake diff --git a/Makefile b/Makefile index 2d3d4843c4c0..50048165bb8d 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,11 @@ ROOTDIR = $(CURDIR) cython cython2 cython3 web runtime vta ifndef DMLC_CORE_PATH - DMLC_CORE_PATH = $(ROOTDIR)/dmlc-core + DMLC_CORE_PATH = $(ROOTDIR)/3rdparty/dmlc-core endif ifndef DLPACK_PATH - DLPACK_PATH = $(ROOTDIR)/dlpack + DLPACK_PATH = $(ROOTDIR)/3rdparty/dlpack endif INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include @@ -50,10 +50,10 @@ build/libtvm_web_runtime.js: build/libtvm_web_runtime.bc # Lint scripts cpplint: - python3 dmlc-core/scripts/lint.py vta cpp vta/include vta/src - python3 dmlc-core/scripts/lint.py topi cpp topi/include; - python3 dmlc-core/scripts/lint.py nnvm cpp nnvm/include nnvm/src; - python3 dmlc-core/scripts/lint.py tvm cpp include src verilog\ + python3 3rdparty/dmlc-core/scripts/lint.py vta cpp vta/include vta/src + python3 3rdparty/dmlc-core/scripts/lint.py topi cpp topi/include; + python3 3rdparty/dmlc-core/scripts/lint.py nnvm cpp nnvm/include nnvm/src; + python3 3rdparty/dmlc-core/scripts/lint.py tvm cpp include src verilog\ examples/extension/src examples/graph_executor/src pylint: @@ -63,13 +63,17 @@ pylint: python3 -m pylint vta/python/vta --rcfile=$(ROOTDIR)/tests/lint/pylintrc jnilint: - python3 dmlc-core/scripts/lint.py tvm4j-jni cpp jvm/native/src + python3 3rdparty/dmlc-core/scripts/lint.py tvm4j-jni cpp jvm/native/src lint: cpplint pylint jnilint doc: doxygen docs/Doxyfile +javadoc: + # build artifact is in jvm/core/target/site/apidocs + cd jvm && mvn javadoc:javadoc + # Cython build cython: cd python; python setup.py build_ext --inplace diff --git a/NEWS.md b/NEWS.md index 567aabf3fcbd..2c2f616cb2f0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,69 @@ Refer to the Roadmap issue for complete list on on-going version features. If you check in something that is not reflected in Roadmap issue, please reply to that issue so it can get added. +## 0.4 + +This release features several major improvements. The high-level graph optimizer is now part of TVM repo. Some of the highlights are: Initial support of AutoTVM for automated optimization; customized accelerator backend VTA. + +- Tensor operator primitives + - Introduce attrs field to operator primitives(e.g. compute) to store additional metadata, the attrs can be used as hint for scheduling +- Enable embedding of asm micro-kernels +- Hybrid python programming model + - python AST based IR builder interface + - support GPU programs +- AutoTVM, Automated tuning, and scheduling + - basic autotvm infra + - GPU IR verifier + - basic autotuning tutorial + - topi integration +- ARM support + - winograd support + - initial support of ARM autotuning records +- TOPI Vision + - Generic GPU sort support(useful for vision) + - SSD operator support +- TOPI numpy consistency + - Rename all binary operators for numpy consistecy: broadcast_add-> add, broadcast_sub -> substract, broadcast_mul -> multiply, broadcast_div->divide + - New operators: slice, LRN, equal, not_equal, less, greater + - tutorials on topi +- Initial low-bit operator support support + - Optimized popcount generation on ARM + - general bit-serial convolution and GEMM + - optimized low bit kernels + - parallel optimization +- New topi backend optimization for intel graphics +- Adapt AVX schedules for SSE target +- VTA: customized accelerator backend + - custom hardware backend example + - tutorials on how to use customized accelerator +- Initial experimental support for HLS backend +- Bugfix in SPIRV code generator for vulkan +- libdevice support, enable NVPTX backend +- Introduce NDArrayContainer for managed NDarray +- RPC and Device API + - Support communication between big/small endian machines. + - RPC and device API protocol upgrade (this is a non-backward compatible change) to support big-small endian communication. This is a non-backward compatible change, need to use the latest version of TVM runtime with the RPC + - graduate rpc from contrib, tvm.contrib.rpc->tvm.rpc + -Support tracker in Android RPC, add fault tolerance for AutoTVM +- BIG.LITTLE aware threadpool +- tvm4j graph runtime that runs end to end workload in java +- DLPack support + - Support from_dlpack and to_dlpack + - Enables bridges to pytorch +- Enable link of stackvm in runtime +- Tensorflow graphdef frontend +- Keras frontend + - improved to support reuse layers, add activations +- ONNX + - gather, LRN +- CoreML frontend + - Support C-RNN and activation functions +- Fix grads for sum and expand_like +- Enhanced operator fusion for multiple elemwise branches +- Separate nnvm fusion and compilation pass +- Unified build system to cmake, customizable cmake path for vulkan, rocm, cuda + + ## 0.3 This release features numerous improvements in TOPI and backends. We make the first step toward object detection support in TOPI, featuring operators necessary for YOLO and SSDs. The topi now supports numpy-style API and operator overloading. RPC is significantly improved to support resource allocation and using a pool of devices. We are adding two new backends: WebGL for running GPUs on the browser, and Vulkan for running on next-generation graphics API. diff --git a/NOTICE b/NOTICE new file mode 100644 index 000000000000..45468c50ba1b --- /dev/null +++ b/NOTICE @@ -0,0 +1 @@ +TVM End to End Deep Learning Compiler Stack: https://tvm.ai/ diff --git a/README.md b/README.md index e2fc7b8c45d2..828b0f7e880b 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,6 @@ Acknowledgement --------------- We learnt a lot from the following projects when building TVM. - [Halide](https://github.com/halide/Halide): TVM uses [HalideIR](https://github.com/dmlc/HalideIR) as data structure for - arithematic simplification and low level lowering. We also learnt and adapted some part of lowering pipeline from Halide. + arithmetic simplification and low level lowering. We also learnt and adapted some part of lowering pipeline from Halide. - [Loopy](https://github.com/inducer/loopy): use of integer set analysis and its loop transformation primitives. - [Theano](https://github.com/Theano/Theano): the design inspiration of symbolic scan operator for recurrence. diff --git a/apps/android_deploy/README.md b/apps/android_deploy/README.md index 801ca8bdf95c..2c2951b5332d 100644 --- a/apps/android_deploy/README.md +++ b/apps/android_deploy/README.md @@ -2,14 +2,21 @@ This folder contains Android Demo app that allows us to show how to deploy model using TVM runtime api on a Android phone. -You will need [JDK](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html), [Android SDK](https://developer.android.com/studio/index.html), [Android NDK](https://developer.android.com/ndk) and an Android device to use this. +You will need [JDK](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html), [Android SDK](https://developer.android.com/studio/index.html), [Android NDK](https://developer.android.com/ndk) and an Android device to use this. Make sure the `ANDROID_HOME` variable already points to your Android SDK folder or set it using `export ANDROID_HOME=[Path to your Android SDK, e.g., ~/Android/sdk]`. We use [Gradle](https://gradle.org) to build. Please follow [the installation instruction](https://gradle.org/install) for your operating system. + +Alternatively, you may execute Docker image we provide wich contains the required packages. Use the command below to build the image and enter interactive session. Note, that building with OpenCL was not tested from Docker. + +```bash +./docker/build.sh demo_android -it bash +(docker) $ echo $ANDROID_HOME +(docker) /opt/android-sdk-linux +``` + ## Build and Installation ### Build APK -We use [Gradle](https://gradle.org) to build. Please follow [the installation instruction](https://gradle.org/install) for your operating system. - Before you build the Android application, please refer to [TVM4J Installation Guide](https://github.com/dmlc/tvm/blob/master/jvm/README.md) and install tvm4j-core to your local maven repository. You can find tvm4j dependency declare in `app/build.gradle`. Modify it if it is necessary. ``` @@ -48,7 +55,6 @@ USE_OPENCL = 0 Now use Gradle to compile JNI, resolve Java dependencies and build the Android application together with tvm4j. Run following script to generate the apk file. ```bash -export ANDROID_HOME=[Path to your Android SDK, e.g., ~/Android/sdk] cd apps/android_deploy gradle clean build ``` diff --git a/apps/android_deploy/app/src/main/java/ml/dmlc/tvm/android/demo/MainActivity.java b/apps/android_deploy/app/src/main/java/ml/dmlc/tvm/android/demo/MainActivity.java index f3cdefe1c2ff..7d391856f599 100644 --- a/apps/android_deploy/app/src/main/java/ml/dmlc/tvm/android/demo/MainActivity.java +++ b/apps/android_deploy/app/src/main/java/ml/dmlc/tvm/android/demo/MainActivity.java @@ -298,7 +298,7 @@ protected Integer doInBackground(Bitmap... bitmaps) { // get the function from the module(get output data) Log.i(TAG, "get output data"); - NDArray outputNdArray = NDArray.empty(new long[]{1000}, new TVMType("float32")); + NDArray outputNdArray = NDArray.empty(new long[]{1, 1000}, new TVMType("float32")); Function getOutputFunc = graphRuntimeModule.getFunction("get_output"); getOutputFunc.pushArg(OUTPUT_INDEX).pushArg(outputNdArray).invoke(); float[] output = outputNdArray.asFloatArray(); @@ -630,4 +630,4 @@ public static Matrix getTransformationMatrix( return matrix; } -} \ No newline at end of file +} diff --git a/apps/android_deploy/app/src/main/jni/Android.mk b/apps/android_deploy/app/src/main/jni/Android.mk index a99517f90332..da5f499ea706 100644 --- a/apps/android_deploy/app/src/main/jni/Android.mk +++ b/apps/android_deploy/app/src/main/jni/Android.mk @@ -20,9 +20,9 @@ LOCAL_SRC_FILES := ml_dmlc_tvm_native_c_api.cc LOCAL_LDFLAGS := -L$(SYSROOT)/usr/lib/ -llog LOCAL_C_INCLUDES := $(ROOT_PATH)/include \ - $(ROOT_PATH)/dlpack/include \ - $(ROOT_PATH)/dmlc-core/include \ - $(ROOT_PATH)/HalideIR/src \ + $(ROOT_PATH)/3rdparty/dlpack/include \ + $(ROOT_PATH)/3rdparty/dmlc-core/include \ + $(ROOT_PATH)/3rdparty/HalideIR/src \ $(ROOT_PATH)/topi/include LOCAL_MODULE = tvm4j_runtime_packed diff --git a/apps/android_deploy/build.gradle b/apps/android_deploy/build.gradle index f7bbe2641c9d..1eeb9d686cfb 100644 --- a/apps/android_deploy/build.gradle +++ b/apps/android_deploy/build.gradle @@ -3,9 +3,12 @@ buildscript { repositories { jcenter() + maven { + url 'https://maven.google.com' + } } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' + classpath 'com.android.tools.build:gradle:3.1.0' classpath 'org.apache.httpcomponents:httpclient:4.5.4' // NOTE: Do not place your application dependencies here; they belong diff --git a/apps/android_deploy/dev_tools/sign_apk.sh b/apps/android_deploy/dev_tools/sign_apk.sh index 314f82cdb76c..fd8cee6b927a 100644 --- a/apps/android_deploy/dev_tools/sign_apk.sh +++ b/apps/android_deploy/dev_tools/sign_apk.sh @@ -1,6 +1,6 @@ #!/bin/bash CURR_DIR=$(cd `dirname $0`; pwd) -APK_DIR=$CURR_DIR/../app/build/outputs/apk +APK_DIR=$CURR_DIR/../app/build/outputs/apk/release UNSIGNED_APK=$APK_DIR/app-release-unsigned.apk SIGNED_APK=$APK_DIR/tvmdemo-release.apk jarsigner -verbose -keystore $CURR_DIR/tvmdemo.keystore -signedjar $SIGNED_APK $UNSIGNED_APK 'tvmdemo' diff --git a/apps/android_rpc/README.md b/apps/android_rpc/README.md index 41d361c823ed..453263aa824e 100644 --- a/apps/android_rpc/README.md +++ b/apps/android_rpc/README.md @@ -104,11 +104,11 @@ You are supposed to find a free "android" in the queue status. ... Queue Status ----------------------------- -key free pending ----------------------------- -android 1 0 ----------------------------- +------------------------------- +key total free pending +------------------------------- +android 1 1 0 +------------------------------- ``` @@ -123,18 +123,25 @@ export TVM_NDK_CC=/opt/android-toolchain-arm64/bin/aarch64-linux-android-g++ python android_rpc_test.py ``` -This will compile TVM IR to shared libraries (CPU and OpenCL) and run vector addition on your Android device. On my test device, it gives following results. +This will compile TVM IR to shared libraries (CPU, OpenCL and Vulkan) and run vector addition on your Android device. To verify compiled TVM IR shared libraries on OpenCL target set [`'test_opencl = True'`](https://github.com/dmlc/tvm/blob/master/apps/android_rpc/tests/android_rpc_test.py#L25) and on Vulkan target set [`'test_vulkan = False'`](https://github.com/dmlc/tvm/blob/master/apps/android_rpc/tests/android_rpc_test.py#L27) in [tests/android_rpc_test.py](https://github.com/dmlc/tvm/blob/master/apps/android_rpc/tests/android_rpc_test.py), by default on CPU target will execute. +On my test device, it gives following results. ```bash -TVM: Initializing cython mode... -[01:21:43] src/codegen/llvm/codegen_llvm.cc:75: set native vector to be 32 for target aarch64 -[01:21:43] src/runtime/opencl/opencl_device_api.cc:194: Initialize OpenCL platform 'Apple' -[01:21:43] src/runtime/opencl/opencl_device_api.cc:214: opencl(0)='Iris' cl_device_id=0x1024500 -[01:21:44] src/codegen/llvm/codegen_llvm.cc:75: set native vector to be 32 for target aarch64 -Run GPU test ... -0.000155807 secs/op Run CPU test ... -0.00139824 secs/op +0.000962932 secs/op + +Run GPU(OpenCL Flavor) test ... +0.000155807 secs/op + +[23:29:34] /home/tvm/src/runtime/vulkan/vulkan_device_api.cc:674: Cannot initialize vulkan: [23:29:34] /home/tvm/src/runtime/vulkan/vulkan_device_api.cc:512: Check failed: __e == VK_SUCCESS Vulan Error, code=-9: VK_ERROR_INCOMPATIBLE_DRIVER + +Stack trace returned 10 entries: +[bt] (0) /home/user/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(dmlc::StackTrace[abi:cxx11]()+0x53) [0x7f477f5399f3] +......... + +You can still compile vulkan module but cannot run locally +Run GPU(Vulkan Flavor) test ... +0.000225198 secs/op ``` You can define your own TVM operators and test via this RPC app on your Android device to find the most optimized TVM schedule. diff --git a/apps/android_rpc/app/src/main/java/ml/dmlc/tvm/tvmrpc/MainActivity.java b/apps/android_rpc/app/src/main/java/ml/dmlc/tvm/tvmrpc/MainActivity.java index d80008bbe258..2ea4e4cb7528 100644 --- a/apps/android_rpc/app/src/main/java/ml/dmlc/tvm/tvmrpc/MainActivity.java +++ b/apps/android_rpc/app/src/main/java/ml/dmlc/tvm/tvmrpc/MainActivity.java @@ -39,11 +39,9 @@ public class MainActivity extends AppCompatActivity { - private boolean skipRelaunch = true; // wait time before automatic restart of RPC Activity public static final int HANDLER_RESTART_DELAY = 5000; - private void showDialog(String title, String msg) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(title); @@ -91,7 +89,7 @@ private void setupRelaunch() { final Runnable rPCStarter = new Runnable() { public void run() { if (switchPersistent.isChecked()) { - System.err.println("relaunching RPC activity in 5s..."); + System.err.println("relaunching RPC activity..."); Intent intent = ((MainActivity) context).updateRPCPrefs(); startActivity(intent); } @@ -116,6 +114,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { System.err.println("automatic RPC restart enabled..."); updateRPCPrefs(); + setupRelaunch(); } else { System.err.println("automatic RPC restart disabled..."); updateRPCPrefs(); @@ -123,29 +122,14 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { } }); - Button startRPC = findViewById(R.id.button_start_rpc); - startRPC.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - Intent intent = ((MainActivity) context).updateRPCPrefs(); - startActivity(intent); - } - }); - enableInputView(true); } @Override protected void onResume() { System.err.println("MainActivity onResume..."); - System.err.println("skipRelaunch: " + skipRelaunch); - // if this is the first time onResume is called, do nothing, otherwise we - // may double launch - if (!skipRelaunch) { - enableInputView(true); - setupRelaunch(); - } else { - skipRelaunch = false; - } + enableInputView(true); + setupRelaunch(); super.onResume(); } diff --git a/apps/android_rpc/app/src/main/jni/Android.mk b/apps/android_rpc/app/src/main/jni/Android.mk index a99517f90332..da5f499ea706 100644 --- a/apps/android_rpc/app/src/main/jni/Android.mk +++ b/apps/android_rpc/app/src/main/jni/Android.mk @@ -20,9 +20,9 @@ LOCAL_SRC_FILES := ml_dmlc_tvm_native_c_api.cc LOCAL_LDFLAGS := -L$(SYSROOT)/usr/lib/ -llog LOCAL_C_INCLUDES := $(ROOT_PATH)/include \ - $(ROOT_PATH)/dlpack/include \ - $(ROOT_PATH)/dmlc-core/include \ - $(ROOT_PATH)/HalideIR/src \ + $(ROOT_PATH)/3rdparty/dlpack/include \ + $(ROOT_PATH)/3rdparty/dmlc-core/include \ + $(ROOT_PATH)/3rdparty/HalideIR/src \ $(ROOT_PATH)/topi/include LOCAL_MODULE = tvm4j_runtime_packed diff --git a/apps/android_rpc/app/src/main/jni/Application.mk b/apps/android_rpc/app/src/main/jni/Application.mk index 5bf52bdaffc0..f142e2995777 100644 --- a/apps/android_rpc/app/src/main/jni/Application.mk +++ b/apps/android_rpc/app/src/main/jni/Application.mk @@ -1,9 +1,9 @@ ifndef config - ifneq ("$(wildcard ./config.mk)","") - config ?= config.mk - else - config ?= make/config.mk - endif + ifneq ("$(wildcard ./config.mk)","") + config ?= config.mk + else + config ?= make/config.mk + endif endif include $(config) @@ -16,10 +16,10 @@ APP_STL := c++_static APP_CPPFLAGS += -DDMLC_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++11 -Oz -frtti ifeq ($(USE_OPENCL), 1) - APP_CPPFLAGS += -DTVM_OPENCL_RUNTIME=1 + APP_CPPFLAGS += -DTVM_OPENCL_RUNTIME=1 endif ifeq ($(USE_VULKAN), 1) - APP_CPPFLAGS += -DTVM_VULKAN_RUNTIME=1 - APP_LDFLAGS += -lvulkan + APP_CPPFLAGS += -DTVM_VULKAN_RUNTIME=1 + APP_LDFLAGS += -lvulkan endif diff --git a/apps/android_rpc/app/src/main/res/layout/content_main.xml b/apps/android_rpc/app/src/main/res/layout/content_main.xml index 0f2564833ecd..69c1f76030df 100644 --- a/apps/android_rpc/app/src/main/res/layout/content_main.xml +++ b/apps/android_rpc/app/src/main/res/layout/content_main.xml @@ -20,6 +20,7 @@ android:hint="@string/input_address" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:inputType="phone" android:background="@android:drawable/editbox_background"/> @@ -37,6 +38,7 @@ android:minWidth="100dip" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:inputType="phone" android:background="@android:drawable/editbox_background"/> @@ -76,15 +78,4 @@ android:textOn="@string/switch_on" /> - -