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

[tuner] Add abstractmethod in autotune.py. Create punet_autotune.py #98

Merged
merged 20 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
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
7 changes: 5 additions & 2 deletions tuning/benchmark_dispatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ readonly NAME="$(basename "$INPUT" .mlir)"

# printf "Benchmarking $(basename ${INPUT}) on ${DEVICE}\n"

# Replace invalid characters in DEVICE variable
SANITIZED_DEVICE=$(echo "${DEVICE}" | sed 's/[^a-zA-Z0-9._-]/_/g')

timeout 16s ./tools/iree-benchmark-module --device="${DEVICE}" --module="${INPUT}" \
--hip_use_streams=true --hip_allow_inline_execution=true \
--batch_size=1000 --benchmark_repetitions=3 > "${DIR}/benchmark_log_${DEVICE}.out" 2>&1 || (mv "$INPUT" "${DIR}/benchmark_failed" && exit 0)
--batch_size=1000 --benchmark_repetitions=3 > "${DIR}/benchmark_log_${SANITIZED_DEVICE}.out" 2>&1 || (mv "$INPUT" "${DIR}/benchmark_failed" && exit 0)

MEAN_TIME="$(grep --text real_time_mean "${DIR}/benchmark_log_${DEVICE}.out" | awk '{print $2}')"
MEAN_TIME="$(grep --text real_time_mean "${DIR}/benchmark_log_${SANITIZED_DEVICE}.out" | awk '{print $2}')"
printf "%s\tMean Time: %.1f\n" "$(basename "$INPUT" .vmfb)" "$MEAN_TIME"
2 changes: 1 addition & 1 deletion tuning/tune.py → tuning/candidate_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from iree.compiler.dialects import _linalg_ops_gen, _util_ops_gen

"""
Usage: ./tune.py 121.mlir -o "tuning/candidates" -l 1024 --lhs-dims=mk --rhs-dims=nk --tile-dims=mnk
Usage: ./candidate_gen.py 121.mlir -o "tuning/candidates" -l 1024 --lhs-dims=mk --rhs-dims=nk --tile-dims=mnk
"""

tune_logger = logging.getLogger("tune")
Expand Down
4 changes: 2 additions & 2 deletions tuning/compile_candidate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ readonly DIR="$(dirname "$INPUT")"
readonly BASENAME="$(basename "$INPUT" .mlir)"
readonly OUT="${DIR}/compiled/${BASENAME}.vmfb"

mkdir -p "${DIR}/compiled" "${DIR}/failed" "${DIR}/configs"
mkdir -p "${DIR}/compiled" "${DIR}/failed" "${DIR}/specs"

timeout 4s ./punet.sh "$INPUT" -o "$OUT" --compile-from=executable-sources 2>/dev/null || (mv "$INPUT" "$DIR/failed" && exit 1)
tools/iree-dump-module "$OUT" | grep -q 'rocm-hsaco-fb' || (mv "$INPUT" "$DIR/failed" && rm -f "$OUT" && exit 1)
if [ -f "${DIR}/${BASENAME}_config.mlir" ]; then
cat "${DIR}/../config_prolog.mlir" "${DIR}/${BASENAME}_config.mlir" "${DIR}/../config_epilog.mlir" > "${DIR}/configs/${BASENAME}_spec.mlir"
cat "${DIR}/../config_prolog.mlir" "${DIR}/${BASENAME}_config.mlir" "${DIR}/../config_epilog.mlir" > "${DIR}/specs/${BASENAME}_spec.mlir"
fi
echo "Compiling ${INPUT}: success"
Loading
Loading