Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
30 changes: 28 additions & 2 deletions test/npu_validation/scripts/run_remote_npu_validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set -euo pipefail
STAGE="${STAGE:-run}" # build|run
RUN_MODE="${RUN_MODE:-npu}" # npu|sim
SOC_VERSION="${SOC_VERSION:-Ascend910}"
GOLDEN_MODE="${GOLDEN_MODE:-npu}" # sim|npu|skip
GOLDEN_MODE="${GOLDEN_MODE:-npu}" # sim|npu|npu_precision|skip
PTO_ISA_REPO="${PTO_ISA_REPO:-https://gitcode.com/cann/pto-isa.git}"
PTO_ISA_COMMIT="${PTO_ISA_COMMIT:-}"
DEVICE_ID="${DEVICE_ID:-0}"
Expand Down Expand Up @@ -307,6 +307,19 @@ while IFS= read -r -d '' cpp; do
done
}

has_reference_golden_outputs() {
local found=0
if [[ -f "./outputs.txt" ]]; then
while IFS= read -r name; do
[[ -n "${name}" ]] || continue
found=1
[[ -f "./golden_${name}.bin" ]] || return 1
done < "./outputs.txt"
[[ "${found}" -eq 1 ]] && return 0
fi
compgen -G "./golden_*.bin" > /dev/null
}

case "${GOLDEN_MODE}" in
sim)
python3 ./golden.py
Expand All @@ -333,6 +346,19 @@ while IFS= read -r -d '' cpp; do
fi
COMPARE_STRICT=1 python3 ./compare.py
;;
npu_precision)
if [[ "${RUN_MODE}" != "npu" ]]; then
log "ERROR: GOLDEN_MODE=npu_precision requires RUN_MODE=npu"
exit 2
fi
python3 ./golden.py
if ! has_reference_golden_outputs; then
log "ERROR: GOLDEN_MODE=npu_precision requires golden.py to generate golden_*.bin"
exit 2
fi
LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" ./build/${testcase}
COMPARE_STRICT=1 python3 ./compare.py
;;
skip)
python3 ./golden.py
if [[ "${RUN_MODE}" == "npu" ]]; then
Expand All @@ -341,7 +367,7 @@ while IFS= read -r -d '' cpp; do
log "WARN: compare skipped (GOLDEN_MODE=skip)"
;;
*)
log "ERROR: unknown GOLDEN_MODE=${GOLDEN_MODE} (expected: sim|npu|skip)"
log "ERROR: unknown GOLDEN_MODE=${GOLDEN_MODE} (expected: sim|npu|npu_precision|skip)"
exit 2
;;
esac
Expand Down
30 changes: 28 additions & 2 deletions test/npu_validation/templates/run_sh_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set -euo pipefail

RUN_MODE="@RUN_MODE@"
SOC_VERSION="@SOC_VERSION@"
GOLDEN_MODE="${GOLDEN_MODE:-npu}" # sim|npu|skip
GOLDEN_MODE="${GOLDEN_MODE:-npu}" # sim|npu|npu_precision|skip
BUILD_DIR="${BUILD_DIR:-build}"

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
Expand Down Expand Up @@ -110,6 +110,19 @@ copy_outputs_as_golden() {
done
}

has_reference_golden_outputs() {
local found=0
if [[ -f "${ROOT_DIR}/outputs.txt" ]]; then
while IFS= read -r name; do
[[ -n "${name}" ]] || continue
found=1
[[ -f "${ROOT_DIR}/golden_${name}.bin" ]] || return 1
done < "${ROOT_DIR}/outputs.txt"
[[ "${found}" -eq 1 ]] && return 0
fi
compgen -G "${ROOT_DIR}/golden_*.bin" > /dev/null
}

case "${GOLDEN_MODE}" in
sim)
LD_LIBRARY_PATH="${LD_LIBRARY_PATH_SIM}" "${ROOT_DIR}/${BUILD_DIR}/@EXECUTABLE@_sim"
Expand All @@ -131,6 +144,19 @@ case "${GOLDEN_MODE}" in
LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" "${ROOT_DIR}/${BUILD_DIR}/@EXECUTABLE@"
COMPARE_STRICT=1 python3 "${ROOT_DIR}/compare.py"
;;
npu_precision)
if [[ "${RUN_MODE}" != "npu" ]]; then
echo "[ERROR] GOLDEN_MODE=npu_precision requires RUN_MODE=npu" >&2
exit 2
fi
python3 "${ROOT_DIR}/golden.py"
if ! has_reference_golden_outputs; then
echo "[ERROR] GOLDEN_MODE=npu_precision requires golden.py to generate golden_*.bin" >&2
exit 2
fi
LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" "${ROOT_DIR}/${BUILD_DIR}/@EXECUTABLE@"
COMPARE_STRICT=1 python3 "${ROOT_DIR}/compare.py"
;;
skip)
if [[ "${RUN_MODE}" == "npu" ]]; then
python3 "${ROOT_DIR}/golden.py"
Expand All @@ -139,7 +165,7 @@ case "${GOLDEN_MODE}" in
echo "[WARN] compare skipped (GOLDEN_MODE=skip)"
;;
*)
echo "[ERROR] Unknown GOLDEN_MODE=${GOLDEN_MODE} (expected: sim|npu|skip)" >&2
echo "[ERROR] Unknown GOLDEN_MODE=${GOLDEN_MODE} (expected: sim|npu|npu_precision|skip)" >&2
exit 2
;;
esac
34 changes: 32 additions & 2 deletions test/samples/TInsert/board_validation/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set -euo pipefail

RUN_MODE="npu"
SOC_VERSION="Ascend910"
GOLDEN_MODE="${GOLDEN_MODE:-sim}" # sim|npu|skip
GOLDEN_MODE="${GOLDEN_MODE:-sim}" # sim|npu|npu_precision|skip
BUILD_DIR="${BUILD_DIR:-build}"
ACL_DEVICE_ID_NPU="${ACL_DEVICE_ID:-}"
ACL_DEVICE_ID_SIM="${ACL_DEVICE_ID_SIM:-0}"
Expand Down Expand Up @@ -112,6 +112,19 @@ copy_outputs_as_golden() {
done
}

has_reference_golden_outputs() {
local found=0
if [[ -f "${ROOT_DIR}/outputs.txt" ]]; then
while IFS= read -r name; do
[[ -n "${name}" ]] || continue
found=1
[[ -f "${ROOT_DIR}/golden_${name}.bin" ]] || return 1
done < "${ROOT_DIR}/outputs.txt"
[[ "${found}" -eq 1 ]] && return 0
fi
compgen -G "${ROOT_DIR}/golden_*.bin" > /dev/null
}

case "${GOLDEN_MODE}" in
sim)
ACL_DEVICE_ID="${ACL_DEVICE_ID_SIM}" LD_LIBRARY_PATH="${LD_LIBRARY_PATH_SIM}" "${ROOT_DIR}/${BUILD_DIR}/tinsert_sim"
Expand All @@ -137,6 +150,23 @@ case "${GOLDEN_MODE}" in
LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" "${ROOT_DIR}/${BUILD_DIR}/tinsert"
COMPARE_STRICT=1 python3 "${ROOT_DIR}/compare.py"
;;
npu_precision)
if [[ "${RUN_MODE}" != "npu" ]]; then
echo "[ERROR] GOLDEN_MODE=npu_precision requires RUN_MODE=npu" >&2
exit 2
fi
python3 "${ROOT_DIR}/golden.py"
if ! has_reference_golden_outputs; then
echo "[ERROR] GOLDEN_MODE=npu_precision requires golden.py to generate golden_*.bin" >&2
exit 2
fi
if [[ -n "${ACL_DEVICE_ID_NPU}" ]]; then
ACL_DEVICE_ID="${ACL_DEVICE_ID_NPU}" LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" "${ROOT_DIR}/${BUILD_DIR}/tinsert"
else
LD_LIBRARY_PATH="${LD_LIBRARY_PATH_NPU}" "${ROOT_DIR}/${BUILD_DIR}/tinsert"
fi
COMPARE_STRICT=1 python3 "${ROOT_DIR}/compare.py"
;;
skip)
if [[ "${RUN_MODE}" == "npu" ]]; then
python3 "${ROOT_DIR}/golden.py"
Expand All @@ -145,7 +175,7 @@ case "${GOLDEN_MODE}" in
echo "[WARN] compare skipped (GOLDEN_MODE=skip)"
;;
*)
echo "[ERROR] Unknown GOLDEN_MODE=${GOLDEN_MODE} (expected: sim|npu|skip)" >&2
echo "[ERROR] Unknown GOLDEN_MODE=${GOLDEN_MODE} (expected: sim|npu|npu_precision|skip)" >&2
exit 2
;;
esac