diff --git a/cutile-rs/scripts/run_examples.sh b/cutile-rs/scripts/run_examples.sh index 92bfa695bd..f171f1c6e5 100755 --- a/cutile-rs/scripts/run_examples.sh +++ b/cutile-rs/scripts/run_examples.sh @@ -16,6 +16,23 @@ while [[ $# -gt 0 ]]; do esac done +# reference-cpu pulls in candle, whose gemm-f16 kernels use FP16 arithmetic +# instructions that the generic aarch64 target does not enable. Turn on just +# that extension when this CPU has it (asimdhp); otherwise build without +# reference-cpu and skip the examples that require it. +SKIP_EXAMPLES=() +if [[ "$(uname -m)" == "aarch64" && "$EXTRA_FEATURES" == *reference-cpu* ]]; then + if grep -qw asimdhp /proc/cpuinfo; then + export RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }-C target-feature=+fp16" + else + features="${EXTRA_FEATURES#--features }" + features=$(tr ',' '\n' <<< "$features" | grep -vx 'reference-cpu' | paste -sd, -) + EXTRA_FEATURES="${features:+--features $features}" + SKIP_EXAMPLES=(async_gemm flash_attention) + echo "No FP16 arithmetic on this aarch64 CPU: skipping the reference-cpu examples" + fi +fi + if [[ -n "$EXTRA_FEATURES" ]]; then print_header "Running examples ($EXTRA_FEATURES)" else @@ -28,7 +45,7 @@ run_step \ echo -e "${YELLOW}>>> Running cutile-examples (GPU)${NC}" cd "$REPO_ROOT/cutile-examples" || exit 1 -run_examples "$REPO_ROOT/cutile-examples/examples" $EXTRA_FEATURES +run_examples "$REPO_ROOT/cutile-examples/examples" $EXTRA_FEATURES "${SKIP_EXAMPLES[@]}" print_summary_and_exit \ "All supported examples passed (see skipped examples above)." \