Skip to content

Commit

Permalink
Merge remote-tracking branch 'tvm-source/main' into SYSOL-584-pytorch…
Browse files Browse the repository at this point in the history
…-conv-transpose-pad-fix
  • Loading branch information
Jeffrey-Sima committed Apr 22, 2021
2 parents 17ab1c2 + 9514e9e commit 213886b
Show file tree
Hide file tree
Showing 888 changed files with 26,176 additions and 10,840 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,8 @@ conda/pkg
# nix files
.envrc
*.nix

# Downloaded models/datasets
.tvm_test_data
.dgl
.caffe2
2 changes: 1 addition & 1 deletion 3rdparty/vta-hw
50 changes: 29 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ tvm_option(USE_RPC "Build with RPC" ON)
tvm_option(USE_THREADS "Build with thread support" 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_CUDA_GRAPH "Build with tiny graph runtime with CUDA Graph for GPUs" OFF)
tvm_option(USE_PROFILER "Build profiler for the VM and graph runtime" ON)
tvm_option(USE_GRAPH_EXECUTOR "Build with tiny graph executor" ON)
tvm_option(USE_GRAPH_EXECUTOR_CUDA_GRAPH "Build with tiny graph executor with CUDA Graph for GPUs" OFF)
tvm_option(USE_PROFILER "Build profiler for the VM and graph executor" ON)
tvm_option(USE_OPENMP "Build with OpenMP thread pool implementation" OFF)
tvm_option(USE_RELAY_DEBUG "Building Relay in debug mode..." OFF)
tvm_option(USE_RTTI "Build with RTTI" ON)
Expand Down Expand Up @@ -79,7 +79,7 @@ tvm_option(USE_COREML "Build with coreml support" OFF)
tvm_option(USE_BNNS "Build with BNNS support" OFF)
tvm_option(USE_TARGET_ONNX "Build with ONNX Codegen support" OFF)
tvm_option(USE_ARM_COMPUTE_LIB "Build with Arm Compute Library" OFF)
tvm_option(USE_ARM_COMPUTE_LIB_GRAPH_RUNTIME "Build with Arm Compute Library graph runtime" OFF)
tvm_option(USE_ARM_COMPUTE_LIB_GRAPH_EXECUTOR "Build with Arm Compute Library graph executor" OFF)
tvm_option(USE_TENSORRT_CODEGEN "Build with TensorRT Codegen support" OFF)
tvm_option(USE_TENSORRT_RUNTIME "Build with TensorRT runtime" OFF)
tvm_option(USE_RUST_EXT "Build with Rust based compiler extensions, STATIC, DYNAMIC, or OFF" OFF)
Expand Down Expand Up @@ -307,16 +307,30 @@ 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})
# NOTE(areusch): USE_GRAPH_RUNTIME will be deleted in a future release
if(USE_GRAPH_RUNTIME AND NOT DEFINED USE_GRAPH_EXECUTOR)
message(WARNING "USE_GRAPH_RUNTIME renamed to USE_GRAPH_EXECUTOR. Please update your config.cmake")
set(USE_GRAPH_EXECUTOR ${USE_GRAPH_RUNTIME})
unset(USE_GRAPH_RUNTIME CACHE)
endif(USE_GRAPH_RUNTIME AND NOT DEFINED USE_GRAPH_EXECUTOR)

# NOTE(areusch): USE_GRAPH_RUNTIME_DEBUG will be deleted in a future release
if(USE_GRAPH_RUNTIME_DEBUG AND NOT DEFINED USE_GRAPH_EXECUTOR_DEBUG)
message(WARNING "USE_GRAPH_RUNTIME_DEBUG renamed to USE_GRAPH_EXECUTOR_DEBUG. Please update your config.cmake")
set(USE_GRAPH_EXECUTOR_DEBUG ${USE_GRAPH_RUNTIME_DEBUG})
unset(USE_GRAPH_RUNTIME_DEBUG CACHE)
endif(USE_GRAPH_RUNTIME_DEBUG AND NOT DEFINED USE_GRAPH_EXECUTOR_DEBUG)

if(USE_GRAPH_EXECUTOR)
message(STATUS "Build with Graph Executor support...")
file(GLOB RUNTIME_GRAPH_EXECUTOR_SRCS src/runtime/graph_executor/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_GRAPH_EXECUTOR_SRCS})

endif(USE_GRAPH_RUNTIME)
endif(USE_GRAPH_EXECUTOR)

# convert old options for profiler
if(USE_GRAPH_RUNTIME_DEBUG)
unset(USE_GRAPH_RUNTIME_DEBUG CACHE)
if(USE_GRAPH_EXECUTOR_DEBUG)
unset(USE_GRAPH_EXECUTOR_DEBUG CACHE)
set(USE_PROFILER ON)
endif()
if(USE_VM_PROFILER)
Expand All @@ -327,10 +341,10 @@ endif()
if(USE_PROFILER)
message(STATUS "Build with profiler...")

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")
file(GLOB RUNTIME_GRAPH_EXECUTOR_DEBUG_SRCS src/runtime/graph_executor/debug/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_GRAPH_EXECUTOR_DEBUG_SRCS})
set_source_files_properties(${RUNTIME_GRAPH_EXECUTOR_SRCS}
PROPERTIES COMPILE_DEFINITIONS "TVM_GRAPH_EXECUTOR_DEBUG")

file(GLOB RUNTIME_VM_PROFILER_SRCS src/runtime/vm/profiler/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_VM_PROFILER_SRCS})
Expand Down Expand Up @@ -435,12 +449,6 @@ if(BUILD_FOR_HEXAGON)
# Wrap pthread_create to allow setting custom stack size.
set_property(TARGET tvm_runtime APPEND PROPERTY LINK_FLAGS
"-Wl,--wrap=pthread_create")

target_include_directories(tvm_runtime SYSTEM
PUBLIC "${USE_HEXAGON_SDK}/libs/common/qurt/ADSPv62MP/include/posix"
PUBLIC "${USE_HEXAGON_SDK}/libs/common/qurt/ADSPv62MP/include/qurt"
PUBLIC "${USE_HEXAGON_SDK}/incs"
PUBLIC "${USE_HEXAGON_SDK}/incs/stddef")
endif()

if(USE_THREADS AND NOT BUILD_FOR_HEXAGON)
Expand Down
10 changes: 6 additions & 4 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ We do encourage everyone to work anything they are interested in.
- [Liangfu Chen](https://github.com/liangfu): @liangfu - vta, chisel, intel FPGA, c runtime
- [Wei Chen](https://github.com/wweic): @wweic - runtime, relay, vm
- [Zhi Chen](https://github.com/zhiics) (PMC): @zhiics - relay, quantization, pass manager
- [Chenfan](https://github.com/jcf94): @jcf94 - autoscheduling
- [Chenfan](https://github.com/jcf94): @jcf94 - auto_scheduler
- [Josh Fromm](https://github.com/jwfromm): @jwfromm - frontends, quantization, topi
- [Yuwei Hu](https://github.com/Huyuwei): @Huyuwei - topi, frontends
- [Nick Hynes](https://github.com/nhynes): @nhynes: - sgx, rust
Expand All @@ -70,12 +70,12 @@ We do encourage everyone to work anything they are interested in.
- [Andrew Tulloch](https://github.com/ajtulloch): @ajtulloch - topi, compiler, runtime
- [Luis Vega](https://github.com/vegaluisjose): @vegaluisjose - vta, chisel
- [Leyuan Wang](https://github.com/Laurawly) (PMC): @Laurawly: - topi
- [Yao Wang](https://github.com/kevinthesun): @kevinthesun: - topi, vision
- [Yao Wang](https://github.com/kevinthesun): @kevinthesun (PMC): - topi, vision
- [Jian Weng](https://github.com/were): @were: - hybrid script
- [Zhao Wu](https://github.com/FrozenGene): @FrozenGene - runtime, topi, frontends
- [Eddie Yan](https://github.com/eqy) (PMC): @eqy - runtime, autotvm, rpc, topi
- [Hao Yu](https://github.com/comaniac): @comaniac - relay, byoc, ansor
- [Lianmin Zheng](https://github.com/merrymercy) (PMC): @merrymercy - autotvm, topi, relay
- [Hao Yu](https://github.com/comaniac): @comaniac - relay, byoc, auto_scheduler
- [Lianmin Zheng](https://github.com/merrymercy) (PMC): @merrymercy - autotvm, auto_scheduler, topi, relay

## Reviewers

Expand All @@ -92,8 +92,10 @@ We do encourage everyone to work anything they are interested in.
- [Balint Cristian](https://github.com/cbalint13): @cbalint13
- [Haozheng Fan](https://github.com/hzfan): @hzfan
- [Josh Fromm](https://github.com/jwfromm): @jwfromm
- [Siyuan Feng](https://github.com/Hzfengsy): @Hzfengsy
- [Sergei Grechanik](https://github.com/sgrechanik-h): @sgrechanik-h
- [Hao Lu](https://github.com/hlu1): @hlu1
- [Bohan Hou](https://github.com/spectrometerHBH): @spectrometerHBH
- [Nick Hynes](https://github.com/nhynes): @nhynes
- [Yuwei Hu](https://github.com/Huyuwei): @Huyuwei
- [Luke Hutton](https://github.com/lhutton1): @lhutton1
Expand Down
9 changes: 5 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
// NOTE: these lines are scanned by docker/dev_common.sh. Please update the regex as needed. -->
ci_lint = "tlcpack/ci-lint:v0.62"
ci_gpu = "tlcpack/ci-gpu:v0.72"
ci_cpu = "tlcpack/ci-cpu:v0.72-t0"
ci_cpu = "tlcpack/ci-cpu:v0.73"
ci_wasm = "tlcpack/ci-wasm:v0.70"
ci_i386 = "tlcpack/ci-i386:v0.72-t0"
ci_qemu = "tlcpack/ci-qemu:v0.02"
ci_arm = "tlcpack/ci-arm:v0.02"
ci_qemu = "tlcpack/ci-qemu:v0.03"
ci_arm = "tlcpack/ci-arm:v0.03"
// <--- End of regex-scanned config.

// tvm libraries
Expand Down Expand Up @@ -187,7 +187,8 @@ stage('Build') {
sh "${docker_run} ${ci_cpu} ./tests/scripts/task_python_vta_fsim.sh"
sh "${docker_run} ${ci_cpu} ./tests/scripts/task_python_vta_tsim.sh"
// sh "${docker_run} ${ci_cpu} ./tests/scripts/task_golang.sh"
sh "${docker_run} ${ci_cpu} ./tests/scripts/task_rust.sh"
// TODO(@jroesch): need to resolve CI issue will turn back on in follow up patch
// sh "${docker_run} ${ci_cpu} ./tests/scripts/task_rust.sh"
junit "build/pytest-results/*.xml"
}
}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ cpptest:
@mkdir -p $(OUTPUTDIR) && cd $(OUTPUTDIR) && cmake .. && $(MAKE) cpptest

crttest:
@mkdir -p build && cd build && cmake .. && $(MAKE) crttest
@mkdir -p $(OUTPUTDIR) && cd $(OUTPUTDIR) && cmake .. && $(MAKE) crttest

# EMCC; Web related scripts
EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\
EMCC_FLAGS= -std=c++11\
-Oz -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1\
-s TOTAL_MEMORY=1073741824\
-s EXTRA_EXPORTED_RUNTIME_METHODS="['addFunction','cwrap','getValue','setValue']"\
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,7 @@ Rust language support in TVM includes two parts. 1. The frontend wraps the curre
* [topi] enable fp16 sort for arm (#4084)
* Add OpenOCD Low-Level Device (RISC-V Support) (#3756)
* Add wave 32 bc for AMD ROCm backend (#3984)
* [RUTNIME] Support C++ RPC (#4281)
* [RUNTIME] Support C++ RPC (#4281)
* [TOPI][OP] Support Faster-RCNN Proposal OP on CPU (#4297)
* [TVM][RUNTIME] A minimum example to generate external library wrappers for DSOModule (#4280)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import org.apache.tvm.Function;
import org.apache.tvm.Module;
import org.apache.tvm.NDArray;
import org.apache.tvm.TVMContext;
import org.apache.tvm.Device;
import org.apache.tvm.TVMType;
import org.apache.tvm.TVMValue;
import org.json.JSONException;
Expand Down Expand Up @@ -111,7 +111,7 @@ public class Camera2BasicFragment extends Fragment {
private AppCompatTextView mInfoView;
private ListView mModelView;
private AssetManager assetManager;
private Module graphRuntimeModule;
private Module graphExecutorModule;
private JSONObject labels;
private ListenableFuture<ProcessCameraProvider> cameraProviderFuture;
private PreviewView previewView;
Expand Down Expand Up @@ -187,21 +187,21 @@ private String[] getModels() {
private String[] inference(float[] chw) {
NDArray inputNdArray = NDArray.empty(new long[]{1, IMG_CHANNEL, MODEL_INPUT_SIZE, MODEL_INPUT_SIZE}, new TVMType("float32"));
inputNdArray.copyFrom(chw);
Function setInputFunc = graphRuntimeModule.getFunction("set_input");
Function setInputFunc = graphExecutorModule.getFunction("set_input");
setInputFunc.pushArg(INPUT_NAME).pushArg(inputNdArray).invoke();
// release tvm local variables
inputNdArray.release();
setInputFunc.release();

// get the function from the module(run it)
Function runFunc = graphRuntimeModule.getFunction("run");
Function runFunc = graphExecutorModule.getFunction("run");
runFunc.invoke();
// release tvm local variables
runFunc.release();

// get the function from the module(get output data)
NDArray outputNdArray = NDArray.empty(new long[]{1, 1000}, new TVMType("float32"));
Function getOutputFunc = graphRuntimeModule.getFunction("get_output");
Function getOutputFunc = graphExecutorModule.getFunction("get_output");
getOutputFunc.pushArg(OUTPUT_INDEX).pushArg(outputNdArray).invoke();
float[] output = outputNdArray.asFloatArray();
// release tvm local variables
Expand Down Expand Up @@ -272,8 +272,8 @@ public void onActivityCreated(Bundle savedInstanceState) {
@Override
public void onDestroy() {
// release tvm local variables
if (null != graphRuntimeModule)
graphRuntimeModule.release();
if (null != graphExecutorModule)
graphExecutorModule.release();
super.onDestroy();
}

Expand Down Expand Up @@ -516,7 +516,7 @@ private void setInputName(String modelName) {
}

/*
Load precompiled model on TVM graph runtime and init the system.
Load precompiled model on TVM graph executor and init the system.
*/
private class LoadModelAsyncTask extends AsyncTask<Void, Void, Integer> {

Expand Down Expand Up @@ -571,36 +571,36 @@ protected Integer doInBackground(Void... args) {
return -1;//failure
}

Log.i(TAG, "creating java tvm context...");
// create java tvm context
TVMContext tvmCtx = EXE_GPU ? TVMContext.opencl() : TVMContext.cpu();
Log.i(TAG, "creating java tvm device...");
// create java tvm device
Device tvmDev = EXE_GPU ? Device.opencl() : Device.cpu();

Log.i(TAG, "loading compiled functions...");
Log.i(TAG, libCacheFilePath);
// tvm module for compiled functions
Module modelLib = Module.load(libCacheFilePath);


// get global function module for graph runtime
Log.i(TAG, "getting graph runtime create handle...");
// get global function module for graph executor
Log.i(TAG, "getting graph executor create handle...");

Function runtimeCreFun = Function.getFunction("tvm.graph_runtime.create");
Log.i(TAG, "creating graph runtime...");
Function runtimeCreFun = Function.getFunction("tvm.graph_executor.create");
Log.i(TAG, "creating graph executor...");

Log.i(TAG, "ctx type: " + tvmCtx.deviceType);
Log.i(TAG, "ctx id: " + tvmCtx.deviceId);
Log.i(TAG, "device type: " + tvmDev.deviceType);
Log.i(TAG, "device id: " + tvmDev.deviceId);

TVMValue runtimeCreFunRes = runtimeCreFun.pushArg(modelGraph)
.pushArg(modelLib)
.pushArg(tvmCtx.deviceType)
.pushArg(tvmCtx.deviceId)
.pushArg(tvmDev.deviceType)
.pushArg(tvmDev.deviceId)
.invoke();

Log.i(TAG, "as module...");
graphRuntimeModule = runtimeCreFunRes.asModule();
Log.i(TAG, "getting graph runtime load params handle...");
graphExecutorModule = runtimeCreFunRes.asModule();
Log.i(TAG, "getting graph executor load params handle...");
// get the function from the module(load parameters)
Function loadParamFunc = graphRuntimeModule.getFunction("load_params");
Function loadParamFunc = graphExecutorModule.getFunction("load_params");
Log.i(TAG, "loading params...");
loadParamFunc.pushArg(modelParams).invoke();
// release tvm local variables
Expand Down
2 changes: 1 addition & 1 deletion apps/android_camera/app/src/main/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ include $(config)
APP_ABI ?= all
APP_STL := c++_shared

APP_CPPFLAGS += -DTVM4J_ANDROID=1 -std=c++14 -Oz -frtti
APP_CPPFLAGS += -DTVM_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++14 -Oz -frtti
ifeq ($(USE_OPENCL), 1)
APP_CPPFLAGS += -DTVM_OPENCL_RUNTIME=1
endif
Expand Down
5 changes: 3 additions & 2 deletions apps/android_camera/app/src/main/jni/tvm_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <fstream>

#define DMLC_USE_LOGGING_LIBRARY <tvm/runtime/logging.h>
#define TVM_BACKTRACE_DISABLED 1
#define TVM_USE_LIBBACKTRACE 0
/* Enable custom logging - this will cause TVM to use a custom implementation
* of tvm::runtime::detail::LogMessage. We use this to pass TVM log messages to
* Android logcat.
Expand All @@ -37,8 +37,9 @@
#include "../src/runtime/cpu_device_api.cc"
#include "../src/runtime/dso_library.cc"
#include "../src/runtime/file_utils.cc"
#include "../src/runtime/graph/graph_runtime.cc"
#include "../src/runtime/graph_executor/graph_executor.cc"
#include "../src/runtime/library_module.cc"
#include "../src/runtime/logging.cc"
#include "../src/runtime/module.cc"
#include "../src/runtime/ndarray.cc"
#include "../src/runtime/object.cc"
Expand Down
2 changes: 1 addition & 1 deletion apps/android_camera/models/prepare_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import tvm
import tvm.relay as relay
from tvm.contrib import utils, ndk, graph_runtime as runtime
from tvm.contrib import utils, ndk, graph_executor as runtime
from tvm.contrib.download import download_testdata, download

target = "llvm -mtriple=arm64-linux-android"
Expand Down
Loading

0 comments on commit 213886b

Please sign in to comment.