Skip to content

Commit

Permalink
Merge branch 'byoc-mrvl' of https://github.com/ccjoechou/tvm into byo…
Browse files Browse the repository at this point in the history
…c-mrvl
  • Loading branch information
Joe (Chien-Chun) Chou committed Dec 18, 2021
2 parents ecb1b10 + e5aac3a commit 3791f5d
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 27 deletions.
11 changes: 2 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ project(tvm C CXX)

# Utility functions
include(cmake/utils/Utils.cmake)
include(cmake/utils/Summary.cmake)
include(cmake/utils/FindCUDA.cmake)
include(cmake/utils/FindOpenCL.cmake)
include(cmake/utils/FindVulkan.cmake)
Expand Down Expand Up @@ -46,7 +45,6 @@ tvm_option(USE_RELAY_DEBUG "Building Relay in debug mode..." OFF)
tvm_option(USE_RTTI "Build with RTTI" ON)
tvm_option(USE_MSVC_MT "Build with MT" OFF)
tvm_option(USE_MICRO "Build with Micro TVM support" OFF)
tvm_option(USE_MRVL "Build with MRVL TVM support" OFF)
tvm_option(INSTALL_DEV "Install compiler infrastructure" OFF)
tvm_option(HIDE_PRIVATE_SYMBOLS "Compile with -fvisibility=hidden." OFF)
tvm_option(USE_TF_TVMDSOOP "Build with TensorFlow TVMDSOOp" OFF)
Expand Down Expand Up @@ -96,7 +94,8 @@ 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)
tvm_option(SUMMARIZE "Print CMake option summary after configuring" OFF)
tvm_option(USE_MRVL "Build with MRVL TVM support" OFF)
tvm_option(USE_MRVL_RUNTIME "Build with MRVL runtime support" OFF)

# include directories
include_directories(${CMAKE_INCLUDE_PATH})
Expand Down Expand Up @@ -614,8 +613,6 @@ endif()
if(GTEST_FOUND)
file(GLOB_RECURSE TEST_SRCS tests/cpp/*.cc)
add_executable(cpptest ${TEST_SRCS})
# include runtime files for unit testing
target_include_directories(cpptest PUBLIC "src/runtime")
target_link_libraries(cpptest PRIVATE ${TVM_TEST_LIBRARY_NAME} GTest::GTest GTest::Main pthread dl)
set_target_properties(cpptest PROPERTIES EXCLUDE_FROM_ALL 1)
set_target_properties(cpptest PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
Expand Down Expand Up @@ -719,7 +716,3 @@ if(USE_CCACHE) # True for AUTO, ON, /path/to/ccache
# Set the flag for ccache
set(CXX_COMPILER_LAUNCHER PATH_TO_CCACHE)
endif(USE_CCACHE)

if(${SUMMARIZE})
print_summary()
endif()
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ stage('Build') {
)
// sh "${docker_run} ${ci_cpu} ./tests/scripts/task_golang.sh"
// TODO(@jroesch): need to resolve CI issue will turn back on in follow up patch
sh (script: "${docker_run} ${ci_cpu} ./tests/scripts/task_rust.sh", label: "Rust build and test")
//sh (script: "${docker_run} ${ci_cpu} ./tests/scripts/task_rust.sh", label: "Rust build and test")
junit "build/pytest-results/*.xml"
}
}
Expand Down
9 changes: 6 additions & 3 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ set(USE_TENSORRT_RUNTIME OFF)
# Whether use VITIS-AI codegen
set(USE_VITIS_AI OFF)

# Whether use MRVL codegen
set(USE_MRVL OFF)

# Whether use MRVL runtime
set(USE_MRVL_RUNTIME OFF)

# Build Verilator codegen and runtime
set(USE_VERILATOR OFF)

Expand Down Expand Up @@ -361,6 +367,3 @@ set(USE_GTEST AUTO)
# Enable using CUTLASS as a BYOC backend
# Need to have USE_CUDA=ON
set(USE_CUTLASS OFF)

# Enable to show a summary of TVM options
set(SUMMARIZE OFF)
1 change: 1 addition & 0 deletions cmake/modules/LibInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function(add_lib_info src_file)
TVM_INFO_USE_ARM_COMPUTE_LIB="${USE_ARM_COMPUTE_LIB}"
TVM_INFO_USE_ARM_COMPUTE_LIB_GRAPH_EXECUTOR="${USE_ARM_COMPUTE_LIB_GRAPH_EXECUTOR}"
TVM_INFO_USE_MRVL="${USE_MRVL}"
TVM_INFO_USE_MRVL_RUNTIME="${USE_MRVL_RUNTIME}"
TVM_INFO_INDEX_DEFAULT_I64="${INDEX_DEFAULT_I64}"
TVM_CXX_COMPILER_PATH="${CMAKE_CXX_COMPILER}"
)
Expand Down
12 changes: 10 additions & 2 deletions cmake/modules/contrib/Mrvl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
include(ExternalProject)

if(USE_MRVL)
IF (MRVL_COMPILER_LIB_PATH)
if(MRVL_COMPILER_LIB_PATH)
add_definitions(-DTVM_USE_MRVL_COMPILER_LIB=1)
# copy 3 pre-built static lib files of Marvell compiler-backend
# under the MRVL_COMPILER_LIB_PATH directory
Expand All @@ -38,7 +38,7 @@ if(USE_MRVL)
# FIXME: list(APPEND TVM_LINKER_LIBS ${MRVL_LIB})
message(STATUS "Build with 4 Mrvl lib *.a files: ${MRVL_RUNTIME_LIB}")
list(APPEND TVM_RUNTIME_LINKER_LIBS ${MRVL_RUNTIME_LIB})
ENDIF (MRVL_COMPILER_LIB_PATH)
endif(MRVL_COMPILER_LIB_PATH)

# Mrvl Module
message(STATUS "Build with Mrvl support")
Expand All @@ -57,4 +57,12 @@ if(USE_MRVL)
)
list(APPEND COMPILER_SRCS ${COMPILER_MRVL_SRCS})

if(NOT USE_MRVL_RUNTIME)
list(APPEND COMPILER_SRCS ${RUNTIME_MRVL_MODULE})
endif()
endif(USE_MRVL)

if(USE_MRVL_RUNTIME)
# Set flag to detect Marvell runtime support.
add_definitions(-DTVM_RUNTIME_MRVL)
endif(USE_MRVL_RUNTIME)
2 changes: 2 additions & 0 deletions rust/tvm-rt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ use-arm-compute-lib-graph-runtime = ["tvm-sys/use-arm-compute-lib-graph-runtime"
use-tensorrt-codegen = ["tvm-sys/use-tensorrt-codegen"]
use-tensorrt-runtime = ["tvm-sys/use-tensorrt-runtime"]
use-vitis-ai = ["tvm-sys/use-vitis-ai"]
use-mrvl = ["tvm-sys/use-mrvl"]
use-mrvl-runtime = ["tvm-sys/use-mrvl-runtime"]
build-static-runtime = ["tvm-sys/build-static-runtime"]

[dependencies]
Expand Down
2 changes: 2 additions & 0 deletions rust/tvm-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ use-arm-compute-lib-graph-runtime = []
use-tensorrt-codegen = []
use-tensorrt-runtime = []
use-vitis-ai = []
use-mrvl = []
use-mrvl-runtime = []
build-static-runtime = []

[dependencies]
Expand Down
10 changes: 10 additions & 0 deletions rust/tvm-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ fn find_using_tvm_build() -> Result<TVMInstall> {
if cfg!(feature = "use-vitis-ai") {
build_config.settings.use_vitis_ai = Some(true);
}
if cfg!(feature = "use-mrvl") {
// FIXME: do we need to register use_mrvl for the tvm-build v0.24 package
// on crates.io first?
build_config.settings.use_mrvl = CMakeSetting::from_str("on").ok();
}
if cfg!(feature = "use-mrvl-runtime") {
// FIXME: do we need to register use_mrvl_runtime for the tvm-build v0.24 package
// on crates.io first?
build_config.settings.use_mrvl_runtime = CMakeSetting::from_str("on").ok();
}
if cfg!(any(
feature = "static-linking",
feature = "build-static-runtime"
Expand Down
2 changes: 2 additions & 0 deletions rust/tvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ use-arm-compute-lib-graph-runtime = ["tvm-rt/use-arm-compute-lib-graph-runtime"]
use-tensorrt-codegen = ["tvm-rt/use-tensorrt-codegen"]
use-tensorrt-runtime = ["tvm-rt/use-tensorrt-runtime"]
use-vitis-ai = ["tvm-rt/use-vitis-ai"]
use-mrvl = ["tvm-rt/use-mrvl"]
use-mrvl-runtime = ["tvm-rt/use-mrvl-runtime"]

[dependencies.tvm-rt]
version = "0.1.0-alpha"
Expand Down
12 changes: 9 additions & 3 deletions src/relay/backend/contrib/mrvl/codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -869,11 +869,17 @@ runtime::Module MrvlCompiler(const ObjectRef& ref) {
TVM_REGISTER_GLOBAL("relay.ext.mrvl").set_body_typed(MrvlCompiler);

/*!
* \brief Check whether Mrvl graph executor is used.
* \brief Check whether Mrvl runtime is used.
*
* \return True if Mrvl graph executor is enabled, False if not.
* \return True if Mrvl runtime is enabled, False if not.
*/
inline constexpr bool IsMrvlRuntimeEnabled() { return true; }
inline constexpr bool IsMrvlRuntimeEnabled() {
#if TVM_RUNTIME_MRVL
return true;
#else
return false;
#endif
}

TVM_REGISTER_GLOBAL("relay.op.is_mrvl_runtime_enabled").set_body_typed(IsMrvlRuntimeEnabled);

Expand Down
4 changes: 2 additions & 2 deletions src/runtime/contrib/mrvl/mrvl_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ class MrvlRuntime : public JSONRuntimeBase {

void Run() override {
LOG(FATAL) << "Cannot call run on Mrvl module without runtime enabled. "
<< "Please build with USE_MRVL_GRAPH_EXECUTOR.";
<< "Please build with USE_MRVL_RUNTIME (which is not supported yet).";
}

void BuildEngine() {
LOG(WARNING) << "Mrvl engine is not initialized. "
<< "Please build with USE_MRVL_GRAPH_EXECUTOR.";
<< "Please build with USE_MRVL_RUNTIME (which is not supported yet).";
}
};

Expand Down
9 changes: 9 additions & 0 deletions src/support/libinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@
#define TVM_INFO_USE_ARM_COMPUTE_LIB_GRAPH_EXECUTOR "NOT-FOUND"
#endif

#ifndef TVM_INFO_USE_MRVL
#define TVM_INFO_USE_MRVL "NOT-FOUND"
#endif

#ifndef TVM_INFO_USE_MRVL_RUNTIME
#define TVM_INFO_USE_MRVL_RUNTIME "NOT-FOUND"
#endif

#ifndef TVM_INFO_INDEX_DEFAULT_I64
#define TVM_INFO_INDEX_DEFAULT_I64 "NOT-FOUND"
#endif
Expand Down Expand Up @@ -276,6 +284,7 @@ TVM_DLL Map<String, String> GetLibInfo() {
{"USE_ARM_COMPUTE_LIB", TVM_INFO_USE_ARM_COMPUTE_LIB},
{"USE_ARM_COMPUTE_LIB_GRAPH_EXECUTOR", TVM_INFO_USE_ARM_COMPUTE_LIB_GRAPH_EXECUTOR},
{"USE_MRVL", TVM_INFO_USE_MRVL},
{"USE_MRVL_RUNTIME", TVM_INFO_USE_MRVL_RUNTIME},
{"INDEX_DEFAULT_I64", TVM_INFO_INDEX_DEFAULT_I64},
{"TVM_CXX_COMPILER_PATH", TVM_CXX_COMPILER_PATH}};
return result;
Expand Down
3 changes: 2 additions & 1 deletion tests/cpp/runtime/hexagon_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
* under the License.
*/

#include "../src/runtime/hexagon/hexagon/hexagon_buffer.h"

#include <gtest/gtest.h>
#include <hexagon/hexagon/hexagon_buffer.h>
#include <tvm/runtime/container/optional.h>

using namespace tvm::runtime;
Expand Down
10 changes: 4 additions & 6 deletions tests/python/contrib/test_mrvl/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ def skip_aot_runtime_test():
# Mrvl codegen not present.
if skip_json_codegen_test():
return True

# TODO(ccjoechou): add real code
# Remote device is in use or Mrvl runtime not present
# Note: Ensure that the device config has been loaded before this check
print("Skip because Mrvl runtime isn't present or a remote device isn't being used.")
return True
if not mrvl.is_mrvl_runtime_enabled():
print("Skip because Mrvl runtime isn't present or a remote device isn't being used.")
return True
return False


def aot_build_and_json_codegen(
Expand Down

0 comments on commit 3791f5d

Please sign in to comment.