From 0caa28dd931bab977c5f64750877d2a1c8558cda Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Mon, 7 Jul 2025 10:58:07 +0800 Subject: [PATCH] Update [ghstack-poisoned] --- .lintrunner.toml | 1 - android/common.sh | 7 ++- android/run_tests.sh | 7 ++- .../qnnpack/scripts/build-android-arm64.sh | 14 +++--- .../qnnpack/scripts/build-android-armv7.sh | 14 +++--- .../cpu/qnnpack/scripts/build-android-x86.sh | 14 +++--- .../cpu/qnnpack/scripts/build-ios-arm64.sh | 11 ++--- .../cpu/qnnpack/scripts/build-ios-arm64e.sh | 11 ++--- .../cpu/qnnpack/scripts/build-ios-armv7.sh | 11 ++--- .../cpu/qnnpack/scripts/build-ios-armv7s.sh | 11 ++--- .../cpu/qnnpack/scripts/build-ios-i386.sh | 11 ++--- .../cpu/qnnpack/scripts/build-ios-x86_64.sh | 11 ++--- .../cpu/qnnpack/scripts/build-local.sh | 8 ++-- .../hip/flash_attn/ck/add_make_kernel_pt.sh | 26 +++++------ aten/tools/run_tests.sh | 2 +- benchmarks/compare.sh | 4 +- .../pr_time_benchmarks/benchmark_runner.sh | 29 ++++++------ benchmarks/dynamo/run_all.sh | 6 +-- benchmarks/dynamo/run_delta.sh | 4 +- benchmarks/sparse/dlmc/test.sh | 1 - benchmarks/sparse/test_csr.sh | 30 ++++++------- docs/cpp/source/check-doxygen.sh | 11 +++-- test/cpp/aoti_inference/standalone_compile.sh | 18 ++++---- test/mobile/custom_build/build.sh | 7 ++- test/mobile/lightweight_dispatch/build.sh | 1 - test/run_doctests.sh | 18 ++++---- tools/bazel_tools/shellwrap.sh | 44 +++++++++---------- tools/gen_flatbuffers.sh | 6 +-- tools/git_add_generated_dirs.sh | 2 +- tools/git_reset_generated_dirs.sh | 2 +- tools/iwyu/run.sh | 4 +- torchgen/_autoheuristic/collect_data.sh | 22 +++++----- torchgen/_autoheuristic/generate_heuristic.sh | 28 ++++++------ .../mixed_mm/generate_heuristic_mixedmm.sh | 8 ++-- .../mixed_mm/get_mixedmm_dataset.sh | 12 ++--- torchgen/_autoheuristic/mm/get_mm_dataset.sh | 10 ++--- .../pad_mm/generate_heuristic_pad_mm.sh | 8 ++-- .../pad_mm/get_padmm_dataset.sh | 2 +- 38 files changed, 203 insertions(+), 233 deletions(-) diff --git a/.lintrunner.toml b/.lintrunner.toml index c2c8937e8bc1..c4854076c1d7 100644 --- a/.lintrunner.toml +++ b/.lintrunner.toml @@ -1489,7 +1489,6 @@ exclude_patterns = [ 'third_party/**/*.sh', # These files are all grandfathered in, feel free to remove from this list # as necessary - "**/*.sh", ".*/**/*.sh", ".ci/**/*.sh", ".github/**/*.sh", diff --git a/android/common.sh b/android/common.sh index c7c508e2c90a..d5e6f84701e5 100644 --- a/android/common.sh +++ b/android/common.sh @@ -10,8 +10,8 @@ if [ -z "$PYTORCH_DIR" ]; then exit 1 fi -retry () { - "$@" || (sleep 10 && "$@") || (sleep 20 && "$@") || (sleep 40 && "$@") +retry() { + "$@" || (sleep 10 && "$@") || (sleep 20 && "$@") || (sleep 40 && "$@") } check_android_sdk() { @@ -57,8 +57,7 @@ build_android() { rm -rf "$LIB_DIR" && mkdir -p "$LIB_DIR" rm -rf "$INCLUDE_DIR" && mkdir -p "$INCLUDE_DIR" - for abi in $(echo "$ABIS_LIST" | tr ',' '\n') - do + for abi in $(echo "$ABIS_LIST" | tr ',' '\n'); do echo "abi:$abi" ANDROID_BUILD_ROOT="$BUILD_ROOT/build_android_$abi" ANDROID_ABI="$abi" \ diff --git a/android/run_tests.sh b/android/run_tests.sh index c8c897761493..7ece428a41ba 100755 --- a/android/run_tests.sh +++ b/android/run_tests.sh @@ -1,7 +1,10 @@ #!/bin/bash set -eux -PYTORCH_DIR="$(cd $(dirname $0)/..; pwd -P)" +PYTORCH_DIR="$( + cd $(dirname $0)/.. + pwd -P +)" PYTORCH_ANDROID_DIR=$PYTORCH_DIR/android source "$PYTORCH_ANDROID_DIR/common.sh" @@ -21,7 +24,7 @@ echo "DEVICES_COUNT:$DEVICES_COUNT" if [ "$DEVICES_COUNT" -eq 1 ]; then echo "Unable to found connected android emulators" -cat <<- EOF + cat <<-EOF To start android emulator: 1. Install android sdkmanager packages $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-25;google_apis;x86" diff --git a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-android-arm64.sh b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-android-arm64.sh index 389430b043fe..be40b2387cf6 100755 --- a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-android-arm64.sh +++ b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-android-arm64.sh @@ -8,14 +8,12 @@ set -e -if [ -z "$ANDROID_NDK" ] -then +if [ -z "$ANDROID_NDK" ]; then echo "ANDROID_NDK not set; please set it to the Android NDK directory" exit 1 fi -if [ ! -d "$ANDROID_NDK" ] -then +if [ ! -d "$ANDROID_NDK" ]; then echo "ANDROID_NDK not a directory; did you install it under ${ANDROID_NDK}?" exit 1 fi @@ -30,8 +28,7 @@ CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Release") CMAKE_ARGS+=("-DCMAKE_POSITION_INDEPENDENT_CODE=ON") # If Ninja is installed, prefer it to Make -if [ -x "$(command -v ninja)" ] -then +if [ -x "$(command -v ninja)" ]; then CMAKE_ARGS+=("-GNinja") fi @@ -57,11 +54,10 @@ CMAKE_ARGS+=("-DANDROID_CPP_FEATURES=exceptions") CMAKE_ARGS+=($@) cd build/android/arm64-v8a && cmake ../../.. \ - "${CMAKE_ARGS[@]}" + "${CMAKE_ARGS[@]}" # Cross-platform parallel build -if [ "$(uname)" == "Darwin" ] -then +if [ "$(uname)" == "Darwin" ]; then cmake --build . -- "-j$(sysctl -n hw.ncpu)" else cmake --build . -- "-j$(nproc)" diff --git a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-android-armv7.sh b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-android-armv7.sh index 6f32950125e0..3813caef9482 100755 --- a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-android-armv7.sh +++ b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-android-armv7.sh @@ -8,14 +8,12 @@ set -e -if [ -z "$ANDROID_NDK" ] -then +if [ -z "$ANDROID_NDK" ]; then echo "ANDROID_NDK not set; please set it to the Android NDK directory" exit 1 fi -if [ ! -d "$ANDROID_NDK" ] -then +if [ ! -d "$ANDROID_NDK" ]; then echo "ANDROID_NDK not a directory; did you install it under ${ANDROID_NDK}?" exit 1 fi @@ -30,8 +28,7 @@ CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Release") CMAKE_ARGS+=("-DCMAKE_POSITION_INDEPENDENT_CODE=ON") # If Ninja is installed, prefer it to Make -if [ -x "$(command -v ninja)" ] -then +if [ -x "$(command -v ninja)" ]; then CMAKE_ARGS+=("-GNinja") fi @@ -57,11 +54,10 @@ CMAKE_ARGS+=("-DANDROID_CPP_FEATURES=exceptions") CMAKE_ARGS+=($@) cd build/android/armeabi-v7a && cmake ../../.. \ - "${CMAKE_ARGS[@]}" + "${CMAKE_ARGS[@]}" # Cross-platform parallel build -if [ "$(uname)" == "Darwin" ] -then +if [ "$(uname)" == "Darwin" ]; then cmake --build . -- "-j$(sysctl -n hw.ncpu)" else cmake --build . -- "-j$(nproc)" diff --git a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-android-x86.sh b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-android-x86.sh index 5f19db582fb0..412ed3487411 100755 --- a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-android-x86.sh +++ b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-android-x86.sh @@ -8,14 +8,12 @@ set -e -if [ -z "$ANDROID_NDK" ] -then +if [ -z "$ANDROID_NDK" ]; then echo "ANDROID_NDK not set; please set it to the Android NDK directory" exit 1 fi -if [ ! -d "$ANDROID_NDK" ] -then +if [ ! -d "$ANDROID_NDK" ]; then echo "ANDROID_NDK not a directory; did you install it under ${ANDROID_NDK}?" exit 1 fi @@ -30,8 +28,7 @@ CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Release") CMAKE_ARGS+=("-DCMAKE_POSITION_INDEPENDENT_CODE=ON") # If Ninja is installed, prefer it to Make -if [ -x "$(command -v ninja)" ] -then +if [ -x "$(command -v ninja)" ]; then CMAKE_ARGS+=("-GNinja") fi @@ -57,11 +54,10 @@ CMAKE_ARGS+=("-DANDROID_CPP_FEATURES=exceptions") CMAKE_ARGS+=($@) cd build/android/x86 && cmake ../../.. \ - "${CMAKE_ARGS[@]}" + "${CMAKE_ARGS[@]}" # Cross-platform parallel build -if [ "$(uname)" == "Darwin" ] -then +if [ "$(uname)" == "Darwin" ]; then cmake --build . -- "-j$(sysctl -n hw.ncpu)" else cmake --build . -- "-j$(nproc)" diff --git a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-arm64.sh b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-arm64.sh index d155d6f7507d..dc48a529a7e0 100755 --- a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-arm64.sh +++ b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-arm64.sh @@ -8,14 +8,12 @@ set -e -if [ -z "$IOS_CMAKE_TOOLCHAIN_FILE" ] -then +if [ -z "$IOS_CMAKE_TOOLCHAIN_FILE" ]; then echo "IOS_CMAKE_TOOLCHAIN_FILE not set; please set it to path of CMake toolchain file for iOS" exit 1 fi -if [ ! -f "$IOS_CMAKE_TOOLCHAIN_FILE" ] -then +if [ ! -f "$IOS_CMAKE_TOOLCHAIN_FILE" ]; then echo "IOS_CMAKE_TOOLCHAIN_FILE not a file path; did you properly setup ${IOS_CMAKE_TOOLCHAIN_FILE}?" exit 1 fi @@ -44,11 +42,10 @@ CMAKE_ARGS+=("-DENABLE_ARC=OFF") CMAKE_ARGS+=($@) cd build/ios/arm64 && cmake ../../.. \ - "${CMAKE_ARGS[@]}" + "${CMAKE_ARGS[@]}" # Cross-platform parallel build -if [ "$(uname)" == "Darwin" ] -then +if [ "$(uname)" == "Darwin" ]; then cmake --build . -- "-j$(sysctl -n hw.ncpu)" else cmake --build . -- "-j$(nproc)" diff --git a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-arm64e.sh b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-arm64e.sh index 985315f74a66..8899bf84fd98 100755 --- a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-arm64e.sh +++ b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-arm64e.sh @@ -8,14 +8,12 @@ set -e -if [ -z "$IOS_CMAKE_TOOLCHAIN_FILE" ] -then +if [ -z "$IOS_CMAKE_TOOLCHAIN_FILE" ]; then echo "IOS_CMAKE_TOOLCHAIN_FILE not set; please set it to path of CMake toolchain file for iOS" exit 1 fi -if [ ! -f "$IOS_CMAKE_TOOLCHAIN_FILE" ] -then +if [ ! -f "$IOS_CMAKE_TOOLCHAIN_FILE" ]; then echo "IOS_CMAKE_TOOLCHAIN_FILE not a file path; did you properly setup ${IOS_CMAKE_TOOLCHAIN_FILE}?" exit 1 fi @@ -44,11 +42,10 @@ CMAKE_ARGS+=("-DENABLE_ARC=OFF") CMAKE_ARGS+=($@) cd build/ios/arm64e && cmake ../../.. \ - "${CMAKE_ARGS[@]}" + "${CMAKE_ARGS[@]}" # Cross-platform parallel build -if [ "$(uname)" == "Darwin" ] -then +if [ "$(uname)" == "Darwin" ]; then cmake --build . -- "-j$(sysctl -n hw.ncpu)" else cmake --build . -- "-j$(nproc)" diff --git a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-armv7.sh b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-armv7.sh index 0431c090db68..6cf7532a4afc 100755 --- a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-armv7.sh +++ b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-armv7.sh @@ -8,14 +8,12 @@ set -e -if [ -z "$IOS_CMAKE_TOOLCHAIN_FILE" ] -then +if [ -z "$IOS_CMAKE_TOOLCHAIN_FILE" ]; then echo "IOS_CMAKE_TOOLCHAIN_FILE not set; please set it to path of CMake toolchain file for iOS" exit 1 fi -if [ ! -f "$IOS_CMAKE_TOOLCHAIN_FILE" ] -then +if [ ! -f "$IOS_CMAKE_TOOLCHAIN_FILE" ]; then echo "IOS_CMAKE_TOOLCHAIN_FILE not a file path; did you properly setup ${IOS_CMAKE_TOOLCHAIN_FILE}?" exit 1 fi @@ -44,11 +42,10 @@ CMAKE_ARGS+=("-DENABLE_ARC=OFF") CMAKE_ARGS+=($@) cd build/ios/armv7 && cmake ../../.. \ - "${CMAKE_ARGS[@]}" + "${CMAKE_ARGS[@]}" # Cross-platform parallel build -if [ "$(uname)" == "Darwin" ] -then +if [ "$(uname)" == "Darwin" ]; then cmake --build . -- "-j$(sysctl -n hw.ncpu)" else cmake --build . -- "-j$(nproc)" diff --git a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-armv7s.sh b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-armv7s.sh index e3f3d6b76231..0b4b67bda587 100755 --- a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-armv7s.sh +++ b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-armv7s.sh @@ -8,14 +8,12 @@ set -e -if [ -z "$IOS_CMAKE_TOOLCHAIN_FILE" ] -then +if [ -z "$IOS_CMAKE_TOOLCHAIN_FILE" ]; then echo "IOS_CMAKE_TOOLCHAIN_FILE not set; please set it to path of CMake toolchain file for iOS" exit 1 fi -if [ ! -f "$IOS_CMAKE_TOOLCHAIN_FILE" ] -then +if [ ! -f "$IOS_CMAKE_TOOLCHAIN_FILE" ]; then echo "IOS_CMAKE_TOOLCHAIN_FILE not a file path; did you properly setup ${IOS_CMAKE_TOOLCHAIN_FILE}?" exit 1 fi @@ -44,11 +42,10 @@ CMAKE_ARGS+=("-DENABLE_ARC=OFF") CMAKE_ARGS+=($@) cd build/ios/armv7s && cmake ../../.. \ - "${CMAKE_ARGS[@]}" + "${CMAKE_ARGS[@]}" # Cross-platform parallel build -if [ "$(uname)" == "Darwin" ] -then +if [ "$(uname)" == "Darwin" ]; then cmake --build . -- "-j$(sysctl -n hw.ncpu)" else cmake --build . -- "-j$(nproc)" diff --git a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-i386.sh b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-i386.sh index e8952148e66a..0f78a05e5aba 100755 --- a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-i386.sh +++ b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-i386.sh @@ -8,14 +8,12 @@ set -e -if [ -z "$IOS_CMAKE_TOOLCHAIN_FILE" ] -then +if [ -z "$IOS_CMAKE_TOOLCHAIN_FILE" ]; then echo "IOS_CMAKE_TOOLCHAIN_FILE not set; please set it to path of CMake toolchain file for iOS" exit 1 fi -if [ ! -f "$IOS_CMAKE_TOOLCHAIN_FILE" ] -then +if [ ! -f "$IOS_CMAKE_TOOLCHAIN_FILE" ]; then echo "IOS_CMAKE_TOOLCHAIN_FILE not a file path; did you properly setup ${IOS_CMAKE_TOOLCHAIN_FILE}?" exit 1 fi @@ -44,11 +42,10 @@ CMAKE_ARGS+=("-DENABLE_ARC=OFF") CMAKE_ARGS+=($@) cd build/ios/i386 && cmake ../../.. \ - "${CMAKE_ARGS[@]}" + "${CMAKE_ARGS[@]}" # Cross-platform parallel build -if [ "$(uname)" == "Darwin" ] -then +if [ "$(uname)" == "Darwin" ]; then cmake --build . -- "-j$(sysctl -n hw.ncpu)" else cmake --build . -- "-j$(nproc)" diff --git a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-x86_64.sh b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-x86_64.sh index 10a58b843e2a..b2f064e68be5 100755 --- a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-x86_64.sh +++ b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-ios-x86_64.sh @@ -8,14 +8,12 @@ set -e -if [ -z "$IOS_CMAKE_TOOLCHAIN_FILE" ] -then +if [ -z "$IOS_CMAKE_TOOLCHAIN_FILE" ]; then echo "IOS_CMAKE_TOOLCHAIN_FILE not set; please set it to path of CMake toolchain file for iOS" exit 1 fi -if [ ! -f "$IOS_CMAKE_TOOLCHAIN_FILE" ] -then +if [ ! -f "$IOS_CMAKE_TOOLCHAIN_FILE" ]; then echo "IOS_CMAKE_TOOLCHAIN_FILE not a file path; did you properly setup ${IOS_CMAKE_TOOLCHAIN_FILE}?" exit 1 fi @@ -49,11 +47,10 @@ CMAKE_ARGS+=("-DENABLE_ARC=OFF") CMAKE_ARGS+=($@) cd build/ios/x86_64 && cmake ../../.. \ - "${CMAKE_ARGS[@]}" + "${CMAKE_ARGS[@]}" # Cross-platform parallel build -if [ "$(uname)" == "Darwin" ] -then +if [ "$(uname)" == "Darwin" ]; then cmake --build . -- "-j$(sysctl -n hw.ncpu)" else cmake --build . -- "-j$(nproc)" diff --git a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-local.sh b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-local.sh index b429650c2184..e9f184237d1c 100755 --- a/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-local.sh +++ b/aten/src/ATen/native/quantized/cpu/qnnpack/scripts/build-local.sh @@ -17,8 +17,7 @@ CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Release") CMAKE_ARGS+=("-DCMAKE_POSITION_INDEPENDENT_CODE=ON") # If Ninja is installed, prefer it to Make -if [ -x "$(command -v ninja)" ] -then +if [ -x "$(command -v ninja)" ]; then CMAKE_ARGS+=("-GNinja") fi @@ -31,11 +30,10 @@ CMAKE_ARGS+=("-DPYTORCH_QNNPACK_BUILD_TESTS=ON") CMAKE_ARGS+=($@) cd build/local && cmake ../.. \ - "${CMAKE_ARGS[@]}" + "${CMAKE_ARGS[@]}" # Cross-platform parallel build -if [ "$(uname)" == "Darwin" ] -then +if [ "$(uname)" == "Darwin" ]; then cmake --build . -- "-j$(sysctl -n hw.ncpu)" else cmake --build . -- "-j$(nproc)" diff --git a/aten/src/ATen/native/transformers/hip/flash_attn/ck/add_make_kernel_pt.sh b/aten/src/ATen/native/transformers/hip/flash_attn/ck/add_make_kernel_pt.sh index 672bea143751..c6fff533dfd7 100755 --- a/aten/src/ATen/native/transformers/hip/flash_attn/ck/add_make_kernel_pt.sh +++ b/aten/src/ATen/native/transformers/hip/flash_attn/ck/add_make_kernel_pt.sh @@ -2,8 +2,8 @@ # Check if the input file is provided if [ "$#" -ne 1 ]; then - echo "Usage: $0 " - exit 1 + echo "Usage: $0 " + exit 1 fi # Assign the input file to a variable @@ -11,20 +11,20 @@ file_list=$1 # Check if the file exists if [ ! -f "$file_list" ]; then - echo "Error: File '$file_list' not found!" - exit 1 + echo "Error: File '$file_list' not found!" + exit 1 fi # Loop through each line in the file list while IFS= read -r file; do - # Check if the file exists in the current directory - if [ -f "$file" ]; then - # Use sed to replace "make_kernel" with "make_kernel_pt" in place - sed -i 's/make_kernel/make_kernel_pt/g' "$file" - echo "Updated: $file" - else - echo "Skipping: $file (not found)" - fi -done < "$file_list" + # Check if the file exists in the current directory + if [ -f "$file" ]; then + # Use sed to replace "make_kernel" with "make_kernel_pt" in place + sed -i 's/make_kernel/make_kernel_pt/g' "$file" + echo "Updated: $file" + else + echo "Skipping: $file (not found)" + fi +done <"$file_list" echo "Replacement completed." diff --git a/aten/tools/run_tests.sh b/aten/tools/run_tests.sh index c8bf60611817..e8b023c50b1a 100755 --- a/aten/tools/run_tests.sh +++ b/aten/tools/run_tests.sh @@ -2,7 +2,7 @@ set -x set -e -VALGRIND_SUP="${PWD}/`dirname $0`/valgrind.sup" +VALGRIND_SUP="${PWD}/$(dirname $0)/valgrind.sup" export CPP_TESTS_DIR=$1 VALGRIND=${VALGRIND:=ON} diff --git a/benchmarks/compare.sh b/benchmarks/compare.sh index d9d6a07ea4d3..9c4eab8b1ad5 100644 --- a/benchmarks/compare.sh +++ b/benchmarks/compare.sh @@ -1,4 +1,4 @@ #!/bin/bash -python -m fastrnns.bench --fuser=old --group=rnns --print-json oss > old.json -python -m fastrnns.bench --fuser=te --group=rnns --print-json oss > te.json +python -m fastrnns.bench --fuser=old --group=rnns --print-json oss >old.json +python -m fastrnns.bench --fuser=te --group=rnns --print-json oss >te.json python compare-fastrnn-results.py old.json te.json --format md diff --git a/benchmarks/dynamo/pr_time_benchmarks/benchmark_runner.sh b/benchmarks/dynamo/pr_time_benchmarks/benchmark_runner.sh index 7a854a7020f3..02da9ae3f4d9 100755 --- a/benchmarks/dynamo/pr_time_benchmarks/benchmark_runner.sh +++ b/benchmarks/dynamo/pr_time_benchmarks/benchmark_runner.sh @@ -1,16 +1,14 @@ #!/bin/bash # Check if the output file argument was provided -if [ $# -eq 0 ] -then - echo "Please provide the output file as an argument" - return +if [ $# -eq 0 ]; then + echo "Please provide the output file as an argument" + return fi # Check if the directory of Python programs argument was provided -if [ $# -eq 1 ] -then - echo "Please provide the directory of Python programs as an argument" - return +if [ $# -eq 1 ]; then + echo "Please provide the directory of Python programs as an argument" + return fi # Set the output file @@ -19,17 +17,16 @@ output_file=$1 python_programs_dir=$2 # Loop through all files in the directory of Python programs -start=`date +%s` +start=$(date +%s) -for file in $python_programs_dir/*.py -do - if [ "$file" != "$python_programs_dir/benchmark_base.py" ]; then - python $file $output_file - fi +for file in $python_programs_dir/*.py; do + if [ "$file" != "$python_programs_dir/benchmark_base.py" ]; then + python $file $output_file + fi done -end=`date +%s` +end=$(date +%s) -runtime=$((end-start)) +runtime=$((end - start)) echo "total time to run benchmarks is:" echo $runtime python benchmarks/dynamo/pr_time_benchmarks/log_benchmarking_time.py $runtime diff --git a/benchmarks/dynamo/run_all.sh b/benchmarks/dynamo/run_all.sh index 18612c8b855e..8c60bb98a7ab 100755 --- a/benchmarks/dynamo/run_all.sh +++ b/benchmarks/dynamo/run_all.sh @@ -22,11 +22,11 @@ set -x # Some QoL for people running this script on Meta servers if getent hosts fwdproxy; then - export https_proxy=http://fwdproxy:8080 http_proxy=http://fwdproxy:8080 no_proxy=.fbcdn.net,.facebook.com,.thefacebook.com,.tfbnw.net,.fb.com,.fburl.com,.facebook.net,.sb.fbsbx.com,localhost + export https_proxy=http://fwdproxy:8080 http_proxy=http://fwdproxy:8080 no_proxy=.fbcdn.net,.facebook.com,.thefacebook.com,.tfbnw.net,.fb.com,.fburl.com,.facebook.net,.sb.fbsbx.com,localhost fi # Feel free to edit these, but we expect most users not to need to modify this -BASE_FLAGS=( --accuracy --explain --timing --print-graph-breaks ) +BASE_FLAGS=(--accuracy --explain --timing --print-graph-breaks) DATE="$(date)" WORK="$PWD" @@ -34,5 +34,5 @@ cd "$(dirname "$BASH_SOURCE")"/../.. python benchmarks/dynamo/benchmarks.py --output "$WORK"/benchmarks.csv "${BASE_FLAGS[@]}" "$@" 2>&1 | tee "$WORK"/sweep.log gh gist create -d "Sweep logs for $(git rev-parse --abbrev-ref HEAD) $* - $(git rev-parse HEAD) $DATE" "$WORK"/sweep.log | tee -a "$WORK"/sweep.log -python benchmarks/dynamo/parse_logs.py "$WORK"/sweep.log > "$WORK"/final.csv +python benchmarks/dynamo/parse_logs.py "$WORK"/sweep.log >"$WORK"/final.csv gh gist create "$WORK"/final.csv diff --git a/benchmarks/dynamo/run_delta.sh b/benchmarks/dynamo/run_delta.sh index 7ca5a881a284..411d51a370f6 100755 --- a/benchmarks/dynamo/run_delta.sh +++ b/benchmarks/dynamo/run_delta.sh @@ -4,7 +4,7 @@ set -x # Some QoL for people running this script on Meta servers if getent hosts fwdproxy; then - export https_proxy=http://fwdproxy:8080 http_proxy=http://fwdproxy:8080 no_proxy=.fbcdn.net,.facebook.com,.thefacebook.com,.tfbnw.net,.fb.com,.fburl.com,.facebook.net,.sb.fbsbx.com,localhost + export https_proxy=http://fwdproxy:8080 http_proxy=http://fwdproxy:8080 no_proxy=.fbcdn.net,.facebook.com,.thefacebook.com,.tfbnw.net,.fb.com,.fburl.com,.facebook.net,.sb.fbsbx.com,localhost fi WORK="$PWD" @@ -18,5 +18,5 @@ mkdir -p "$WORK/sweep/dynamic" (cd "$WORK/sweep/static" && "$ROOT/benchmarks/dynamo/run_all.sh" "$@") (cd "$WORK/sweep/dynamic" && "$ROOT/benchmarks/dynamo/run_all.sh" "$@" --dynamic-shapes) -python benchmarks/dynamo/combine_csv.py "$WORK/sweep/static/final.csv" "$WORK/sweep/dynamic/final.csv" > "$WORK/delta.csv" +python benchmarks/dynamo/combine_csv.py "$WORK/sweep/static/final.csv" "$WORK/sweep/dynamic/final.csv" >"$WORK/delta.csv" gh gist create "$WORK/delta.csv" diff --git a/benchmarks/sparse/dlmc/test.sh b/benchmarks/sparse/dlmc/test.sh index 28d8af26731f..4d91ab326909 100644 --- a/benchmarks/sparse/dlmc/test.sh +++ b/benchmarks/sparse/dlmc/test.sh @@ -16,7 +16,6 @@ python -m dlmc.matmul_bench --path $DATASET_ROOT_DIR/dlmc/rn50 --dataset magnitu python -m dlmc.matmul_bench --path $DATASET_ROOT_DIR/dlmc/rn50 --dataset magnitude_pruning --operation sparse@vector - # cuda python -m dlmc.matmul_bench --path $DATASET_ROOT_DIR/dlmc/rn50 --dataset magnitude_pruning --operation sparse@sparse --with-cuda python -m dlmc.matmul_bench --path $DATASET_ROOT_DIR/dlmc/rn50 --dataset magnitude_pruning --operation sparse@sparse --with-cuda --backward-test diff --git a/benchmarks/sparse/test_csr.sh b/benchmarks/sparse/test_csr.sh index e22c2df6ee54..5a002bd9b6f2 100644 --- a/benchmarks/sparse/test_csr.sh +++ b/benchmarks/sparse/test_csr.sh @@ -3,28 +3,28 @@ PYTORCH_HOME=$1 cd $PYTORCH_HOME -echo "" >> $OUTFILE -echo "----- USE_MKL=1 -----" >> $OUTFILE +echo "" >>$OUTFILE +echo "----- USE_MKL=1 -----" >>$OUTFILE rm -rf build export USE_MKL=1 CMAKE_ONLY=1 python setup.py build -ccmake build # or cmake-gui build +ccmake build # or cmake-gui build python setup.py install cd benchmarks -echo "!! SPARSE SPMM TIME BENCHMARK!! " >> $OUTFILE +echo "!! SPARSE SPMM TIME BENCHMARK!! " >>$OUTFILE for dim0 in 1000 5000 10000; do - for nnzr in 0.01 0.05 0.1 0.3; do - python -m sparse.spmm --format csr --m $dim0 --n $dim0 --k $dim0 --nnz-ratio $nnzr --outfile $OUTFILE - # python -m sparse.spmm --format coo --m $dim0 --n $dim0 --k $dim0 --nnz-ratio $nnzr --outfile $OUTFILE - done + for nnzr in 0.01 0.05 0.1 0.3; do + python -m sparse.spmm --format csr --m $dim0 --n $dim0 --k $dim0 --nnz-ratio $nnzr --outfile $OUTFILE + # python -m sparse.spmm --format coo --m $dim0 --n $dim0 --k $dim0 --nnz-ratio $nnzr --outfile $OUTFILE + done done -echo "----------------------" >> $OUTFILE +echo "----------------------" >>$OUTFILE cd $PYTORCH_HOME -echo "----- USE_MKL=0 ------" >> $OUTFILE +echo "----- USE_MKL=0 ------" >>$OUTFILE rm -rf build export USE_MKL=0 @@ -32,9 +32,9 @@ python setup.py install cd benchmarks for dim0 in 1000 5000 10000; do - for nnzr in 0.01 0.05 0.1 0.3; do - python -m sparse.spmv --format csr --m $dim0 --nnz-ratio $nnzr --outfile $OUTFILE - python -m sparse.spmv --format coo --m $dim0 --nnz-ratio $nnzr --outfile $OUTFILE - done + for nnzr in 0.01 0.05 0.1 0.3; do + python -m sparse.spmv --format csr --m $dim0 --nnz-ratio $nnzr --outfile $OUTFILE + python -m sparse.spmv --format coo --m $dim0 --nnz-ratio $nnzr --outfile $OUTFILE + done done -echo "----------------------" >> $OUTFILE +echo "----------------------" >>$OUTFILE diff --git a/docs/cpp/source/check-doxygen.sh b/docs/cpp/source/check-doxygen.sh index 3614c2d0ab27..c47327dfe558 100755 --- a/docs/cpp/source/check-doxygen.sh +++ b/docs/cpp/source/check-doxygen.sh @@ -5,12 +5,15 @@ set -ex ignore_warning() { # Invert match to filter out $1. set +e - grep -v "$1" doxygen-log.txt > temp.txt + grep -v "$1" doxygen-log.txt >temp.txt set -e mv temp.txt doxygen-log.txt } -command -v doxygen >/dev/null 2>&1 || { echo >&2 "doxygen is not supported. Aborting."; exit 1; } +command -v doxygen >/dev/null 2>&1 || { + echo >&2 "doxygen is not supported. Aborting." + exit 1 +} pushd "$(dirname "$0")/../../.." @@ -18,13 +21,13 @@ cp torch/_utils_internal.py tools/shared python -m torchgen.gen --source-path aten/src/ATen -python tools/setup_helpers/generate_code.py \ +python tools/setup_helpers/generate_code.py \ --native-functions-path aten/src/ATen/native/native_functions.yaml \ --tags-path aten/src/ATen/native/tags.yaml popd # Run doxygen and log all output. -doxygen "$(dirname $0)" 2> original-doxygen-log.txt +doxygen "$(dirname $0)" 2>original-doxygen-log.txt cp original-doxygen-log.txt doxygen-log.txt # Uncomment this if you need it for debugging; we're not printing this diff --git a/test/cpp/aoti_inference/standalone_compile.sh b/test/cpp/aoti_inference/standalone_compile.sh index 7e97f916f2dc..2dddf35fac39 100644 --- a/test/cpp/aoti_inference/standalone_compile.sh +++ b/test/cpp/aoti_inference/standalone_compile.sh @@ -1,22 +1,22 @@ #!/bin/sh if [ -z "$CXX" ]; then - CXX="clang++" - echo "Using system default C++ compiler: $CXX" + CXX="clang++" + echo "Using system default C++ compiler: $CXX" else - echo "Using user-provided C++ compiler: $CXX" + echo "Using user-provided C++ compiler: $CXX" fi if [ -z "$TORCH_ROOT_DIR" ]; then - echo "Error: The TORCH_ROOT_DIR environment variable must be set." >&2 - echo "Example: export TORCH_ROOT_DIR=/home/$USER/local/pytorch" >&2 - exit 1 + echo "Error: The TORCH_ROOT_DIR environment variable must be set." >&2 + echo "Example: export TORCH_ROOT_DIR=/home/$USER/local/pytorch" >&2 + exit 1 fi if [ $# -lt 2 ]; then - echo "Usage: $0 ." - echo "Example Usage: $0 standalone_test.cpp standalone_test.out." - exit 1 + echo "Usage: $0 ." + echo "Example Usage: $0 standalone_test.cpp standalone_test.out." + exit 1 fi # Building the wrapper diff --git a/test/mobile/custom_build/build.sh b/test/mobile/custom_build/build.sh index 3049b287bcc1..9d16eabdcdfa 100755 --- a/test/mobile/custom_build/build.sh +++ b/test/mobile/custom_build/build.sh @@ -19,7 +19,10 @@ set -ex -o pipefail -SRC_ROOT="$( cd "$(dirname "$0")"/../../.. ; pwd -P)" +SRC_ROOT="$( + cd "$(dirname "$0")"/../../.. + pwd -P +)" TEST_SRC_ROOT="${SRC_ROOT}/test/mobile/custom_build" BUILD_ROOT="${BUILD_ROOT:-${SRC_ROOT}/build_test_custom_build}" mkdir -p "${BUILD_ROOT}" @@ -72,7 +75,7 @@ build_predictor() { run_predictor() { cd "${PREDICTOR_BUILD_ROOT}" - ./Predictor "${MODEL}" > output.txt + ./Predictor "${MODEL}" >output.txt if cmp -s output.txt "${TEST_SRC_ROOT}/expected_output.txt"; then echo "Test result is the same as expected." diff --git a/test/mobile/lightweight_dispatch/build.sh b/test/mobile/lightweight_dispatch/build.sh index 7e062a89ea63..7311b4cde8ce 100755 --- a/test/mobile/lightweight_dispatch/build.sh +++ b/test/mobile/lightweight_dispatch/build.sh @@ -37,7 +37,6 @@ if [ "$ret" -ne 0 ]; then exit "$ret" fi - # run test if ! build/bin/test_codegen_unboxing; then echo "test_codegen_unboxing has failure!" diff --git a/test/run_doctests.sh b/test/run_doctests.sh index 2942e961c9da..e2e3a21e1805 100755 --- a/test/run_doctests.sh +++ b/test/run_doctests.sh @@ -12,17 +12,17 @@ invoked in 'run_test.py' # xdoctest -m torch --style=google list # Reference: https://stackoverflow.com/questions/59895/bash-script-dir -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) TORCH_MODPATH=$SCRIPT_DIR/../torch echo "TORCH_MODPATH = $TORCH_MODPATH" -if [[ ! -d "$TORCH_MODPATH" ]] ; then - echo "Could not find the path to the torch module" +if [[ ! -d "$TORCH_MODPATH" ]]; then + echo "Could not find the path to the torch module" else - export XDOCTEST_GLOBAL_EXEC="from torch import nn\nimport torch.nn.functional as F\nimport torch" - export XDOCTEST_OPTIONS="+IGNORE_WHITESPACE" - # Note: google wont catch numpy style docstrings (a few exist) but it also wont fail - # on things not intended to be doctests. - export XDOCTEST_STYLE="google" - xdoctest torch "$TORCH_MODPATH" --style="$XDOCTEST_STYLE" --global-exec "$XDOCTEST_GLOBAL_EXEC" --options="$XDOCTEST_OPTIONS" + export XDOCTEST_GLOBAL_EXEC="from torch import nn\nimport torch.nn.functional as F\nimport torch" + export XDOCTEST_OPTIONS="+IGNORE_WHITESPACE" + # Note: google wont catch numpy style docstrings (a few exist) but it also wont fail + # on things not intended to be doctests. + export XDOCTEST_STYLE="google" + xdoctest torch "$TORCH_MODPATH" --style="$XDOCTEST_STYLE" --global-exec "$XDOCTEST_GLOBAL_EXEC" --options="$XDOCTEST_OPTIONS" fi diff --git a/tools/bazel_tools/shellwrap.sh b/tools/bazel_tools/shellwrap.sh index 712788ae09e0..833b095eaca9 100755 --- a/tools/bazel_tools/shellwrap.sh +++ b/tools/bazel_tools/shellwrap.sh @@ -11,29 +11,29 @@ shell='/bin/bash' rcfile='/tmp/pytorch_bazel_tools_shellwrap' -while [[ $# -gt 0 ]] ; do - case "$1" in - --shell_bin_path) - # path for the shell executable - shell="$2" - shift 2 - ;; - --rcfile) - # path for the file used to write the environment - rcfile="$2" - shift 2 - ;; - *) - # remaining arguments are part of the command for execution - break - ;; - esac +while [[ $# -gt 0 ]]; do + case "$1" in + --shell_bin_path) + # path for the shell executable + shell="$2" + shift 2 + ;; + --rcfile) + # path for the file used to write the environment + rcfile="$2" + shift 2 + ;; + *) + # remaining arguments are part of the command for execution + break + ;; + esac done if ! tty -s; then - echo 'A tty is not available.' - echo "Use \`bazel run\`, not \`bazel test\`." - exit 1 + echo 'A tty is not available.' + echo "Use \`bazel run\`, not \`bazel test\`." + exit 1 fi NOCOLOR='\033[0m' @@ -41,8 +41,8 @@ YELLOW='\033[1;33m' # store the environment in a file export PYTORCH_SHELL_COMMAND=$* -echo "alias run=\"$*\"" > "$rcfile" -echo "PS1='\s-\v\$ '" >> "$rcfile" +echo "alias run=\"$*\"" >"$rcfile" +echo "PS1='\s-\v\$ '" >>"$rcfile" echo ===== # print the execution command (command is yellow) diff --git a/tools/gen_flatbuffers.sh b/tools/gen_flatbuffers.sh index cc0263dbbf45..57c7d7a6e3f8 100644 --- a/tools/gen_flatbuffers.sh +++ b/tools/gen_flatbuffers.sh @@ -8,8 +8,8 @@ cmake .. cmake --build . --target flatc mkdir -p "$ROOT/build/torch/csrc/jit/serialization" ./flatc --cpp --gen-mutable --scoped-enums \ - -o "$ROOT/torch/csrc/jit/serialization" \ - -c "$ROOT/torch/csrc/jit/serialization/mobile_bytecode.fbs" -echo '// @generated' >> "$ROOT/torch/csrc/jit/serialization/mobile_bytecode_generated.h" + -o "$ROOT/torch/csrc/jit/serialization" \ + -c "$ROOT/torch/csrc/jit/serialization/mobile_bytecode.fbs" +echo '// @generated' >>"$ROOT/torch/csrc/jit/serialization/mobile_bytecode_generated.h" cd "$ROOT" || exit exit diff --git a/tools/git_add_generated_dirs.sh b/tools/git_add_generated_dirs.sh index d91f513c4eeb..c56f9e5d080d 100755 --- a/tools/git_add_generated_dirs.sh +++ b/tools/git_add_generated_dirs.sh @@ -10,4 +10,4 @@ # If not satisfied: Go to 3) BASEDIR=$(dirname "$0") -(< $BASEDIR/generated_dirs.txt xargs -i find {} -type f) | xargs git add -f +(<$BASEDIR/generated_dirs.txt xargs -i find {} -type f) | xargs git add -f diff --git a/tools/git_reset_generated_dirs.sh b/tools/git_reset_generated_dirs.sh index 852693e09d55..6d7e29bc114d 100755 --- a/tools/git_reset_generated_dirs.sh +++ b/tools/git_reset_generated_dirs.sh @@ -10,4 +10,4 @@ # If not satisfied: Go to 3) BASEDIR=$(dirname "$0") -(< $BASEDIR/generated_dirs.txt xargs -i find {} -type f) | xargs git reset HEAD +(<$BASEDIR/generated_dirs.txt xargs -i find {} -type f) | xargs git reset HEAD diff --git a/tools/iwyu/run.sh b/tools/iwyu/run.sh index e67316f49c8b..7323c762f5f6 100755 --- a/tools/iwyu/run.sh +++ b/tools/iwyu/run.sh @@ -10,5 +10,5 @@ TORCH_ROOT=$(dirname $(dirname $(dirname $(readlink -f $0)))) iwyu_tool -p $TORCH_ROOT/build $@ -- -Wno-unknown-warning-option -Xiwyu \ - --no_fwd_decls -Xiwyu --mapping_file=$TORCH_ROOT/tools/iwyu/all.imp \ - | python $TORCH_ROOT/tools/iwyu/fixup.py + --no_fwd_decls -Xiwyu --mapping_file=$TORCH_ROOT/tools/iwyu/all.imp | + python $TORCH_ROOT/tools/iwyu/fixup.py diff --git a/torchgen/_autoheuristic/collect_data.sh b/torchgen/_autoheuristic/collect_data.sh index 73b6364829b9..3d349a4655f4 100644 --- a/torchgen/_autoheuristic/collect_data.sh +++ b/torchgen/_autoheuristic/collect_data.sh @@ -3,16 +3,16 @@ # This script makes it easy to parallelize data collection across multiple GPUs # Check if tmux is installed -if ! command -v tmux &> /dev/null; then - echo "tmux is not installed. Please install it and try again." - exit 1 +if ! command -v tmux &>/dev/null; then + echo "tmux is not installed. Please install it and try again." + exit 1 fi # Check if the correct number of arguments is provided if [ "$#" -ne 5 ]; then - echo "Usage: $0 \"\" " - echo "Example: $0 \"python run.py --a b --b c\" 1,4,5,3 1000 pytorch-3.10 a100" - exit 1 + echo "Usage: $0 \"\" " + echo "Example: $0 \"python run.py --a b --b c\" 1,4,5,3 1000 pytorch-3.10 a100" + exit 1 fi PYTHON_COMMAND=$1 @@ -26,7 +26,7 @@ SESSION_NAME="parallel_run_$(date +%s)" tmux new-session -d -s "$SESSION_NAME" # Split the device numbers -IFS=',' read -ra DEVICES <<< "$DEVICE_NUMBERS" +IFS=',' read -ra DEVICES <<<"$DEVICE_NUMBERS" NUM_GPUS=${#DEVICES[@]} NUM_SAMPLES_PER_GPU=$((NUM_SAMPLES / NUM_GPUS)) @@ -35,14 +35,14 @@ echo "Each GPU will collect ${NUM_SAMPLES_PER_GPU}" # Function to create a new pane and run the script create_pane() { - local device=$1 - tmux split-window -t "$SESSION_NAME" - tmux send-keys -t "$SESSION_NAME" "conda activate ${CONDA_ENV} && $PYTHON_COMMAND --device $device -o ${OUTPUT_DIR}/data_${device}.txt --num-samples ${NUM_SAMPLES_PER_GPU}" C-m + local device=$1 + tmux split-window -t "$SESSION_NAME" + tmux send-keys -t "$SESSION_NAME" "conda activate ${CONDA_ENV} && $PYTHON_COMMAND --device $device -o ${OUTPUT_DIR}/data_${device}.txt --num-samples ${NUM_SAMPLES_PER_GPU}" C-m } # Create panes for each device number for device in "${DEVICES[@]}"; do - create_pane ${device} + create_pane ${device} done # Remove the first pane (empty one) diff --git a/torchgen/_autoheuristic/generate_heuristic.sh b/torchgen/_autoheuristic/generate_heuristic.sh index 97696a43712d..3b6330c63257 100644 --- a/torchgen/_autoheuristic/generate_heuristic.sh +++ b/torchgen/_autoheuristic/generate_heuristic.sh @@ -1,8 +1,8 @@ #!/bin/bash if [ $# -lt 8 ]; then - echo "Error: This script requires exactly at least 8 arguments." - exit 1 + echo "Error: This script requires exactly at least 8 arguments." + exit 1 fi MODE=$1 @@ -18,19 +18,19 @@ EXTRA_TRAIN_ARGS=$9 mkdir -p ${OUTPUT_DIR} if [ "$MODE" = "collect" ]; then - # this will collect data for NUM_SAMPLES samples on the number of GPUs specified in GPU_DEVICE_IDS in parallel - bash ../collect_data.sh "python ${BENCHMARK_SCRIPT}" ${GPU_DEVICE_IDS} ${NUM_SAMPLES} ${CONDA_ENV} ${OUTPUT_DIR} + # this will collect data for NUM_SAMPLES samples on the number of GPUs specified in GPU_DEVICE_IDS in parallel + bash ../collect_data.sh "python ${BENCHMARK_SCRIPT}" ${GPU_DEVICE_IDS} ${NUM_SAMPLES} ${CONDA_ENV} ${OUTPUT_DIR} elif [ "$MODE" = "generate" ]; then - # the bash script above generates one separate txt file per GPU - # if GPU_DEVICE_IDS=6,7, it will generate "data_6.txt", "data_7.txt" inside OUTPUT_DIR - # these files have to be merged into a single file before we can use AutoHeuristic to learn a heuristic - OUTPUT_FILE="${OUTPUT_DIR}/${HEURISTIC_NAME}.txt" - INPUT_FILES=$(echo $GPU_DEVICE_IDS | tr ',' '\n' | sed "s|^|${OUTPUT_DIR}/data_|" | sed 's/$/.txt/') - python ../merge_data.py ${OUTPUT_FILE} ${INPUT_FILES} + # the bash script above generates one separate txt file per GPU + # if GPU_DEVICE_IDS=6,7, it will generate "data_6.txt", "data_7.txt" inside OUTPUT_DIR + # these files have to be merged into a single file before we can use AutoHeuristic to learn a heuristic + OUTPUT_FILE="${OUTPUT_DIR}/${HEURISTIC_NAME}.txt" + INPUT_FILES=$(echo $GPU_DEVICE_IDS | tr ',' '\n' | sed "s|^|${OUTPUT_DIR}/data_|" | sed 's/$/.txt/') + python ../merge_data.py ${OUTPUT_FILE} ${INPUT_FILES} - # This will learn a heuristic and generate the code into torch/_inductor/autoheuristic/artifacts/_${HEURISTIC_NAME}.py - python ${TRAIN_SCRIPT} ${OUTPUT_FILE} --heuristic-name ${HEURISTIC_NAME} ${EXTRA_TRAIN_ARGS} + # This will learn a heuristic and generate the code into torch/_inductor/autoheuristic/artifacts/_${HEURISTIC_NAME}.py + python ${TRAIN_SCRIPT} ${OUTPUT_FILE} --heuristic-name ${HEURISTIC_NAME} ${EXTRA_TRAIN_ARGS} else - echo "Error: Invalid mode ${MODE}. Please use 'collect' or 'generate'." - exit 1 + echo "Error: Invalid mode ${MODE}. Please use 'collect' or 'generate'." + exit 1 fi diff --git a/torchgen/_autoheuristic/mixed_mm/generate_heuristic_mixedmm.sh b/torchgen/_autoheuristic/mixed_mm/generate_heuristic_mixedmm.sh index 27a671511bea..bb0d4b2bbfd8 100644 --- a/torchgen/_autoheuristic/mixed_mm/generate_heuristic_mixedmm.sh +++ b/torchgen/_autoheuristic/mixed_mm/generate_heuristic_mixedmm.sh @@ -1,10 +1,10 @@ #!/bin/bash if [ $# -ne 1 ]; then - echo "Error: This script requires exactly one argument." - echo "`bash generate_heuristic_mixedmm.sh collect` to run benchmark and collect training data." - echo "`bash generate_heuristic_mixedmm.sh generate` to use the collected data to learn a heuristic." - exit 1 + echo "Error: This script requires exactly one argument." + echo "$(bash generate_heuristic_mixedmm.sh collect) to run benchmark and collect training data." + echo "$(bash generate_heuristic_mixedmm.sh generate) to use the collected data to learn a heuristic." + exit 1 fi MODE=$1 diff --git a/torchgen/_autoheuristic/mixed_mm/get_mixedmm_dataset.sh b/torchgen/_autoheuristic/mixed_mm/get_mixedmm_dataset.sh index 531b698bde61..afc3c05fa907 100644 --- a/torchgen/_autoheuristic/mixed_mm/get_mixedmm_dataset.sh +++ b/torchgen/_autoheuristic/mixed_mm/get_mixedmm_dataset.sh @@ -1,13 +1,13 @@ #!/bin/bash -base_url='https://github.com/AlnisM/autoheuristic-datasets/raw/main/' # @lint-ignore +base_url='https://github.com/AlnisM/autoheuristic-datasets/raw/main/' # @lint-ignore a100_data='mixedmm_a100_data.zip' h100_data='mixedmm_h100_data.zip' datasets=("${a100_data}" "${h100_data}") for dataset in "${datasets[@]}"; do - rm -f ${dataset} - url="${base_url}${dataset}" - wget ${url} - unzip -o ${dataset} - rm ${dataset} + rm -f ${dataset} + url="${base_url}${dataset}" + wget ${url} + unzip -o ${dataset} + rm ${dataset} done diff --git a/torchgen/_autoheuristic/mm/get_mm_dataset.sh b/torchgen/_autoheuristic/mm/get_mm_dataset.sh index 60280104ebf4..2702c6e4dfd1 100644 --- a/torchgen/_autoheuristic/mm/get_mm_dataset.sh +++ b/torchgen/_autoheuristic/mm/get_mm_dataset.sh @@ -1,12 +1,12 @@ #!/bin/bash -base_url='https://github.com/AlnisM/autoheuristic-datasets/raw/main/' # @lint-ignore +base_url='https://github.com/AlnisM/autoheuristic-datasets/raw/main/' # @lint-ignore a100_data='a100_mm.zip' h100_data='h100_mm.zip' datasets=("${a100_data}" "${h100_data}") for dataset in "${datasets[@]}"; do - url="${base_url}${dataset}" - wget ${url} - unzip ${dataset} - rm ${dataset} + url="${base_url}${dataset}" + wget ${url} + unzip ${dataset} + rm ${dataset} done diff --git a/torchgen/_autoheuristic/pad_mm/generate_heuristic_pad_mm.sh b/torchgen/_autoheuristic/pad_mm/generate_heuristic_pad_mm.sh index b7dac53179be..99c757637406 100644 --- a/torchgen/_autoheuristic/pad_mm/generate_heuristic_pad_mm.sh +++ b/torchgen/_autoheuristic/pad_mm/generate_heuristic_pad_mm.sh @@ -1,10 +1,10 @@ #!/bin/bash if [ $# -ne 1 ]; then - echo "Error: This script requires exactly one argument." - echo "`bash generate_heuristic_pad_mm.sh collect` to run benchmark and collect training data." - echo "`bash generate_heuristic_pad_mm.sh generate` to use the collected data to learn a heuristic." - exit 1 + echo "Error: This script requires exactly one argument." + echo "$(bash generate_heuristic_pad_mm.sh collect) to run benchmark and collect training data." + echo "$(bash generate_heuristic_pad_mm.sh generate) to use the collected data to learn a heuristic." + exit 1 fi MODE=$1 diff --git a/torchgen/_autoheuristic/pad_mm/get_padmm_dataset.sh b/torchgen/_autoheuristic/pad_mm/get_padmm_dataset.sh index ba8ed904660b..18a7beb671dd 100644 --- a/torchgen/_autoheuristic/pad_mm/get_padmm_dataset.sh +++ b/torchgen/_autoheuristic/pad_mm/get_padmm_dataset.sh @@ -1,7 +1,7 @@ #!/bin/bash a100_zip="pad_mm_a100_data.zip" -a100_data="https://github.com/AlnisM/autoheuristic-datasets/raw/main/${a100_zip}" # @lint-ignore +a100_data="https://github.com/AlnisM/autoheuristic-datasets/raw/main/${a100_zip}" # @lint-ignore rm -f ${a100_zip} wget ${a100_data} unzip -o ${a100_zip}