Skip to content

Commit

Permalink
[Unity] Merge with upstream after rebasing onto TVM main (apache#44)
Browse files Browse the repository at this point in the history
This PR is another merge with tvm/unity. The key difference between this and apache#41 is that this merge takes place after `tvm/unity` rebased on top of `tvm/main`. As can be seen, this causes the number of touched files to be quite a bit longer. However, I think this is still likely a more useful history than rebasing.
  • Loading branch information
Josh Fromm committed Mar 7, 2023
1 parent 1c7baff commit 34635ed
Show file tree
Hide file tree
Showing 275 changed files with 14,367 additions and 2,980 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/cutlass
Submodule cutlass updated 25 files
+1 −1 docs/annotated.html
+1 −1 docs/default__mma__core__simt_8h_source.html
+1 −1 docs/hierarchy.html
+1 −1 docs/namespacecutlass_1_1transform.html
+1 −1 docs/pitch__linear__thread__map_8h.html
+1 −1 docs/pitch__linear__thread__map_8h_source.html
+1 −1 docs/structcutlass_1_1transform_1_1TransposePitchLinearThreadMap2DThreadTile.html
+46 −7 examples/41_fused_multi_head_attention/debug_utils.h
+6 −6 examples/41_fused_multi_head_attention/default_fmha_grouped.h
+0 −0 examples/41_fused_multi_head_attention/epilogue/epilogue_pipelined.h
+0 −0 examples/41_fused_multi_head_attention/epilogue/epilogue_rescale_output.h
+0 −0 examples/41_fused_multi_head_attention/epilogue/epilogue_thread_apply_logsumexp.h
+132 −11 examples/41_fused_multi_head_attention/fmha_grouped.h
+7 −2 examples/41_fused_multi_head_attention/fused_multihead_attention_fixed_seqlen.cu
+2 −0 examples/41_fused_multi_head_attention/gemm/find_default_mma.h
+17 −152 examples/41_fused_multi_head_attention/gemm/mma_accum_lambda_iterator.h
+263 −23 examples/41_fused_multi_head_attention/gemm/mma_from_smem.h
+437 −52 examples/41_fused_multi_head_attention/kernel_forward.h
+88 −0 examples/41_fused_multi_head_attention/transform/tile_smem_loader.h
+1 −1 include/cutlass/gemm/device/base_grouped.h
+52 −126 include/cutlass/gemm/kernel/gemm_universal_streamk.h
+2 −9 include/cutlass/gemm/threadblock/threadblock_swizzle_streamk.h
+1 −1 include/cutlass/transform/pitch_linear_thread_map.h
+1 −1 test/unit/common/cutlass_unit_test.h
+36 −16 tools/library/scripts/generator.py
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ We do encourage everyone to work anything they are interested in.
- [Alex Weaver](https://github.com/alex-weaver): @alex-weaver
- [Logan Weber](https://github.com/weberlo): @weberlo
- [Matt Welsh](https://github.com/mdw-octoml): @mdw-octoml
- [Cheng Wen](https://github.com/chengven027-intellif): @chengven027-intellif
- [Jian Weng](https://github.com/were): @were
- [wrongtest](https://github.com/wrongtest-intellif): @wrongtest-intellif
- [Yong Wu](https://github.com/yongwww): @yongwww
Expand Down
10 changes: 10 additions & 0 deletions apps/android_camera/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,13 @@ Run uninstall first:
```bash
$ANDROID_HOME/platform-tools/adb uninstall ml.apache.tvm.android.androidcamerademo
```
### Troubleshooting

If you build the application in Android Studio and see error similar to this one:
```
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.version-check'.
> Minimum supported Gradle version is 7.5. Current version is 7.4. If using the gradle wrapper, try editing the distributionUrl in /Users/echuraev/Workspace/OctoML/tvm_android_test/apps/android_deploy/gradle/wrapper/gradle-wrapper.properties to gradle-7.5-all.zip
```
Run project syncing `File -> Sync Project with Gradle Files`. It should sync the
project and create gradle-wrapper files.
3 changes: 3 additions & 0 deletions apps/android_camera/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,MissingApplicationIcon">
<uses-native-library
android:name="libOpenCL.so"
android:required="false"/>
<activity
android:name="org.apache.tvm.android.androidcamerademo.MainActivity"
android:exported="true"
Expand Down
2 changes: 1 addition & 1 deletion apps/android_camera/models/prepare_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def main(model_str, output_path):
raise RuntimeError("Require environment variable TVM_NDK_CC")
models_path = Path().absolute().parent.joinpath("app/src/main/assets/models/")
if not models_path.exists():
models_path.mkdir()
models_path.mkdir(parents=True)
models = {
"mobilenet_v2": models_path.joinpath("mobilenet_v2"),
"resnet18_v1": models_path.joinpath("resnet18_v1"),
Expand Down
11 changes: 11 additions & 0 deletions apps/android_deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,14 @@ Copied these compiled model deploy_lib.so, deploy_graph.json and deploy_param.pa
Install compiled android application on phone and enjoy the image classifier demo using extraction model

You can define your own TVM operators and deploy via this demo application on your Android device to find the most optimized TVM schedule.

### Troubleshooting

If you build the application in Android Studio and see error similar to this one:
```
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.version-check'.
> Minimum supported Gradle version is 7.5. Current version is 7.4. If using the gradle wrapper, try editing the distributionUrl in /Users/echuraev/Workspace/OctoML/tvm_android_test/apps/android_deploy/gradle/wrapper/gradle-wrapper.properties to gradle-7.5-all.zip
```
Run project syncing `File -> Sync Project with Gradle Files`. It should sync the
project and create gradle-wrapper files.
3 changes: 3 additions & 0 deletions apps/android_deploy/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ under the License.
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<uses-native-library
android:name="libOpenCL.so"
android:required="false"/>
<activity
android:name="org.apache.tvm.android.demo.MainActivity"
android:theme="@style/AppTheme.NoActionBar"
Expand Down
11 changes: 11 additions & 0 deletions apps/android_rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,14 @@ Run GPU(Vulkan Flavor) test ...
```

You can define your own TVM operators and test via this RPC app on your Android device to find the most optimized TVM schedule.

### Troubleshooting

If you build the application in Android Studio and see error similar to this one:
```
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.version-check'.
> Minimum supported Gradle version is 7.5. Current version is 7.4. If using the gradle wrapper, try editing the distributionUrl in /Users/echuraev/Workspace/OctoML/tvm_android_test/apps/android_deploy/gradle/wrapper/gradle-wrapper.properties to gradle-7.5-all.zip
```
Run project syncing `File -> Sync Project with Gradle Files`. It should sync the
project and create gradle-wrapper files.
3 changes: 3 additions & 0 deletions apps/android_rpc/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ under the License.
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:icon="@mipmap/ic_launcher">
<uses-native-library
android:name="libOpenCL.so"
android:required="false"/>
<activity
android:name=".MainActivity"
android:theme="@style/AppTheme.NoActionBar"
Expand Down
17 changes: 0 additions & 17 deletions apps/microtvm/zephyr/template_project/src/mlperftiny/platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@

#include "crt_config.h"

// TVM_WORKSPACE_SIZE_BYTES is defined in python
static uint8_t g_aot_memory[TVM_WORKSPACE_SIZE_BYTES];
tvm_workspace_t app_workspace;

size_t TVMPlatformFormatMessage(char* out_buf, size_t out_buf_size_bytes, const char* fmt,
va_list args) {
return vsnprintk(out_buf, out_buf_size_bytes, fmt, args);
Expand All @@ -53,16 +49,3 @@ void TVMPlatformAbort(tvm_crt_error_t error) {
for (;;)
;
}

tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) {
return StackMemoryManager_Allocate(&app_workspace, num_bytes, out_ptr);
}

tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
return StackMemoryManager_Free(&app_workspace, ptr);
}

tvm_crt_error_t TVMPlatformInitialize() {
StackMemoryManager_Init(&app_workspace, g_aot_memory, sizeof(g_aot_memory));
return kTvmErrorNoError;
}
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void th_infer() { Infer(g_input_data); }

/// \brief optional API.
// Modified from source
void th_final_initialize(void) { TVMPlatformInitialize(); }
void th_final_initialize(void) {}

void th_pre() {}
void th_post() {}
Expand Down
3 changes: 0 additions & 3 deletions cmake/utils/CRTConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ function(generate_crt_config platform output_path)
set(TVM_CRT_MAX_STRLEN_DLTYPE 10)
set(TVM_CRT_MAX_STRLEN_FUNCTION_NAME 120)
set(TVM_CRT_MAX_STRLEN_PARAM_NAME 80)
set(TVM_CRT_MAX_FUNCTION_NAME_LENGTH_BYTES 30)
set(TVM_CRT_PAGE_BITS 10)
set(TVM_CRT_MAX_PAGES 300)

if("${platform}" STREQUAL "zephyr")
set(TVM_CRT_MAX_PACKET_SIZE_BYTES 512)
Expand Down
5 changes: 1 addition & 4 deletions docker/Dockerfile.ci_adreno
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ COPY utils/apt-install-and-clear.sh /usr/local/bin/apt-install-and-clear

# Android SDK
COPY install/ubuntu_install_androidsdk.sh /install/ubuntu_install_androidsdk.sh
RUN bash /install/ubuntu_install_androidsdk.sh
ENV ANDROID_HOME=/opt/android-sdk-linux
ENV ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/21.3.6528147
ENV ANDROID_NDK_MAJOR=21
RUN bash /install/ubuntu_install_androidsdk.sh 25.2.9519653 3.22.1 33.0.2 33
ENV PATH /opt/android-sdk-linux/platform-tools:$PATH

# Clang tool for CLML source codegen
Expand Down
3 changes: 0 additions & 3 deletions docker/Dockerfile.ci_cpu
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ RUN bash /install/ubuntu_install_vitis_ai_packages_ci.sh
# Android SDK
COPY install/ubuntu_install_androidsdk.sh /install/ubuntu_install_androidsdk.sh
RUN bash /install/ubuntu_install_androidsdk.sh
ENV ANDROID_HOME=/opt/android-sdk-linux/
ENV ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/21.3.6528147/
ENV ANDROID_NDK_MAJOR=21

# PaddlePaddle deps
COPY install/ubuntu_install_paddle.sh /install/ubuntu_install_paddle.sh
Expand Down
2 changes: 0 additions & 2 deletions docker/Dockerfile.ci_hexagon
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ RUN bash /install/ubuntu_install_java.sh
COPY install/ubuntu_install_androidsdk.sh /install/ubuntu_install_androidsdk.sh
RUN bash /install/ubuntu_install_androidsdk.sh
ENV ANDROID_HOME=/opt/android-sdk-linux
ENV ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/21.3.6528147
ENV ANDROID_NDK_MAJOR=21
ENV PATH /opt/android-sdk-linux/platform-tools:$PATH

# Hexagon
Expand Down
2 changes: 0 additions & 2 deletions docker/Dockerfile.demo_android
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,3 @@ RUN cd /usr && \
# Environment variables
ENV PYTHONPATH=/usr/tvm/python:/usr/tvm/vta/python:${PYTHONPATH}
ENV ANDROID_HOME=/opt/android-sdk-linux/
ENV ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/21.3.6528147/
ENV ANDROID_NDK_MAJOR=21
43 changes: 36 additions & 7 deletions docker/install/ubuntu_install_androidsdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@ ASDKTOOLS_HOME=/opt/android-sdk-tools
ASDKTOOLS_VERSION=3859397
ASDKTOOLS_SHA256=444e22ce8ca0f67353bda4b85175ed3731cae3ffa695ca18119cbacef1c1bea0

ANDROID_NDK_VERSION=21.3.6528147
CMAKE_VERSION=3.6.4111459
BUILD_TOOLS_VERSION=27.0.3
ANDROID_PLATFORM=27
ANDROID_NDK_MAJOR=21

if [ $# -gt 0 ] ; then
ANDROID_NDK_VERSION=$1
ANDROID_NDK_MAJOR=`echo $1 | cut -d "." -f1`
fi
if [ $# -gt 1 ] ; then
CMAKE_VERSION=$2
fi
if [ $# -gt 2 ] ; then
BUILD_TOOLS_VERSION=$3
fi
if [ $# -gt 3 ] ; then
ANDROID_PLATFORM=$4
fi

echo "NDK Version: ${ANDROID_NDK_VERSION}"
echo "NDK Major : ${ANDROID_NDK_MAJOR}"
echo "Cmake Version: ${CMAKE_VERSION}"
echo "Build Tools: ${BUILD_TOOLS_VERSION}"
echo "Android Platform: ${ANDROID_PLATFORM}"

wget -q http://dl.google.com/android/repository/sdk-tools-linux-${ASDKTOOLS_VERSION}.zip -O sdk-tools-linux.zip
echo "${ASDKTOOLS_SHA256} *sdk-tools-linux.zip" | sha256sum --check -
unzip sdk-tools-linux.zip
Expand All @@ -52,8 +78,8 @@ done

cat >/install/package-list-minimal.txt <<EOF
build-tools;26.0.3
build-tools;27.0.3
cmake;3.6.4111459
build-tools;${BUILD_TOOLS_VERSION}
cmake;${CMAKE_VERSION}
emulator
extras;android;m2repository
extras;google;auto
Expand All @@ -67,19 +93,22 @@ extras;google;webdriver
extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2
extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2
platforms;android-26
platforms;android-27
platforms;android-${ANDROID_PLATFORM}
tools
ndk;21.3.6528147
ndk;${ANDROID_NDK_VERSION}
EOF

mkdir /root/.android 2>/dev/null || true
touch /root/.android/repositories.cfg
# NOTE: sdkmanager returns exit code 141
(yes || true) | sdkmanager --licenses --sdk_root="$ANDROID_HOME" || true
sdkmanager --verbose --package_file=/install/package-list-minimal.txt --sdk_root="$ANDROID_HOME"
test -d "${ANDROID_HOME}/build-tools/27.0.3"
test -d "${ANDROID_HOME}/ndk/21.3.6528147"
for f in ${ANDROID_HOME}/ndk/21.3.6528147/* ; do
test -d "${ANDROID_HOME}/build-tools/${BUILD_TOOLS_VERSION}"
test -d "${ANDROID_HOME}/ndk/${ANDROID_NDK_VERSION}"
for f in ${ANDROID_HOME}/ndk/${ANDROID_NDK_VERSION}/* ; do
ln --symbolic "$f" "/usr/bin/`basename $f`"
done
echo "export ANDROID_HOME=${ANDROID_HOME}" >> /etc/profile
echo "export ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/${ANDROID_NDK_VERSION}/" >> /etc/profile
echo "export ANDROID_NDK_VERSION=${ANDROID_NDK_VERSION}" >> /etc/profile
echo "export ANDROID_NDK_MAJOR=${ANDROID_NDK_MAJOR}" >> /etc/profile
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def fixup_tutorials(original_url: str) -> str:
"header_dropdown": header_dropdown,
"header_logo": header_logo,
"header_logo_link": header_logo_link,
"version_prefixes": ["main", "v0.8.0/", "v0.9.0/", "v0.10.0/"],
"version_prefixes": ["main", "v0.8.0/", "v0.9.0/", "v0.10.0/", "v0.11.0/"],
"display_github": True,
"github_user": "apache",
"github_repo": "tvm",
Expand Down
28 changes: 17 additions & 11 deletions docs/script_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

BASH = "# bash"
BASH_IGNORE = "# bash-ignore"
BASH_MULTILINE_COMMENT_START = ": '"
BASH_MULTILINE_COMMENT_END = "'"
BASH_MULTILINE_COMMENT = "# bash-comment"


def bash_to_python(src_path: pathlib.Path, dest_path: pathlib.Path):
Expand All @@ -33,6 +32,8 @@ def bash_to_python(src_path: pathlib.Path, dest_path: pathlib.Path):
bash_detected = False
bash_ignore_detected = False
new_line_required = False
bash_multiline_comment_detected = False

while line:
line = line.strip("\n").strip("\r")
if bash_detected:
Expand All @@ -42,7 +43,7 @@ def bash_to_python(src_path: pathlib.Path, dest_path: pathlib.Path):
dest_f.write("\n")
python_code = "# .. code-block:: bash\n#\n"
for bash_line in bash_block:
python_code += f"#\t {bash_line}\n"
python_code += f"# \t {bash_line}\n"
python_code += "#"
dest_f.write(python_code)

Expand All @@ -55,29 +56,34 @@ def bash_to_python(src_path: pathlib.Path, dest_path: pathlib.Path):
elif bash_ignore_detected:
if line == BASH_IGNORE:
bash_ignore_detected = False
new_line_required = True
else:
new_line_required = False
pass
elif bash_multiline_comment_detected:
if line == BASH_MULTILINE_COMMENT:
bash_multiline_comment_detected = False
else:
if line != "#":
assert len(line) > 2, "Detected empty line."
dest_f.write(line[2:])
new_line_required = True
else:
if line == BASH:
bash_detected = True
elif line == BASH_IGNORE:
bash_ignore_detected = True
elif line in [BASH_MULTILINE_COMMENT_START, BASH_MULTILINE_COMMENT_END]:
if new_line_required:
dest_f.write("\n")
dest_f.write('"""')
new_line_required = True
elif line == BASH_MULTILINE_COMMENT:
bash_multiline_comment_detected = True
else:
if new_line_required:
dest_f.write("\n")
dest_f.write(f"{line}")
new_line_required = True

line = src_f.readline()
if new_line_required:
dest_f.write("\n")
if new_line_required:
dest_f.write("\n")
new_line_required = False


def main():
Expand Down
Loading

0 comments on commit 34635ed

Please sign in to comment.