-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathrun_matmul_test.sh
executable file
·802 lines (686 loc) · 22.6 KB
/
run_matmul_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
#!/bin/bash
#
# Copyright 2024 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Manual IREE matmul test script.
#
# This pulls code from
# * https://github.com/openxla/iree/blob/main/build_tools/cmake/iree_e2e_matmul_test.cmake
# * https://github.com/openxla/iree/blob/main/tests/e2e/matmul/CMakeLists.txt
#
# Usage:
# 1. Build IREE (or install packages). You'll need `iree-compile` to include
# support for the compiler target backend you wish to test and
# `iree-e2e-matmul-test` to include support for the runtime HAL
# driver/device you wish to test.
# 2. Update the paths in this script or specify them via environment variables
# 3. Run: `./run_matmul_tests.sh <output_dir_path> <iree_install_path> [<peano_install_path>] [<xrt_path>] [<vitis_path>] [do_signing]`
# The directories above in square brackets are optional, the first 2 directories are required.
set -euo pipefail
if [ "$#" -lt 2 ] || [ "$#" -gt 5 ]; then
# The expected parameters are
# 1) <output-dir> (required)
# 2) <iree-install-dir> (required)
# 3) <peano-install-dir> (optional)
# 4) <vitis-install-dir> (optional)
# 5) <xrt-dir> (optional)
echo -e "Illegal number of parameters: $#, expected 2-5 parameters." \
"\n The parameters are as follows:" \
"\n 1) <output-dir> (required)" \
"\n 2) <iree-install-dir> (required)" \
"\n 3) <peano-install-dir> (optional)" \
"\n 4) <vitis-install-dir> (optional)" \
"\n 5) <xrt-dir> (optional)" \
"\n Example, dependent on environment variables:" \
"\n ./run_matmul_test.sh " \
"results_dir_tmp \$IREE_INSTALL_DIR " \
"\$PEANO_INSTALL_DIR /opt/xilinx/xrt \$VITIS_INSTALL_PATH"
exit 1
fi
OUTPUT_DIR=`realpath "$1"`
if [ -d "${OUTPUT_DIR}" ]; then
rm -rf "${OUTPUT_DIR}";
fi
mkdir -p ${OUTPUT_DIR}
if [ ! -d "${OUTPUT_DIR}" ]; then
echo "Failed to locate or construct OUTPUT_DIR '${OUTPUT_DIR}'."
exit 1
fi
IREE_INSTALL_DIR=`realpath "$2"`
if [ ! -d "${IREE_INSTALL_DIR}" ]; then
echo "IREE_INSTALL_DIR must be a directory, '${IREE_INSTALL_DIR}' is not."
exit 1
fi
# Search for iree-compile and iree-e2e-matmul-test in the user provided directory.
IREE_COMPILE_EXE=""
TEST_RUNNER=""
for dir in "${IREE_INSTALL_DIR}" "${IREE_INSTALL_DIR}/bin" "${IREE_INSTALL_DIR}/tools" "${IREE_INSTALL_DIR}/tools/testing/e2e"; do
echo "Looking in $dir"
if [ -f "${dir}/iree-compile" ]; then
IREE_COMPILE_EXE="${dir}/iree-compile"
fi
if [ -f "${dir}/iree-compile.exe" ]; then
IREE_COMPILE_EXE="${dir}/iree-compile.exe"
fi
if [ -f "${dir}/iree-e2e-matmul-test" ]; then
TEST_RUNNER="${dir}/iree-e2e-matmul-test"
fi
if [ -f "${dir}/iree-e2e-matmul-test.exe" ]; then
TEST_RUNNER="${dir}/iree-e2e-matmul-test.exe"
fi
done
if [ -z "${IREE_COMPILE_EXE}" ]; then
echo "No 'iree-compile' found in any of the following directories: " \
"'${IREE_INSTALL_DIR}', '${IREE_INSTALL_DIR}/bin', '${IREE_INSTALL_DIR}/tools'."
exit 1
fi
if [ -z "${TEST_RUNNER}" ]; then
echo "No 'iree-e2e-matmul-test' found in any of the following directories: " \
"'${IREE_INSTALL_DIR}', '${IREE_INSTALL_DIR}/bin', '${IREE_INSTALL_DIR}/tools'."
exit 1
fi
# Parameter 3) <peano-install-dir>
if [ -z "${3-}" ]; then
PEANO=/opt/llvm-aie
else
PEANO=`realpath "$3"`
fi
if [ ! -d "${PEANO}" ]; then
echo "No directory '${PEANO}' (argument 3) found."
exit 1
fi
# Parameter 4) <vitis-install-dir>
if [ -z "${4-}" ]; then
VITIS=/opt/Xilinx/Vitis/2024.2
else
VITIS=`realpath "$4"`
fi
# Parameter 5) <xrt-dir>
if [ -z "${5-}" ]; then
XRT_DIR=/opt/xilinx/xrt
else
XRT_DIR=`realpath "$5"`
fi
if [ -f "$XRT_DIR/setup.sh" ]; then
source $XRT_DIR/setup.sh
fi
THIS_DIR="$(cd $(dirname $0) && pwd)"
ROOT_DIR="$(cd $THIS_DIR/../.. && pwd)"
GENERATOR="${THIS_DIR}/generate_e2e_matmul_tests.py"
# Verify that generator exists
if [ ! -f "${GENERATOR}" ]; then
echo "Generator script '${GENERATOR}' not found."
exit 1
fi
IREE_PYTHON3_EXECUTABLE="${IREE_PYTHON3_EXECUTABLE:-python}"
if [ -z "$IREE_PYTHON3_EXECUTABLE" ]; then
echo "IREE_PYTHON3_EXECUTABLE is not set."
exit 1
else
echo "Python version: $("${IREE_PYTHON3_EXECUTABLE}" --version)"
fi
GITHUB_ACTIONS="${GITHUB_ACTIONS:-false}"
# Circumvent xclbin security (no longer needed as of April 2024 XDNA driver)
export XRT_HACK_UNSECURE_LOADING_XCLBIN=1
cd ${OUTPUT_DIR}
export MATMUL_TESTS_RUN=0
export MATMUL_TESTS_FAILS=0
DEVICE_HAL="${DEVICE_HAL:-xrt-lite}"
###############################################################################
# Define helper function #
###############################################################################
# This should be Python, CMake, or ... just... not Bash.
# Reference for named args: https://tecadmin.net/create-bash-functions-with-arguments/
function run_matmul_test() {
# Options without defaults
# ========================
local lhs_rhs_type=""
local acc_type=""
local m=""
local n=""
local k=""
# Options with defaults
# =====================
local lower_to_aie_pipeline="air"
# name_prefix: A prefix for the name of the test. The full test name will be
# extended with m,n,k if they are unique.
local name_prefix="noprefix"
local target_backend="amd-aie"
local target_device="npu1_4col"
local peano_install_path="${PEANO}"
local amd_aie_install_path="${IREE_INSTALL_DIR}"
local vitis_path="${VITIS}"
local use_chess="false"
local tile_pipeline="pad-pack"
# By default, the m,n,k provided are used, and there are no dynamic tensor
# dimensions.
local dynamicity="static"
local accumulate="false"
local enable_packet_flow="false";
# The default is to not expect a compilation failure.
local expect_compile_failure="0"
local do_transpose_rhs="0"
# The maximum number of elements to check for correctness.
# See https://github.com/iree-org/iree/blob/tools/testing/e2e/test_utils.c#L40-L47
local max_elements_to_check="20000"
# The default is to not use microkernels.
local use_ukernel="0"
# After compilation, the test with be run 'num_repeat_runs' times. This option (when
# set greater than 1) is useful for shapes which might be 'flakey' and fail
# intermittently. It is also useful if a test is know to fail at runtime but
# should still be checked to compile (set num_repeat_runs=0 in this case).
local num_repeat_runs="1"
# Run the test 'num_corruption_repeat_runs' times without an NPU reset in
# between. This can be used to check for corruption, i.e. the AIE might be
# left in a bad state in between runs. Additionally, this increases the speed
# of the repeated test
local num_corruption_repeat_runs="1"
while [ "$#" -gt 0 ]; do
case "$1" in
--lower_to_aie_pipeline)
lower_to_aie_pipeline="$2"
shift 2
;;
--num_repeat_runs)
num_repeat_runs="$2"
shift 2
;;
--num_corruption_repeat_runs)
num_corruption_repeat_runs="$2"
shift 2
;;
--max_elements_to_check)
max_elements_to_check="$2"
shift 2
;;
--do_transpose_rhs)
do_transpose_rhs="$2"
shift 2
;;
--enable_packet_flow)
enable_packet_flow="$2"
shift 2
;;
--expect_compile_failure)
expect_compile_failure="$2"
shift 2
;;
--name_prefix)
name_prefix="$2"
shift 2
;;
--lhs_rhs_type)
lhs_rhs_type="$2"
shift 2
;;
--acc_type)
acc_type="$2"
shift 2
;;
--use_ukernel)
use_ukernel="$2"
shift 2
;;
--target_device)
target_device="$2"
shift 2
;;
--target_backend)
target_backend="$2"
shift 2
;;
--peano_install_path)
peano_install_path="$2"
shift 2
;;
--amd_aie_install_path)
amd_aie_install_path="$2"
shift 2
;;
--use_chess)
use_chess="$2"
shift 2
;;
--vitis_path)
vitis_path="$2"
shift 2
;;
--tile_pipeline)
tile_pipeline="$2"
shift 2
;;
--dynamicity)
dynamicity="$2"
shift 2
;;
--accumulate)
accumulate="$2"
shift 2
;;
--m)
m="$2"
shift 2
;;
--n)
n="$2"
shift 2
;;
--k)
k="$2"
shift 2
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
# Record the current time in milliseconds. Record the time at certain
# checkpoints, and print statistics summarizing how much time is spent in
# compilation and execution.
start_time=$(date +%s%3N)
# Generate a name for the test based on name_prefix and the matmul dimensions,
# but only if the test has 1 matmul in it. If there are multiple matmuls,
# then use name_prefix as is. This is to prevent long names when there are
# many matmuls in a test.
#
# Generate a name, assuming m, n, k are just single integers:
name="mm_${name_prefix}_${lhs_rhs_type}_${acc_type}_m${m}_n${n}_k${k}"
# Disable exit on failure:
set +e
# Check if the name contains a ',' or ' ', which indicates multiple matmuls.
nameContainsComma=$(echo $name | grep -c ",")
nameContainsSpace=$(echo $name | grep -c " ")
if [ $nameContainsComma -ne 0 ] || [ $nameContainsSpace -ne 0 ]; then
name="${name_prefix}"
fi
# Confirm that the name does not contain a comma or space, now that just
# the name_prefix is used.
nameContainsComma=$(echo $name | grep -c ",")
nameContainsSpace=$(echo $name | grep -c " ")
if [ $nameContainsComma -ne 0 ] || [ $nameContainsSpace -ne 0 ]; then
echo "Name contains a comma or space: not allowed."
exit 1
fi
export MATMUL_TESTS_RUN=$(( $MATMUL_TESTS_RUN+1 ))
# Re-enable exit on failure:
set -e
matmul_ir="${OUTPUT_DIR}/${name}_ir.mlir"
calls_ir="${OUTPUT_DIR}/${name}_calls.mlir"
matmul_vmfb="${OUTPUT_DIR}/${name}.vmfb"
calls_vmfb="${OUTPUT_DIR}/${name}_calls.vmfb"
generation_flags="--lhs_rhs_type=${lhs_rhs_type} \
--acc_type=${acc_type} \
--m=${m} \
--n=${n} \
--k=${k} \
--dynamicity=${dynamicity} \
--accumulate=${accumulate} \
--output_matmuls_mlir=${matmul_ir} \
--output_calls_mlir=${calls_ir}"
if [ $do_transpose_rhs -ne 0 ]; then
generation_flags="${generation_flags} --transpose_rhs"
fi
echo "**** Generating .mlir file containing matmul function(s) ****"
${IREE_PYTHON3_EXECUTABLE} ${GENERATOR} ${generation_flags}
generated_time=$(date +%s%3N)
## Disable exit on failure:
set +e
compilation_flags="--iree-hal-target-backends=${target_backend} \
--iree-amdaie-target-device=${target_device} \
--iree-amdaie-lower-to-aie-pipeline=${lower_to_aie_pipeline} \
--iree-amdaie-tile-pipeline=${tile_pipeline} \
--iree-amd-aie-peano-install-dir=${peano_install_path} \
--iree-amd-aie-install-dir=${amd_aie_install_path} \
--iree-amd-aie-vitis-install-dir=${vitis_path} \
--iree-amd-aie-enable-chess=${use_chess} \
--iree-amdaie-enable-packet-flow=${enable_packet_flow} \
--iree-hal-dump-executable-files-to=$PWD \
--iree-amdaie-device-hal=${DEVICE_HAL} \
--iree-hal-memoization=false \
--iree-hal-indirect-command-buffers=false \
--mlir-elide-resource-strings-if-larger=10 \
--iree-amd-aie-show-invoked-commands"
if [ $use_ukernel -ne 0 ]; then
compilation_flags="${compilation_flags} \
--iree-amdaie-enable-ukernels=all"
fi
set +e
echo "**** Generating matmul .vmfb file for ${name} ****"
${IREE_COMPILE_EXE} "${matmul_ir}" \
${compilation_flags} --compile-to=vm -o "${matmul_vmfb}.vm"
${IREE_COMPILE_EXE} "${matmul_ir}" \
${compilation_flags} -o "${matmul_vmfb}"
compileResult=$?
# Handle cases other than when compilation is expected to, and does, succeed:
if [ $expect_compile_failure -ne 0 ]; then
if [ $compileResult -ne 0 ]; then
echo "Expected compilation failure, got compilation failure."
return 0
else
echo "Expected compilation failure, got compilation success."
export MATMUL_TESTS_FAILS=$(( $MATMUL_TESTS_FAILS+1 ))
return
fi
else
if [ $compileResult -ne 0 ]; then
echo "Expected compilation success, got compilation failure."
export MATMUL_TESTS_FAILS=$(( $MATMUL_TESTS_FAILS+1 ))
return
fi
fi
# Renable exit on failure:
echo "**** Generating calls .vmfb file for ${name} ****"
${IREE_COMPILE_EXE} "${calls_ir}" \
--iree-hal-target-backends=${target_backend} \
-o "${calls_vmfb}"
return_status=$?
if [ $return_status -ne 0 ]; then
echo "'${name}' matmul compile failed!"
export MATMUL_TESTS_FAILS=$(( $MATMUL_TESTS_FAILS+1 ))
return
fi
compiled_time=$(date +%s%3N)
echo "**** Running '${name}' matmul tests ****"
COMMAND="${TEST_RUNNER} \
--module=${matmul_vmfb} \
--module=${calls_vmfb} \
--device=${DEVICE_HAL} \
--max_elements_to_check=${max_elements_to_check}"
if [ -n "${XRT_LITE_N_CORE_ROWS:-}" ]; then
COMMAND="${COMMAND} --xrt_lite_n_core_rows=$XRT_LITE_N_CORE_ROWS"
fi
if [ -n "${XRT_LITE_N_CORE_COLS:-}" ]; then
COMMAND="${COMMAND} --xrt_lite_n_core_cols=$XRT_LITE_N_CORE_COLS"
fi
total_num_runs=$(( num_repeat_runs * num_corruption_repeat_runs))
echo "**** Running '${name}' matmul test ${total_num_runs} times (command ${COMMAND}) ****"
for i in $(seq 1 $num_repeat_runs); do
# Only reset NPU in CI to facilitate easier local testing without sudo access.
if [[ "$OSTYPE" == "linux-gnu"* ]] && [ "${GITHUB_ACTIONS}" = true ]; then
echo "Reset NPU"
bash $THIS_DIR/reset_npu.sh
fi
for j in $(seq 1 $num_corruption_repeat_runs); do
run_number=$(( (i - 1) * num_corruption_repeat_runs + j))
echo "Run number ${run_number} / ${total_num_runs}"
eval "${COMMAND}"
return_status=$?
if [ $return_status -ne 0 ]; then
echo "'${name}' matmul test failed!"
export MATMUL_TESTS_FAILS=$(( $MATMUL_TESTS_FAILS+1 ))
fi
done
done
set -e
end_time=$(date +%s%3N)
#print the time spent in each stage:
echo "Time spent in generation: $((generated_time - start_time)) [ms]"
echo "Time spent in compilation: $((compiled_time - generated_time)) [ms]"
echo "Time spent in execution and verification: $((end_time - compiled_time)) [ms]"
}
# Helper function to run the same matmul test on an array of shapes with format 'MxKxN'.
function run_matmul_test_on_shapes() {
shapes=()
while [[ $1 != --* ]]
do
shapes+=($1)
shift
done
for shape in "${shapes[@]}"
do
IFS="x" read -r -a elems <<< "${shape}"
run_matmul_test \
"$@" \
--m "${elems[0]}" --k "${elems[1]}" --n "${elems[2]}"
done
}
########################################################
# Run tests #
########################################################
# Notes:
# 1. Be conservative in adding more shapes, as it can increase both the
# build and execution latency of tests. The build latency is nearly the
# same for all shapes, while execution latency grows cubicly i.e.
# linearly with m*k*n.
# Example of a run without any defaults arguments.
run_matmul_test \
--name_prefix "test1" \
--lhs_rhs_type "bf16" \
--acc_type "f32" \
--target_backend "amd-aie" \
--target_device "npu1_4col" \
--peano_install_path "${PEANO}" \
--amd_aie_install_path "${IREE_INSTALL_DIR}" \
--vitis_path "${VITIS}" \
--lower_to_aie_pipeline "air" \
--tile_pipeline "pad-pack" \
--m "64" \
--n "64" \
--k "64" \
--dynamicity "static" \
--accumulate "false" \
--expect_compile_failure "0" \
--do_transpose_rhs "0" \
--max_elements_to_check "0" \
--use_ukernel "0" \
--num_repeat_runs "2"
###################################################################
# MLIR-AIR Matmul tests
###################################################################
if [ -d "$VITIS" ]; then
run_matmul_test \
--name_prefix "ukern" \
--lower_to_aie_pipeline "air" \
--tile_pipeline "pad-pack" \
--lhs_rhs_type "bf16" \
--acc_type "f32" \
--m "256" --k "256" --n "256" \
--use_ukernel "1"
fi
# Example of a run with a group of 2+ matmuls. Currently this test is passed
# the flag '--num_repeat_runs 0" as there is currently an issue with the runtime if
# multiple matmuls are run in the same test. TODO(newling/nmeshram): Document
# this issue.
run_matmul_test \
--name_prefix "multiple_matmuls" \
--lower_to_aie_pipeline "air" \
--tile_pipeline "pad-pack" \
--lhs_rhs_type "i32" \
--acc_type "i32" \
--m "512,8,16" \
--n "512,32,16" \
--k "256,16,8" \
--num_repeat_runs "0"
run_matmul_test \
--name_prefix "transpose_i8_i32" \
--lower_to_aie_pipeline "air" \
--tile_pipeline "pad-pack" \
--lhs_rhs_type "i8" \
--acc_type "i32" \
--m "16" --n "32" --k "64" \
--do_transpose_rhs "1"
run_matmul_test \
--name_prefix "packPeel_i32" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "i32" \
--acc_type "i32" \
--m "64" --n "64" --k "128"
run_matmul_test \
--name_prefix "packPeel_bf16" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "bf16" \
--acc_type "f32" \
--m "512" --n "512" --k "512"
run_matmul_test \
--name_prefix "packPeel_t_bf16" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "bf16" \
--acc_type "f32" \
--m "128" --n "256" --k "512" \
--do_transpose_rhs "1"
###################################################################
# ObjectFifo Matmul tests
###################################################################
# Run repeatedly to check for non-deterministic hangs and numerical
# issues.
repeat_shapes=(
'32x32x32'
)
run_matmul_test_on_shapes ${repeat_shapes[@]} \
--name_prefix "small" \
--lower_to_aie_pipeline "objectFifo" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "i32" \
--acc_type "i32" \
--num_corruption_repeat_runs "1000"
i32_shapes_small=(
'32x32x32'
'64x32x128'
'128x32x64'
'128x32x64'
'128x32x128'
'256x32x256'
'32x64x32'
'64x64x64'
'128x256x128'
)
run_matmul_test_on_shapes ${i32_shapes_small[@]} \
--name_prefix "small_i32" \
--lower_to_aie_pipeline "objectFifo" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "i32" \
--acc_type "i32" \
--num_repeat_runs "10"
run_matmul_test_on_shapes ${i32_shapes_small[@]} \
--name_prefix "small" \
--lower_to_aie_pipeline "objectFifo" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "i32" \
--acc_type "i32" \
--num_corruption_repeat_runs "10" \
--enable_packet_flow "true"
i32_shapes_medium=(
'1024x1024x1024'
)
# TODO(jornt): re-enable `1536x2048x1536`
#if [ "$OSTYPE" != "msys" ]; then
# i32_shapes_medium+=('1536x2048x1536')
#fi
run_matmul_test_on_shapes ${i32_shapes_medium[@]} \
--name_prefix "medium_i32" \
--lower_to_aie_pipeline "objectFifo" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "i32" \
--acc_type "i32" \
--num_repeat_runs "2"
# bf16 Matmul tests.
bf16_i8_shapes_small=(
'64x64x64'
'128x256x128'
)
bf16_i8_shapes_medium=(
'512x512x512'
'1024x1024x1024'
'1536x2048x1536'
'4096x2048x4096'
)
bf16_ukernel_shapes_small=(
'64x64x64'
'256x256x256'
)
bf16_ukernel_shapes_medium=(
'128x512x512'
'512x4096x2048'
)
run_matmul_test_on_shapes ${bf16_i8_shapes_small[@]} \
--name_prefix "small_bf16" \
--lower_to_aie_pipeline "objectFifo" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "bf16" \
--acc_type "f32" \
--num_repeat_runs "2"
run_matmul_test_on_shapes ${bf16_i8_shapes_medium[@]} \
--name_prefix "medium_bf16" \
--lower_to_aie_pipeline "objectFifo" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "bf16" \
--acc_type "f32" \
--num_repeat_runs "2"
# i8 Matmul tests.
run_matmul_test_on_shapes ${bf16_i8_shapes_small[@]} \
--name_prefix "small_i8" \
--lower_to_aie_pipeline "objectFifo" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "i8" \
--acc_type "i32" \
--num_repeat_runs "2"
run_matmul_test_on_shapes ${bf16_i8_shapes_medium[@]} \
--name_prefix "medium_i8" \
--lower_to_aie_pipeline "objectFifo" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "i8" \
--acc_type "i32" \
--num_repeat_runs "2"
if [ -d "$VITIS" ]; then
run_matmul_test_on_shapes ${bf16_ukernel_shapes_small[@]} \
--name_prefix "small_ukern" \
--lower_to_aie_pipeline "objectFifo" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "bf16" \
--acc_type "f32" \
--num_repeat_runs "2" \
--use_ukernel "1"
run_matmul_test_on_shapes ${bf16_ukernel_shapes_medium[@]} \
--name_prefix "medium_ukern" \
--lower_to_aie_pipeline "objectFifo" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "bf16" \
--acc_type "f32" \
--num_repeat_runs "2" \
--use_ukernel "1"
fi
###################################################################
# Chess tests
###################################################################
if [ -d "$VITIS" ]; then
run_matmul_test \
--name_prefix "chess_i32_matmul" \
--lhs_rhs_type "i32" \
--acc_type "i32" \
--m "32" \
--n "32" \
--k "32" \
--use_chess "1" \
--num_repeat_runs "10"
run_matmul_test \
--name_prefix "chess_bf16_ukernel" \
--lhs_rhs_type "bf16" \
--acc_type "f32" \
--m "64" \
--n "64" \
--k "64" \
--use_chess "1" \
--num_repeat_runs "10" \
--use_ukernel "1"
run_matmul_test \
--name_prefix "chess_i32_matmul_multi_core" \
--lower_to_aie_pipeline "objectFifo" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "i32" \
--acc_type "i32" \
--m "32" \
--n "32" \
--k "32" \
--use_chess "1" \
--num_repeat_runs "10"
fi
echo "\n\n"
echo "$MATMUL_TESTS_RUN matmul tests run!"
if [ $MATMUL_TESTS_FAILS -ne 0 ]; then
echo "$MATMUL_TESTS_FAILS matmul tests failed! Scroll up and look for the 🦄 and 🐞..."
exit 1
fi