Skip to content

Commit

Permalink
[BYOC][CONTRIB] Vitis-AI codegen integration (apache#6343)
Browse files Browse the repository at this point in the history
* [BYOC][CONTRIB] VITIS-AI integration

* Remove environment related files

* Update vitis_ai.rst

* Add review changes

* Remove new lines and note frame in vitis_ai.rst

* use sys.exit

* Add condition for vitis_ai runtime exec function

* remove unused graph_json

* correct indentation

* use code python instead of bash

* Rename VITISAI.cmake to VitisAI.cmake

* use relay.ext.vitis_ai.options.build_dir in comparison

* Re-add deleted docker related files

* Make use of PyXIR XGraph and RuntimeModule serialization & refactor flow

* Fix linter errors

* Fix linter errors

* Address sphinx warnings

* Add infertype to fix Vitis-AI annotation test

* Renaming util to utils

* Add Vitis-AI flag to config.cmake file

* Move vitis-ai config options to compiler sources instead of runtime sources

* Fix clang-format errors

Co-authored-by: Anil Martha <[email protected]>
Co-authored-by: anilm (generated by with_the_same_user script) <[email protected]>
Co-authored-by: Jorn Tuyls <[email protected]>
  • Loading branch information
4 people authored and Trevor Morris committed Dec 4, 2020
1 parent 875a561 commit f5805e5
Show file tree
Hide file tree
Showing 15 changed files with 1,924 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ tvm_option(USE_ARM_COMPUTE_LIB_GRAPH_RUNTIME "Build with Arm Compute Library gra
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)
tvm_option(USE_VITIS_AI "Build with VITIS-AI Codegen support" OFF)

# include directories
include_directories(${CMAKE_INCLUDE_PATH})
Expand Down Expand Up @@ -367,6 +368,7 @@ include(cmake/modules/contrib/CoreML.cmake)
include(cmake/modules/contrib/ONNX.cmake)
include(cmake/modules/contrib/ArmComputeLib.cmake)
include(cmake/modules/contrib/TensorRT.cmake)
include(cmake/modules/contrib/VitisAI.cmake)
include(cmake/modules/Git.cmake)
include(cmake/modules/LibInfo.cmake)
include(cmake/modules/RustExt.cmake)
Expand Down
3 changes: 3 additions & 0 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ set(USE_ETHOSN_HW OFF)
set(USE_TENSORRT_CODEGEN OFF)
set(USE_TENSORRT_RUNTIME OFF)

# Whether use VITIS-AI codegen
set(USE_VITIS_AI OFF)

# Build ANTLR parser for Relay text format
# Possible values:
# - ON: enable ANTLR by searching default locations (cmake find_program for antlr4 and /usr/local for jar)
Expand Down
47 changes: 47 additions & 0 deletions cmake/modules/contrib/VitisAI.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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.

if(USE_VITIS_AI)
set(PYXIR_SHARED_LIB libpyxir.so)
find_package(PythonInterp 3.6 REQUIRED)
if(NOT PYTHON)
find_program(PYTHON NAMES python3 python3.6)
endif()
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
"import pyxir as px; print(px.get_include_dir()); print(px.get_lib_dir());"
RESULT_VARIABLE __result
OUTPUT_VARIABLE __output
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(__result MATCHES 0)
string(REGEX REPLACE ";" "\\\\;" __values ${__output})
string(REGEX REPLACE "\r?\n" ";" __values ${__values})
list(GET __values 0 PYXIR_INCLUDE_DIR)
list(GET __values 1 PYXIR_LIB_DIR)
else()
message(FATAL_ERROR "Can't build TVM with Vitis-AI because PyXIR can't be found")
endif()
message(STATUS "Build with contrib.vitisai")
include_directories(${PYXIR_INCLUDE_DIR})
file(GLOB VAI_CONTRIB_SRC src/runtime/contrib/vitis_ai/*.cc)
file(GLOB COMPILER_VITIS_AI_SRCS
CONFIGURE_DEPENDS src/relay/backend/contrib/vitis_ai/*)
list(APPEND COMPILER_SRCS ${COMPILER_VITIS_AI_SRCS})
link_directories(${PYXIR_LIB_DIR})
list(APPEND TVM_RUNTIME_LINKER_LIBS "pyxir")
list(APPEND RUNTIME_SRCS ${VAI_CONTRIB_SRC})
endif(USE_VITIS_AI)
1 change: 1 addition & 0 deletions docs/deploy/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ target device without relying on RPC. see the following resources on how to do s
hls
arm_compute_lib
tensorrt
vitis_ai
Loading

0 comments on commit f5805e5

Please sign in to comment.