Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into ast-dump
Browse files Browse the repository at this point in the history
  • Loading branch information
chiwwang committed Oct 25, 2021
2 parents f59a3fe + aa38997 commit fb2cf61
Show file tree
Hide file tree
Showing 351 changed files with 12,142 additions and 5,176 deletions.
14 changes: 14 additions & 0 deletions .asf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,17 @@ github:
- vulkan
- spirv
- machine-learning

# Triage perm for collaborators(test run)
#
# The perm is given based on needs and not based on
# evaluation of past contributions. The rationale
# is that people may need the permission to start
# contributing in this way. It serves to diversify
# the ways to contribute.
#
# There is a limited number of slots. To enable broad
# participation, permission is given on a three month
# cycle. PMC may review and recycle slots when necessary.
collaborators:
- denise-k
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ if(USE_CCACHE) # True for AUTO, ON, /path/to/ccache
message(STATUS "Found the path to ccache, enabling ccache")
set(PATH_TO_CCACHE ccache)
else()
message(FATAL_ERROR "Cannot find ccache. Set USE_CCACHE mode to AUTO or OFF to build without ccache. USE_CCACHE=" "${USE_CCACHE")
message(FATAL_ERROR "Cannot find ccache. Set USE_CCACHE mode to AUTO or OFF to build without ccache. USE_CCACHE=" "${USE_CCACHE}")
endif(CCACHE_FOUND)
else() # /path/to/ccache
set(PATH_TO_CCACHE USE_CCACHE)
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ We do encourage everyone to work anything they are interested in.
- [Andrew Z. Luo](https://github.com/AndrewZhaoLuo): @AndrewZhaoLuo
- [Steven Lyubomirsky](https://github.com/slyubomirsky): @slyubomirsky
- [Masahiro Masuda](https://github.com/masahi): @masahi
- [Andrey Malyshev](https://github.com/elvin-n): @elvin-n
- [Sergey Mironov](https://github.com/grwlf): @grwlf
- [Thierry Moreau](https://github.com/tmoreau89): @tmoreau89
- [Kazutaka Morita](https://github.com/kazum): @kazum
- [Trevor Morris](https://github.com/trevor-m): @trevor-m
- [Tatsuya Nishiyama](https://github.com/nishi-t): @nishi-t
- [Leandro Nunes](https://github.com/leandron): @leandron
- [Jiawei Liu](https://github.com/ganler): @ganler
- [Lily Orth-Smith](https://github.com/electriclilies): @electriclilies
- [Wei Pan](https://github.com/wpan11nv): @wpan11nv
- [Krzysztof Parzyszek](https://github.com/kparzysz-quic): @kparzysz-quic
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TVM is licensed under the [Apache-2.0](LICENSE) license.
Getting Started
---------------
Check out the [TVM Documentation](https://tvm.apache.org/docs/) site for installation instructions, tutorials, examples, and more.
The [Getting Started with TVM](https://tvm.apache.org/docs/tutorials/get_started/introduction.html) tutorial is a great
The [Getting Started with TVM](https://tvm.apache.org/docs/tutorial/introduction.html) tutorial is a great
place to start.

Contribute to TVM
Expand Down
4 changes: 3 additions & 1 deletion apps/bundle_deploy/crt_config/crt_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
/*! Maximum supported string length in dltype, e.g. "int8", "int16", "float32" */
#define TVM_CRT_MAX_STRLEN_DLTYPE 10
/*! Maximum supported string length in function names */
#define TVM_CRT_MAX_STRLEN_FUNCTION_NAME 80
#define TVM_CRT_MAX_STRLEN_FUNCTION_NAME 120
/*! Maximum supported string length in parameter names */
#define TVM_CRT_MAX_STRLEN_PARAM_NAME 80

/*! Maximum number of registered modules. */
#define TVM_CRT_MAX_REGISTERED_MODULES 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
## Compilation

The launcher consists of two parts: part running on Hexagon, and part running
on Android. They need to be compiled separately. Since some source files are
shared between these two parts, make sure to delete all object files between
compilations. Compile the Hexagon code first.
on Android. Each component must be compiled separately.

The supported Snapdragon architectures are 855, 865, and 888.

Expand All @@ -33,45 +31,89 @@ The supported Snapdragon architectures are 855, 865, and 888.
Android NDK can be downloaded from https://developer.android.com/ndk.
Hexagon SDK is available at //developer.qualcomm.com/software/hexagon-dsp-sdk.

### Compilation of the Hexagon part
### Compilation with TVM

1. Build the static version of TVM runtime for Hexagon. Use Hexagon clang
from the Hexagon SDK. This step is the same as building the shared version,
except at the cmake step, add `-DBUILD_STATIC_RUNTIME=ON`. The compilation
step should create `libtvm_runtime.a`.
Building the Hexagon launcher application as a component of the main TVM build
used for Hexagon codegen can be achieved by setting `USE_HEXAGON_LAUNCHER=ON`.
This option will compile core tvm, the android launcher binary and its corresponding
tvm_runtime, as well as the Hexagon launcher shared library and its corresponding
tvm_runtime. As described in the [Manual compilation](#Manual compilation) section
each component requires Hexagon and android dependencies. When building the launcher
along with TVM these configurations must be providing when invoking cmake. A minimal
example invocation for compiling TVM along with the Hexagon launcher is included below:

2. Create a subdirectory for the build files, and run `cmake` with the
following variables set:
- `FASTRPC_LIBS=SKEL`
- `USE_HEXAGON_SDK` to the path to the Hexagon SDK
- `CMAKE_C_COMPILER=hexagon-clang`
- `CMAKE_CXX_COMPILER=hexagon-clang++`
- `USE_HEXAGON_ARCH` to one of v65, v66, v68
- `TVM_RUNTIME_HEXAGON=/path/to/libtvm_runtime.a` _statically_ linked
TVM runtime
```
cmake -DCMAKE_C_COMPILER=/path/to/clang \
-DCMAKE_CXX_COMPILER=/path/to/clang++ \
-DCMAKE_CXX_FLAGS='-stdlib=libc++' \
-DCMAKE_CXX_STANDARD=14 \
-DUSE_LLVM=/path/to/llvm/bin/llvm-config \
-DUSE_HEXAGON_ARCH=v65|v66|v68 \
-DUSE_HEXAGON_LAUNCHER=ON \
-DUSE_HEXAGON_SDK=/path/to/hexagon/SDK \
-DUSE_HEXAGON_TOOLCHAIN=/path/to/hexagon/toolchain/ ..
-DANDROID_ABI=arm64-v8a \
-DANDROID_PLATFORM=android-28 \
-DUSE_ANDROID_TOOLCHAIN=/path/to/android-ndk/build/cmake/android.toolchain.cmake \
..
```

where `v65|v66|v68` means "one of" these architecture versions.
The Hexagon launcher application is an android binary and thus requires the use
of an android toolchain for compilation. Similarly, the Hexagon tvm runtime
requires the use of the Hexagon toolchain and depends on the Hexagon SDK. The
resulting hexagon launcher binaries can be found in the `apps_hexagon_launcher`
subdirectory of the cmake build directory. Please note that the above command
will not build support for Hexagon codegen in the TVM library, for that please
additionally define the `USE_HEXAGON_DEVICE` variable. Also, the LLVM used in
`USE_LLVM` should have Hexagon target built in.

### Manual compilation

Make sure to provide the path to launcher's `CMakeLists.txt` directory
in `cmake` invocation.
Since some source files are shared between the Hexagon and android builds,
make sure to delete all object files between compilations. Compile the Hexagon
code first.

3. Run `make`. This will create `liblauncher_rpc_skel.so`.
#### Compilation of the Hexagon part

Create a subdirectory for the build files, and run `cmake` with the
following variables set:

```
cmake -DCMAKE_C_COMPILER=/path/to/hexagon-clang \
-DCMAKE_CXX_COMPILER=/path/to/hexagon-clang++ \
-DUSE_HEXAGON_ARCH=v65|v66|v68 \
-DUSE_HEXAGON_SDK=/path/to/hexagon/SDK \
/path/to/apps/hexagon_launcher/cmake/hexagon
```

### Compilation of the Android part
Run `make`. This will create `liblauncher_rpc_skel.so`. The static version of
the TVM runtime for Hexagon will be built as a part of the process.

1. Build TVM runtime for Android, using clang for AArch64 from the Android
NDK. Unlike in the Hexagon case, this should be the dynamic library (which
is the default), i.e. `libtvm_runtime.so`.
#### Compilation of the Android part

2. Create a subdirectory for the build files (different from the one used for
Hexagon files), and run `cmake` with the following variables set:
- `FASTRPC_LIBS=STUB`
- `USE_HEXAGON_SDK` to the path to the Hexagon SDK
- `CMAKE_C_COMPILER=aarch64-linux-android28-clang` (or later)
- `CMAKE_CXX_COMPILER=aarch64-linux-android28-clang++` (or later)
- `USE_HEXAGON_ARCH` to one of v65, v66, v68 (same as for the Hexagon part)
- `TVM_RUNTIME_ANDROID=/path/to/libtvm_runtime.so` dynamically or
statically linked TVM runtime

3. Run `make`. This will create `launcher_android`.

```
cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/android-ndk/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=arm64-v8a \
-DANDROID_PLATFORM=android-28 \
-DUSE_HEXAGON_SDK=/p/Hexagon_SDK/4.3.0.0
-DUSE_HEXAGON_ARCH=v65|v66|v68
/path/to/apps/hexagon_launcher/cmake/android
```

Run `make`. This will create `launcher_android`. The TVM runtime for Android will
be built as a part of the process. Depending on the version of cmake that you are
using, you may see the following warnings---they can be ignored.

```
An old version of CMake is being used that cannot automatically detect
compiler attributes. Compiler identification is being bypassed. Some
values may be wrong or missing. Update to CMake 3.19 or newer to use
CMake's built-in compiler identification.
```

## Execution

Expand Down
56 changes: 56 additions & 0 deletions apps/hexagon_launcher/cmake/HexagonLauncher.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 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(NOT DEFINED USE_HEXAGON_SDK)
message(SEND_ERROR "Please set USE_HEXAGON_SDK to the location of Hexagon SDK")
endif()
if (NOT DEFINED USE_HEXAGON_ARCH)
message(SEND_ERROR "Please set USE_HEXAGON_ARCH to the Hexagon architecture version")
endif()

set(TVM_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../")

include(ExternalProject)
include("${TVM_SOURCE_DIR}/cmake/modules/HexagonSDK.cmake")

find_hexagon_sdk_root("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}")

include_directories(SYSTEM ${HEXAGON_SDK_INCLUDES} ${HEXAGON_REMOTE_ROOT})

set(QAIC_EXE "${HEXAGON_QAIC_EXE}")
foreach(INCDIR IN LISTS HEXAGON_SDK_INCLUDES HEXAGON_REMOTE_ROOT)
list(APPEND QAIC_FLAGS "-I${INCDIR}")
endforeach()

set(LAUNCHER_SRC "${CMAKE_CURRENT_SOURCE_DIR}/../../")
set(CMAKE_SKIP_RPATH TRUE)

# Qaic for the domain header.
#
# Don't add paths to these filenames, or otherwise cmake may spontaneously
# add -o option to the qaic invocation (with an undesirable path).
set(LAUNCHER_RPC_IDL "launcher_rpc.idl")
set(LAUNCHER_RPC_H "launcher_rpc.h")
set(LAUNCHER_RPC_SKEL_C "launcher_rpc_skel.c")
set(LAUNCHER_RPC_STUB_C "launcher_rpc_stub.c")

include_directories(
"${LAUNCHER_SRC}"
"${TVM_SOURCE_DIR}/include"
"${TVM_SOURCE_DIR}/3rdparty/dlpack/include"
"${TVM_SOURCE_DIR}/3rdparty/dmlc-core/include"
)
78 changes: 78 additions & 0 deletions apps/hexagon_launcher/cmake/android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 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.

cmake_minimum_required(VERSION 3.2)
project(HexagonAndroidLauncher C CXX)

include("${CMAKE_CURRENT_SOURCE_DIR}/../HexagonLauncher.cmake")

add_custom_command(
OUTPUT ${LAUNCHER_RPC_STUB_C} ${LAUNCHER_RPC_H}
COMMAND ${QAIC_EXE} ${QAIC_FLAGS} "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}"
MAIN_DEPENDENCY "${LAUNCHER_SRC}/${LAUNCHER_RPC_IDL}"
)

include_directories(SYSTEM
"${HEXAGON_SDK_INCLUDES}"
"${HEXAGON_RPCMEM_ROOT}/inc"
"${CMAKE_CURRENT_BINARY_DIR}" # Output of qaic will go here
)

link_directories(${HEXAGON_REMOTE_ROOT})

add_definitions(-DDMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)

set(STUB_SRCS
"${LAUNCHER_SRC}/launcher_android.cc"
"${LAUNCHER_SRC}/launcher_core.cc"
"${LAUNCHER_SRC}/launcher_main.cc"
"${LAUNCHER_SRC}/launcher_util.cc"
)

add_executable(launcher_android
"${LAUNCHER_RPC_H}"
"${LAUNCHER_RPC_STUB_C}"
"${STUB_SRCS}"
)

ExternalProject_Add(android_tvm_runtime
SOURCE_DIR "${TVM_SOURCE_DIR}"
BUILD_COMMAND $(MAKE) runtime
CMAKE_ARGS
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
"-DANDROID_PLATFORM=${ANDROID_PLATFORM}"
"-DANDROID_ABI=${ANDROID_ABI}"
"-DCMAKE_CXX_STANDARD=14"
"-DUSE_LIBBACKTRACE=OFF"
"-DUSE_LLVM=OFF"
"-DUSE_RPC=OFF"
INSTALL_COMMAND ""
BUILD_ALWAYS ON
)
ExternalProject_Get_Property(android_tvm_runtime BINARY_DIR)
ExternalProject_Add_Step(android_tvm_runtime copy_binaries
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${BINARY_DIR}/libtvm_runtime.so
${CMAKE_CURRENT_BINARY_DIR}
DEPENDEES install
)

add_dependencies(launcher_android android_tvm_runtime)
add_library(a_tvm_runtime SHARED IMPORTED)
set_target_properties(a_tvm_runtime PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/libtvm_runtime.so")

target_link_libraries(launcher_android cdsprpc log a_tvm_runtime)
Loading

0 comments on commit fb2cf61

Please sign in to comment.