Skip to content

Commit c43be77

Browse files
committed
check-inductor-report.py
1 parent da4183b commit c43be77

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

.github/workflows/e2e-reusable.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,18 @@ jobs:
228228
if [[ "${{ inputs.only_one_model }}" ]]; then
229229
bash -e $GITHUB_WORKSPACE/scripts/inductor_xpu_test.sh ${{ inputs.suite }} ${{ inputs.dtype }} ${{ inputs.mode }} ${{ inputs.test_mode }} xpu 0 static 1 0 ${{ inputs.only_one_model }}
230230
elif [[ "${{ inputs.models }}" == "subset" ]]; then
231+
models_subset_file = "$GITHUB_WORKSPACE/.github/models/${{ inputs.test_mode }}/${{ inputs.suite }}.txt"
231232
while read model; do
232233
bash -e $GITHUB_WORKSPACE/scripts/inductor_xpu_test.sh ${{ inputs.suite }} ${{ inputs.dtype }} ${{ inputs.mode }} ${{ inputs.test_mode }} xpu 0 static 1 0 $model
233-
done < $GITHUB_WORKSPACE/.github/models/${{ inputs.test_mode }}/${{ inputs.suite }}.txt
234+
done < $models_subset_file
235+
if [[ "${{ inputs.test_all_subset_models }}" == true ]]
236+
python $GITHUB_WORKSPACE/scripts/check-inductor-logs.py --models-file="$models_subset_file" \
237+
--suite=${{ inputs.suite }} \
238+
--dtype=${{ inputs.dtype }} \
239+
--mode=${{ inputs.mode }} \
240+
--test_mode=${{ inputs.test_mode }} \
241+
--device=xpu
242+
fi
234243
else
235244
bash -e $GITHUB_WORKSPACE/scripts/inductor_xpu_test.sh ${{ inputs.suite }} ${{ inputs.dtype }} ${{ inputs.mode }} ${{ inputs.test_mode }} xpu 0 static 1 0
236245
fi

scripts/check-inductor-report.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import sys
2+
import argparse
3+
from pathlib import Path
4+
import csv
5+
6+
def check_report(suite, dtype, mode, test_mode, device, models_file):
7+
inductor_log_dir = Path('inductor_log') / suite / dtype
8+
inductor_report_filename = f"inductor_{suite}_{dtype}_{mode}_{device}_{test_mode}.csv"
9+
inductor_report_path = Path(inductor_log_dir / inductor_report_filename)
10+
11+
subset = []
12+
report = []
13+
exitcode = 0
14+
15+
with open(models_file) as f:
16+
subset = f.read().strip().split('\n')
17+
18+
with open(inductor_report_path) as f:
19+
reader = csv.reader(f)
20+
report_with_header = []
21+
for l in reader:
22+
report_with_header.append(l)
23+
for r in report_with_header[1:]:
24+
if r[0] == device:
25+
report.append(r)
26+
27+
test_list = [r[1] for r in report]
28+
29+
if test_mode == "performance":
30+
for m in subset:
31+
if m not in test_list:
32+
exitcode = 1
33+
print(f"Test is not found in report: {m}")
34+
35+
if test_mode == "accuracy":
36+
test_statuses = [r[3] for r in report]
37+
for m in subset:
38+
try:
39+
idx = test_list.index(m)
40+
except ValueError:
41+
exitcode = 1
42+
print(f"Test is NOT FOUND: {m}")
43+
continue
44+
if test_statuses[idx] != "pass":
45+
exitcode = 1
46+
print(f"Test is NOT PASSED: {m}")
47+
return exitcode
48+
49+
def main():
50+
argparser = argparse.ArgumentParser()
51+
argparser.add_argument('--suite', required=True)
52+
argparser.add_argument('--dtype', required=True)
53+
argparser.add_argument('--mode', required=True, choices=("training", "inference"))
54+
argparser.add_argument('--test_mode', required=True, choices=("performance", "accuracy"))
55+
argparser.add_argument('--device', help="i.e. xpu", required=True)
56+
argparser.add_argument('--models-file', help="Subset of models list", required=True)
57+
args = argparser.parse_args()
58+
exitcode = check_report(args.suite, args.dtype, args.mode, args.test_mode, args.device, args.models_file)
59+
print(f"Report check result: {'SUCCESS' if exitcode == 0 else 'FAIL'}")
60+
exit(exitcode)
61+
62+
63+
if __name__ == "__main__":
64+
main()

0 commit comments

Comments
 (0)