forked from pytorch/ao
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build_native.sh and add README.md (pytorch#481)
* Add build_native.sh and add README.md Summary: Added a script to build C++ runner for ET and AOTI. Updated README.md to ask users to run it. Made some improvement on building speed, by reducing duplicate build command. Now we can rely on `install_requirements.sh` to install all of the C++ libraries needed for runner. Test Plan: Reviewers: Subscribers: Tasks: Tags: * Revert custom ops change Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: * Add build_native.sh to CI job Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: * Add README for building native runner for aoti Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
- Loading branch information
1 parent
183d9bd
commit 38d9912
Showing
7 changed files
with
165 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# Simple script to build native aoti and et runner | ||
# Function to display a help message | ||
|
||
set -ex | ||
|
||
show_help() { | ||
cat << EOF | ||
Usage: ${0##*/} [-h|--help] aoti|et | ||
This script builds native aoti and et runner for LLM. | ||
-h|--help Display this help and exit | ||
aoti Build native runner for aoti | ||
et Build native runner for et | ||
EOF | ||
} | ||
# Check if no arguments were passed | ||
if [ $# -eq 0 ]; then | ||
echo "No arguments provided" | ||
show_help | ||
exit 1 | ||
fi | ||
while (( "$#" )); do | ||
case "$1" in | ||
-h|--help) | ||
show_help | ||
exit 0 | ||
;; | ||
aoti) | ||
echo "Building aoti native runner..." | ||
TARGET="aoti" | ||
shift | ||
;; | ||
et) | ||
echo "Building et native runner..." | ||
TARGET="et" | ||
shift | ||
;; | ||
*) | ||
echo "Invalid option: $1" | ||
show_help | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [ -z "${TORCHCHAT_ROOT}" ]; then | ||
# Get the absolute path of the current script | ||
SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" | ||
# Get the absolute path of the parent directory | ||
TORCHCHAT_ROOT="$(dirname "$SCRIPT_PATH")" | ||
fi | ||
|
||
if [ -z "${ET_BUILD_DIR}" ]; then | ||
ET_BUILD_DIR="et-build" | ||
fi | ||
|
||
source "$TORCHCHAT_ROOT/scripts/install_utils.sh" | ||
|
||
if [[ "$TARGET" == "et" ]]; then | ||
pushd ${TORCHCHAT_ROOT} | ||
git submodule update --init | ||
find_cmake_prefix_path | ||
install_pip_dependencies | ||
clone_executorch | ||
install_executorch_libs false | ||
popd | ||
fi | ||
|
||
# CMake commands | ||
cmake -S . -B ./cmake-out -DCMAKE_PREFIX_PATH=`python -c 'import torch;print(torch.utils.cmake_prefix_path)'` -G Ninja | ||
cmake --build ./cmake-out --target "${TARGET}"_run | ||
|
||
printf "Build finished. Please run: \n./cmake-out model.<pte|so> -z tokenizer.model -i <prompt>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters