@@ -22,7 +22,7 @@ if [[ "$1" == "-h" || "$1" == "--help" ]]; then
2222fi
2323
2424if [[ $# -eq 0 ]]; then
25- TEST_SUITES=(run_ootb_tests_ethos_u run_ootb_tests_tosa run_ootb_tests_vgf run_deit_e2e_ethos_u)
25+ TEST_SUITES=(run_ootb_tests_ethos_u run_ootb_tests_tosa run_ootb_tests_vgf run_deit_e2e_ethos_u run_swin2sr_e2e_vgf )
2626else
2727 TEST_SUITES=(" $1 " )
2828fi
@@ -66,7 +66,7 @@ run_deit_e2e_ethos_u() {
6666 local image_path=" ${work_root} /dog.bmp"
6767 local pte_path=" ${export_dir} /deit_tiny_smoke.pte"
6868 local toolchain_file=" ${et_root_dir} /examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake"
69- echo " ${FUNCNAME} : Work root is ${work_root} ; existing artifacts will be reused if present"
69+ echo " ${FUNCNAME} : Work directory: ${work_root} ; existing artifacts will be reused if present"
7070
7171 mkdir -p " ${model_dir} " " ${export_dir} " " ${build_dir} "
7272
@@ -150,6 +150,135 @@ run_deit_e2e_ethos_u() {
150150 echo " ${FUNCNAME} : PASS"
151151}
152152
153+ run_swin2sr_e2e_vgf () {
154+ echo " $FUNCNAME : Prepare demo assets, export FP/INT8, build, and run the Swin2SR VGF e2e test"
155+
156+ local script_dir
157+ script_dir=$( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd)
158+ et_root_dir=$( cd " ${script_dir} /../../.." && pwd)
159+ local example_dir=" ${et_root_dir} /examples/arm/super_resolution_example_vgf"
160+ local work_root=" ${et_root_dir} /arm_test/swin2sr_vgf_ootb_smoke"
161+ local demo_dir=" ${work_root} /demo_assets"
162+ local runtime_dir=" ${demo_dir} /runtime"
163+ local runner_path=" ${work_root} /executor_runner"
164+ local input_image=" ${runtime_dir} /demo_lr_64.png"
165+ local fp_pte_path=" ${demo_dir} /swin2sr_x2_vgf_fp.pte"
166+ local int8_pte_path=" ${demo_dir} /swin2sr_x2_vgf_int8.pte"
167+ local fp_output_image=" ${runtime_dir} /demo_fp_128.png"
168+ local int8_output_image=" ${runtime_dir} /demo_int8_128.png"
169+ local checkpoint_id=" caidas/swin2SR-classical-sr-x2-64"
170+ local checkpoint_revision=" cee1c923c6a37361c6e5650b65dcf4be821e5d52"
171+ echo " ${FUNCNAME} : Work directory: ${work_root} ; existing artifacts will be reused if present"
172+
173+ mkdir -p " ${demo_dir} " " ${runtime_dir} "
174+
175+ setup_path_script=${et_root_dir} /examples/arm/arm-scratch/setup_path.sh
176+ source ${setup_path_script}
177+
178+ echo " ${FUNCNAME} : Installing example requirements"
179+ pip install -r " ${example_dir} /requirements.txt"
180+
181+ echo " ${FUNCNAME} : Preparing deterministic demo assets"
182+ python3 " ${example_dir} /model_export/prepare_demo_assets.py" \
183+ --output-dir " ${demo_dir} "
184+
185+ echo " ${FUNCNAME} : Building VKML executor_runner"
186+ " ${et_root_dir} /backends/arm/scripts/build_executor_runner_vkml.sh" \
187+ --output=" ${work_root} "
188+
189+ if [[ ! -f " ${runner_path} " ]]; then
190+ runner_path=$( find " ${work_root} " -name executor_runner -type f | head -n 1)
191+ fi
192+ [[ -f " ${runner_path} " ]] || {
193+ echo " ${FUNCNAME} : Missing executor_runner under ${work_root} "
194+ return 1
195+ }
196+
197+ echo " ${FUNCNAME} : Exporting FP Swin2SR model"
198+ python3 " ${example_dir} /model_export/export_super_resolution.py" \
199+ --model-name swin2sr \
200+ --checkpoint " ${checkpoint_id} " \
201+ --checkpoint-revision " ${checkpoint_revision} " \
202+ --input-height 64 \
203+ --input-width 64 \
204+ --quantization-mode none \
205+ --eval-lr-dir " ${demo_dir} /eval/lr" \
206+ --eval-hr-dir " ${demo_dir} /eval/hr" \
207+ --num-eval-samples 2 \
208+ --output-path " ${fp_pte_path} "
209+
210+ for artifact in \
211+ " ${fp_pte_path} " \
212+ " ${demo_dir} /swin2sr_x2_vgf_fp.json" \
213+ " ${demo_dir} /swin2sr_x2_vgf_fp_delegation.txt" \
214+ " ${demo_dir} /swin2sr_x2_vgf_fp_metrics.json" ; do
215+ [[ -f " ${artifact} " ]] || {
216+ echo " ${FUNCNAME} : Missing FP export artifact ${artifact} "
217+ return 1
218+ }
219+ done
220+
221+ echo " ${FUNCNAME} : Exporting INT8 Swin2SR model"
222+ python3 " ${example_dir} /model_export/export_super_resolution.py" \
223+ --model-name swin2sr \
224+ --checkpoint " ${checkpoint_id} " \
225+ --checkpoint-revision " ${checkpoint_revision} " \
226+ --input-height 64 \
227+ --input-width 64 \
228+ --quantization-mode int8 \
229+ --calibration-lr-dir " ${demo_dir} /calibration/lr" \
230+ --eval-lr-dir " ${demo_dir} /eval/lr" \
231+ --eval-hr-dir " ${demo_dir} /eval/hr" \
232+ --num-calibration-samples 4 \
233+ --num-eval-samples 2 \
234+ --output-path " ${int8_pte_path} "
235+
236+ for artifact in \
237+ " ${int8_pte_path} " \
238+ " ${demo_dir} /swin2sr_x2_vgf_int8.json" \
239+ " ${demo_dir} /swin2sr_x2_vgf_int8_delegation.txt" \
240+ " ${demo_dir} /swin2sr_x2_vgf_int8_metrics.json" ; do
241+ [[ -f " ${artifact} " ]] || {
242+ echo " ${FUNCNAME} : Missing INT8 export artifact ${artifact} "
243+ return 1
244+ }
245+ done
246+
247+ echo " ${FUNCNAME} : Running FP runtime smoke"
248+ python3 " ${example_dir} /runtime/run_super_resolution.py" \
249+ --model-path " ${fp_pte_path} " \
250+ --runner " ${runner_path} " \
251+ --input-image " ${input_image} " \
252+ --output-image " ${fp_output_image} " \
253+ --working-dir " ${runtime_dir} /fp_work"
254+
255+ [[ -f " ${fp_output_image} " ]] || {
256+ echo " ${FUNCNAME} : Missing FP runtime output ${fp_output_image} "
257+ return 1
258+ }
259+
260+ if [[ " $( uname -s) " == " Linux" ]]; then
261+ echo " ${FUNCNAME} : Running INT8 runtime smoke"
262+ python3 " ${example_dir} /runtime/run_super_resolution.py" \
263+ --model-path " ${int8_pte_path} " \
264+ --runner " ${runner_path} " \
265+ --input-image " ${input_image} " \
266+ --output-image " ${int8_output_image} " \
267+ --working-dir " ${runtime_dir} /int8_work"
268+
269+ [[ -f " ${int8_output_image} " ]] || {
270+ echo " ${FUNCNAME} : Missing INT8 runtime output ${int8_output_image} "
271+ return 1
272+ }
273+ else
274+ # TODO: MLETORCH-2105 remove this once the next ML SDK release supports
275+ # quantized VKML runtime validation on Darwin.
276+ echo " ${FUNCNAME} : Skipping INT8 runtime on $( uname -s) ; quantized VKML runtime validation is Linux-only"
277+ fi
278+
279+ echo " ${FUNCNAME} : PASS"
280+ }
281+
153282for suite in " ${TEST_SUITES[@]} " ; do
154283 " ${suite} "
155284done
0 commit comments