#! /bin/bash ws=$(realpath $(dirname "${BASH_SOURCE[0]}")) cd $ws # 允许通过环境变量直接指定 target_hardware,非交互式环境默认使用 AX615 if [ -n "$TARGET_HARDWARE" ]; then target_hardware=$TARGET_HARDWARE elif [ -t 0 ]; then options=(AX615 AX650 AX637 M57 "其他(手动输入)") PS3="请选择 target_hardware(输入数字): " select opt in "${options[@]}"; do case $opt in AX615|AX637|AX650|M57) target_hardware=$opt break ;; "其他(手动输入)") read -rp "请输入 target_hardware: " target_hardware if [ -n "$target_hardware" ]; then break fi echo "输入不能为空,请重新选择" ;; *) echo "无效选项,请重新选择" ;; esac done else target_hardware=AX650 fi echo "使用 target_hardware: $target_hardware" find $ws -maxdepth 2 -name "*.onnx" | parallel -I {} -j 8 \ " d=\$(realpath \$(dirname {})) if [ -f \$d/output/compiled.axmodel ]; then echo '[{}] axmodel already exists, skip.'; exit 0; fi echo 'start building [{}]...'; time pulsar2 build \ --target_hardware $target_hardware \ --npu_mode NPU1 \ --input {} \ --config \$d/config.json \ --output_dir \$d/output 2>&1 | tee \$d/build.log || \ { echo 'build [{}] failed, skip.'; exit 0; }; echo 'build [{}] finish.'; " echo "" echo "=== 模型转出情况 ===" while IFS= read -r onnx; do d=$(realpath $(dirname "$onnx")) name=$(basename "$d") if [ -f "$d/output/compiled.axmodel" ]; then echo "✅ Task '$name'" else echo "❌ Task '$name'" fi done < <(find $ws -maxdepth 2 -name "*.onnx" | sort)