Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Relay][Runtime] Implementation of Relay VM #2889

Merged
merged 30 commits into from
May 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e287bb2
Implement the virtual machine
jroesch May 2, 2019
e5ac94c
Fix rebase build issues
jroesch May 2, 2019
5dfc0e6
Reorganize vm.py and fix allocator bug
jroesch May 2, 2019
97406a2
Remove compiler
jroesch May 2, 2019
4639b74
Remove tests
jroesch May 2, 2019
5c3c163
Remove backend/vm/vm.cc too
jroesch May 2, 2019
e66e807
Fix docs
jroesch May 3, 2019
9a925c7
Fix doc
jroesch May 3, 2019
1863315
Fix doc
jroesch May 3, 2019
d9cb9f4
Add vm docs
jroesch May 6, 2019
60a5c23
Remove change to dead_code.cc
jroesch May 7, 2019
5e29506
Remove Relay logging
jroesch May 7, 2019
4dc4bc0
Remove reduce
jroesch May 7, 2019
3724a21
Update include/tvm/runtime/vm.h
wweic May 7, 2019
1ed746e
Reformat
jroesch May 7, 2019
0a6e4e4
Update include/tvm/runtime/vm.h
wweic May 7, 2019
0a59439
Address feedback
jroesch May 7, 2019
0920565
Update include/tvm/runtime/vm.h
zhiics May 7, 2019
17b16c0
Apply suggestions from code review
zhiics May 7, 2019
35efa9f
Fix a couple outstanding comments
jroesch May 7, 2019
06d9c38
Last couple comments
jroesch May 7, 2019
7f9338e
Update include/tvm/runtime/vm.h
wweic May 7, 2019
a91d224
Address code review feedback
jroesch May 7, 2019
2356ab8
Fix final comment
jroesch May 7, 2019
03f749c
Address comments
wweic May 7, 2019
99510dd
Explicitly delete copy assignment operator
jroesch May 8, 2019
71237c9
Error reporting and example
wweic May 8, 2019
87b0698
add Const
wweic May 8, 2019
cc74bd7
Fix rebase
jroesch May 9, 2019
e9983f4
Pass 3rd arg to fusion
jroesch May 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ tvm_option(USE_LLVM "Build with LLVM, can be set to specific llvm-config path" O
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_RELAY_DEBUG "Building Relay in debug mode..." OFF)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this option USE_RELAY_DEBUG still used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it turns on debugging flags for TVM as well as profiling information.

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)
Expand Down Expand Up @@ -140,7 +141,10 @@ file(GLOB TOPI_SRCS
)
file(GLOB_RECURSE HALIDEIR_SRCS 3rdparty/HalideIR/src/*.cpp)
list(APPEND COMPILER_SRCS ${HALIDEIR_SRCS})
file(GLOB RUNTIME_SRCS src/runtime/*.cc)
file(GLOB RUNTIME_SRCS
src/runtime/*.cc
src/runtime/vm/*.cc
)

# Package runtime rules
if(NOT USE_RTTI)
Expand Down Expand Up @@ -197,6 +201,13 @@ include(cmake/modules/contrib/HybridDump.cmake)
add_library(tvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS})
add_library(tvm_topi SHARED ${TOPI_SRCS})
add_library(tvm_runtime SHARED ${RUNTIME_SRCS})

if(USE_RELAY_DEBUG)
message(STATUS "Building Relay in debug mode...")
set_target_properties(tvm PROPERTIES COMPILE_DEFINITIONS "USE_RELAY_DEBUG")
set_target_properties(tvm PROPERTIES COMPILE_DEFINITIONS "NDEBUG")
endif(USE_RELAY_DEBUG)

if(NOT USE_SGX STREQUAL "OFF")
add_dependencies(tvm sgx_edl)
add_dependencies(tvm_runtime sgx_edl tvm_t)
Expand Down
4 changes: 4 additions & 0 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,7 @@ set(USE_ANTLR OFF)

# Build TSIM for VTA
set(USE_VTA_TSIM OFF)

# Whether use Relay debug mode
set(USE_RELAY_DEBUG OFF)

51 changes: 0 additions & 51 deletions include/tvm/relay/logging.h

This file was deleted.

19 changes: 18 additions & 1 deletion include/tvm/relay/pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,22 @@ TVM_DLL bool AlphaEqual(const Expr& e1, const Expr& e2);
*/
TVM_DLL bool AlphaEqual(const Type& t1, const Type& t2);

/*! \brief Add abstraction over a function
*
* For example: `square` is transformed to
* `fun x -> square x`.
*
* See https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B7-conversion
* for more details.
*
* \param e The original function.
* \param mod The module used for referencing global functions, can be
* None.
*
* \return the new function with abstraction
*/
TVM_DLL Expr EtaExpand(const Expr& e, const Module& mod);

/*! \brief Check that each Var is only bound once.
*
* For example, the expression `let x = 1 in let x = 2 in 3` bound x twice.
Expand Down Expand Up @@ -467,9 +483,10 @@ TVM_DLL Expr FoldConstant(const Expr& expr);
* \brief Fuse operations into expr into seperate functions.
* \param expr The expression.
* \param fuse_opt_level Optimization level.
* \param mod the module.
* \return The optimized expression.
*/
TVM_DLL Expr FuseOps(const Expr& expr, int fuse_opt_level);
TVM_DLL Expr FuseOps(const Expr& expr, int fuse_opt_level, const Module& mod);

/*!
* \brief Apply rewrite rules to rewrite the expr in post DFS order.
Expand Down
2 changes: 1 addition & 1 deletion include/tvm/runtime/c_runtime_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ typedef enum {
kStr = 11U,
kBytes = 12U,
kNDArrayContainer = 13U,
kObject = 14U,
// Extension codes for other frameworks to integrate TVM PackedFunc.
// To make sure each framework's id do not conflict, use first and
// last sections to mark ranges.
Expand All @@ -113,7 +114,6 @@ typedef enum {
// The following section of code is used for non-reserved types.
kExtReserveEnd = 64U,
kExtEnd = 128U,
kObject = 14U,
} TVMTypeCode;

/*!
Expand Down
6 changes: 4 additions & 2 deletions include/tvm/runtime/ndarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,11 @@ class NDArray::Container {
DLContext ctx) {
dl_tensor.data = data;
shape_ = std::move(shape);
dl_tensor.shape = dmlc::BeginPtr(shape);
dl_tensor.ndim = static_cast<int>(shape.size());
dl_tensor.ndim = static_cast<int>(shape_.size());
dl_tensor.shape = dmlc::BeginPtr(shape_);
dl_tensor.dtype = dtype;
dl_tensor.strides = nullptr;
dl_tensor.byte_offset = 0;
dl_tensor.ctx = ctx;
}

Expand Down
Loading