Skip to content

Commit 190c6f0

Browse files
committed
Add --verbose flag for riscv64 scripts
1 parent eb5d50d commit 190c6f0

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

.ci/scripts/test_riscv_qemu.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ et_root_dir=$(realpath "${script_dir}/../..")
1717
model="add"
1818
xnnpack=false
1919
quantize=false
20+
verbose=false
2021

2122
usage() {
2223
cat <<EOF
@@ -34,6 +35,7 @@ for arg in "$@"; do
3435
--model=*) model="${arg#*=}" ;;
3536
--xnnpack) xnnpack=true ;;
3637
--quantize) quantize=true ;;
38+
--verbose) verbose=true ;;
3739
-h|--help) usage; exit 0 ;;
3840
*) echo "Unknown option: $arg" >&2; usage; exit 1 ;;
3941
esac
@@ -46,6 +48,9 @@ fi
4648
if ${quantize}; then
4749
run_extra_args+=(--quantize)
4850
fi
51+
if ${verbose}; then
52+
run_extra_args+=(--verbose)
53+
fi
4954

5055
bash "${et_root_dir}/examples/riscv/setup.sh"
5156
bash "${et_root_dir}/examples/riscv/run.sh" --model="${model}" "${run_extra_args[@]}"

examples/riscv/aot_riscv.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
import argparse
14+
import logging
1415
from pathlib import Path
1516

1617
import torch
@@ -75,8 +76,16 @@ def main() -> None:
7576
action="store_true",
7677
help="Produce an 8-bit quantized model",
7778
)
79+
parser.add_argument(
80+
"--verbose",
81+
action="store_true",
82+
help="Enable XNNPACK partitioner DEBUG logging and dump the lowered graph",
83+
)
7884
args = parser.parse_args()
7985

86+
if args.verbose:
87+
logging.basicConfig(level=logging.DEBUG)
88+
8089
if args.output is None:
8190
args.output = Path(f"{args.model}_riscv.bpte")
8291

@@ -100,7 +109,8 @@ def main() -> None:
100109
from executorch.backends.xnnpack.partition.xnnpack_partitioner import (
101110
XnnpackPartitioner,
102111
)
103-
partitioners.append(XnnpackPartitioner())
112+
113+
partitioners.append(XnnpackPartitioner(verbose=args.verbose))
104114

105115
compile_config = None
106116
if args.quantize:
@@ -121,6 +131,11 @@ def main() -> None:
121131
f"quantize={args.quantize} delegated_nodes={delegated}"
122132
)
123133

134+
if args.verbose:
135+
from executorch.exir.backend.utils import print_delegated_graph
136+
137+
print_delegated_graph(edge.exported_program().graph_module)
138+
124139
et_program = edge.to_executorch()
125140

126141
test_suite = MethodTestSuite(

examples/riscv/run.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ qemu_timeout="600"
2323
model="add"
2424
xnnpack=false
2525
quantize=false
26+
verbose=false
2627

2728
usage() {
2829
cat <<EOF
@@ -31,6 +32,7 @@ Options:
3132
--model=<NAME> Which model to export and run (default: ${model})
3233
--xnnpack Enable the XNNPACK backend (AOT partitioner + runtime)
3334
--quantize Produce an 8-bit quantized model
35+
--verbose Enable XNNPACK partitioner DEBUG logging and dump the lowered graph
3436
--build_only Only export and cross-compile; do not invoke QEMU
3537
--build_dir=<DIR> CMake build directory (default: ${build_dir})
3638
--output_dir=<DIR> Directory for the exported .bpte (default: ${output_dir})
@@ -45,6 +47,7 @@ for arg in "$@"; do
4547
--model=*) model="${arg#*=}" ;;
4648
--xnnpack) xnnpack=true ;;
4749
--quantize) quantize=true ;;
50+
--verbose) verbose=true ;;
4851
--build_only) build_only=true ;;
4952
--build_dir=*) build_dir="${arg#*=}" ;;
5053
--output_dir=*) output_dir="${arg#*=}" ;;
@@ -66,6 +69,9 @@ fi
6669
if ${quantize}; then
6770
aot_extra_args+=(--quantize)
6871
fi
72+
if ${verbose}; then
73+
aot_extra_args+=(--verbose)
74+
fi
6975
python "${script_dir}/aot_riscv.py" --model "${model}" "${aot_extra_args[@]}" --output "${bpte_path}"
7076

7177
echo "[run.sh] Step 2/3: cross-compile executor_runner for riscv64-linux"

0 commit comments

Comments
 (0)