-
Notifications
You must be signed in to change notification settings - Fork 626
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enhancement] Support tvm 1.x (#1531)
* support tvm 1.x * fix tvm sdk export
- Loading branch information
Showing
57 changed files
with
2,316 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
cann | ||
CANN | ||
nd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
|
||
if (NOT DEFINED TVM_DIR) | ||
set(TVM_DIR $ENV{TVM_DIR}) | ||
endif () | ||
if (NOT TVM_DIR) | ||
message(FATAL_ERROR "Please set TVM_DIR with cmake -D option.") | ||
endif() | ||
|
||
find_path( | ||
TVM_INCLUDE_DIR tvm/runtime/c_runtime_api.h | ||
HINTS ${TVM_DIR} | ||
PATH_SUFFIXES include) | ||
|
||
find_path( | ||
DMLC_CORE_INCLUDE_DIR dmlc/io.h | ||
HINTS ${TVM_DIR}/3rdparty/dmlc-core | ||
PATH_SUFFIXES include) | ||
|
||
find_path( | ||
DLPACK_INCLUDE_DIR dlpack/dlpack.h | ||
HINTS ${TVM_DIR}/3rdparty/dlpack | ||
PATH_SUFFIXES include) | ||
|
||
find_library( | ||
TVM_LIBRARY_PATH tvm_runtime | ||
HINTS ${TVM_DIR} | ||
PATH_SUFFIXES build lib build/${CMAKE_BUILD_TYPE}) | ||
if (NOT (TVM_INCLUDE_DIR AND DMLC_CORE_INCLUDE_DIR AND DLPACK_INCLUDE_DIR AND TVM_LIBRARY_PATH)) | ||
message(FATAL_ERROR "Couldn't find tvm in TVM_DIR: " | ||
"${TVM_DIR}, please check if the path is correct.") | ||
endif() | ||
|
||
add_library(tvm_runtime SHARED IMPORTED) | ||
set_property(TARGET tvm_runtime APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) | ||
if (MSVC) | ||
set_target_properties(tvm_runtime PROPERTIES | ||
IMPORTED_IMPLIB_RELEASE ${TVM_LIBRARY_PATH} | ||
INTERFACE_INCLUDE_DIRECTORIES ${TVM_INCLUDE_DIR} ${DMLC_CORE_INCLUDE_DIR} ${DLPACK_INCLUDE_DIR} | ||
) | ||
|
||
else() | ||
set_target_properties(tvm_runtime PROPERTIES | ||
IMPORTED_LOCATION_RELEASE ${TVM_LIBRARY_PATH} | ||
INTERFACE_INCLUDE_DIRECTORIES ${TVM_INCLUDE_DIR} ${DMLC_CORE_INCLUDE_DIR} ${DLPACK_INCLUDE_DIR} | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
backend_config = dict(type='tvm') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
_base_ = ['./classification_static.py', '../_base_/backends/tvm.py'] | ||
|
||
onnx_config = dict(input_shape=[224, 224]) | ||
backend_config = dict(model_inputs=[ | ||
dict( | ||
shape=dict(input=[1, 3, 224, 224]), | ||
dtype=dict(input='float32'), | ||
tuner=dict( | ||
type='AutoScheduleTuner', | ||
log_file='tvm_tune_log.log', | ||
num_measure_trials=2000)) | ||
]) |
16 changes: 16 additions & 0 deletions
16
configs/mmcls/classification_tvm-autotvm-int8_static-224x224.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
_base_ = ['./classification_tvm-autotvm_static-224x224.py'] | ||
|
||
calib_config = dict(create_calib=True, calib_file='calib_data.h5') | ||
backend_config = dict(model_inputs=[ | ||
dict( | ||
shape=dict(input=[1, 3, 224, 224]), | ||
dtype=dict(input='float32'), | ||
tuner=dict( | ||
type='AutoTVMTuner', | ||
log_file='tvm_tune_log.log', | ||
n_trial=1000, | ||
tuner=dict(type='XGBTuner'), | ||
), | ||
qconfig=dict(calibrate_mode='kl_divergence', weight_scale='max'), | ||
) | ||
]) |
14 changes: 14 additions & 0 deletions
14
configs/mmcls/classification_tvm-autotvm_static-224x224.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
_base_ = ['./classification_static.py', '../_base_/backends/tvm.py'] | ||
|
||
onnx_config = dict(input_shape=[224, 224]) | ||
backend_config = dict(model_inputs=[ | ||
dict( | ||
shape=dict(input=[1, 3, 224, 224]), | ||
dtype=dict(input='float32'), | ||
tuner=dict( | ||
type='AutoTVMTuner', | ||
log_file='tvm_tune_log.log', | ||
n_trial=1000, | ||
tuner=dict(type='XGBTuner'), | ||
)) | ||
]) |
13 changes: 13 additions & 0 deletions
13
configs/mmdet/detection/detection_tvm-ansor_static-800x1344.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
_base_ = ['../_base_/base_static.py', '../../_base_/backends/tvm.py'] | ||
|
||
onnx_config = dict(input_shape=[1344, 800]) | ||
backend_config = dict(model_inputs=[ | ||
dict( | ||
use_vm=True, | ||
shape=dict(input=[1, 3, 800, 1344]), | ||
dtype=dict(input='float32'), | ||
tuner=dict( | ||
type='AutoScheduleTuner', | ||
log_file='tvm_tune_log.log', | ||
num_measure_trials=2000)) | ||
]) |
15 changes: 15 additions & 0 deletions
15
configs/mmdet/detection/detection_tvm-autotvm_static-300x300.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
_base_ = ['../_base_/base_static.py', '../../_base_/backends/tvm.py'] | ||
|
||
onnx_config = dict(input_shape=[300, 300]) | ||
backend_config = dict(model_inputs=[ | ||
dict( | ||
use_vm=True, | ||
shape=dict(input=[1, 3, 300, 300]), | ||
dtype=dict(input='float32'), | ||
tuner=dict( | ||
type='AutoTVMTuner', | ||
log_file='tvm_tune_log.log', | ||
n_trial=1000, | ||
tuner=dict(type='XGBTuner'), | ||
)) | ||
]) |
15 changes: 15 additions & 0 deletions
15
configs/mmdet/detection/detection_tvm-autotvm_static-800x1344.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
_base_ = ['../_base_/base_static.py', '../../_base_/backends/tvm.py'] | ||
|
||
onnx_config = dict(input_shape=[1344, 800]) | ||
backend_config = dict(model_inputs=[ | ||
dict( | ||
use_vm=True, | ||
shape=dict(input=[1, 3, 800, 1344]), | ||
dtype=dict(input='float32'), | ||
tuner=dict( | ||
type='AutoTVMTuner', | ||
log_file='tvm_tune_log.log', | ||
n_trial=1000, | ||
tuner=dict(type='XGBTuner'), | ||
)) | ||
]) |
15 changes: 15 additions & 0 deletions
15
configs/mmdet/instance-seg/instance-seg_tvm-ansor_static-800x1344.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
_base_ = [ | ||
'../_base_/base_instance-seg_static.py', '../../_base_/backends/tvm.py' | ||
] | ||
|
||
onnx_config = dict(input_shape=[1344, 800]) | ||
backend_config = dict(model_inputs=[ | ||
dict( | ||
use_vm=True, | ||
shape=dict(input=[1, 3, 800, 1344]), | ||
dtype=dict(input='float32'), | ||
tuner=dict( | ||
type='AutoScheduleTuner', | ||
log_file='tvm_tune_log.log', | ||
num_measure_trials=20000)) | ||
]) |
17 changes: 17 additions & 0 deletions
17
configs/mmdet/instance-seg/instance-seg_tvm-autotvm_static-800x1344.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
_base_ = [ | ||
'../_base_/base_instance-seg_static.py', '../../_base_/backends/tvm.py' | ||
] | ||
|
||
onnx_config = dict(input_shape=[1344, 800]) | ||
backend_config = dict(model_inputs=[ | ||
dict( | ||
use_vm=True, | ||
shape=dict(input=[1, 3, 800, 1344]), | ||
dtype=dict(input='float32'), | ||
tuner=dict( | ||
type='AutoTVMTuner', | ||
log_file='tvm_tune_log.log', | ||
n_trial=10000, | ||
tuner=dict(type='XGBTuner'), | ||
)) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
_base_ = ['./segmentation_static.py', '../_base_/backends/tvm.py'] | ||
|
||
onnx_config = dict(input_shape=[1024, 512]) | ||
backend_config = dict(model_inputs=[ | ||
dict( | ||
shape=dict(input=[1, 3, 512, 1024]), | ||
dtype=dict(input='float32'), | ||
tuner=dict( | ||
type='AutoScheduleTuner', | ||
log_file='tvm_tune_log.log', | ||
num_measure_trials=2000)) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
_base_ = ['./segmentation_static.py', '../_base_/backends/tvm.py'] | ||
|
||
onnx_config = dict(input_shape=[1024, 512]) | ||
backend_config = dict(model_inputs=[ | ||
dict( | ||
shape=dict(input=[1, 3, 512, 1024]), | ||
dtype=dict(input='float32'), | ||
tuner=dict( | ||
type='AutoTVMTuner', | ||
log_file='tvm_tune_log.log', | ||
n_trial=1000, | ||
tuner=dict(type='XGBTuner'))) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
|
||
project(mmdeploy_tvm_net) | ||
|
||
include(${CMAKE_SOURCE_DIR}/cmake/modules/FindTVM.cmake) | ||
|
||
mmdeploy_add_module(${PROJECT_NAME} tvm_net.cpp) | ||
target_include_directories(${PROJECT_NAME} PRIVATE ${TVM_INCLUDE_DIR} ${DLPACK_INCLUDE_DIR} ${DMLC_CORE_INCLUDE_DIR}) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE tvm_runtime mmdeploy_dlpack_utils) | ||
|
||
add_library(mmdeploy::tvm_net ALIAS ${PROJECT_NAME}) |
Oops, something went wrong.