Skip to content

Commit 050196a

Browse files
[CI] UT logs post op and artifact
1 parent 7642026 commit 050196a

File tree

2 files changed

+116
-7
lines changed

2 files changed

+116
-7
lines changed

.github/scripts/ut_result_check.sh

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
ut_suite=${1:-op_regression} # op_regression / op_extended / op_ut / torch_xpu
2+
3+
if [[ ${ut_suite} == 'op_regression' || ${ut_suite} == 'op_regression_dev1' || ${ut_suite} == 'op_extended' ]]; then
4+
grep "^FAILED" ${ut_suite}_test.log | awk '{print $2}' > ./${ut_suite}_failed.log
5+
grep "PASSED" ${ut_suite}_test.log | awk '{print $1}' > ./${ut_suite}_passed.log
6+
num_failed=$(cat ./${ut_suite}_failed.log | wc -l)
7+
num_passed=$(cat ./${ut_suite}_passed.log | wc -l)
8+
echo -e "========================================================================="
9+
echo -e "Show Failed cases in ${ut_suite}"
10+
echo -e "========================================================================="
11+
cat ./${ut_suite}_failed.log
12+
if [[ $num_failed -gt 0 ]] && [[ $num_passed -lt 0 ]]; then
13+
echo -e "[ERROR] UT ${ut_suite} test Fail"
14+
exit 1
15+
else
16+
echo -e "[PASS] UT ${ut_suite} test Pass"
17+
fi
18+
fi
19+
if [[ ${ut_suite} == 'op_ut' ]]; then
20+
grep "^FAILED" op_ut_with_skip_test.log | awk '{print $2}' > ./${ut_suite}_with_skip_test_failed.log
21+
grep "^FAILED" op_ut_with_only_test.log | awk '{print $2}' > ./${ut_suite}_with_only_test_failed.log
22+
num_failed_with_skip=$(cat ./${ut_suite}_with_skip_test_failed.log | wc -l)
23+
num_failed_with_only=$(cat ./${ut_suite}_with_only_test_failed.log | wc -l)
24+
echo -e "========================================================================="
25+
echo -e "Show Failed cases in ${ut_suite} with skip"
26+
echo -e "========================================================================="
27+
cat ./${ut_suite}_with_skip_test_failed.log
28+
echo -e "========================================================================="
29+
echo -e "Show Failed cases in ${ut_suite} with only"
30+
echo -e "========================================================================="
31+
cat ./${ut_suite}_with_only_test_failed.log
32+
let num_failed=num_failed_with_skip+num_failed_with_only
33+
grep "PASSED" op_ut_with_skip_test.log | awk '{print $1}' > ./${ut_suite}_with_skip_test_passed.log
34+
grep "PASSED" op_ut_with_only_test.log | awk '{print $1}' > ./${ut_suite}_with_only_test_passed.log
35+
num_passed_with_skip=$(cat ./${ut_suite}_with_skip_test_passed.log | wc -l)
36+
num_passed_with_only=$(cat ./${ut_suite}_with_only_test_passed.log | wc -l)
37+
let num_passed=num_passed_with_skip+num_passed_with_only
38+
if [[ $num_failed -gt 0 ]] && [[ $num_passed -lt 0 ]]; then
39+
echo -e "[ERROR] UT ${ut_suite} test Fail"
40+
exit 1
41+
else
42+
echo -e "[PASS] UT ${ut_suite} test Pass"
43+
fi
44+
fi
45+
if [[ ${ut_suite} == 'torch_xpu' ]]; then
46+
echo "Pytorch XPU binary UT checking"
47+
cd ../../pytorch
48+
TEST_REPORTS_DIR=$(pwd)/test/test-reports
49+
for xpu_case in build/bin/*{xpu,sycl}*; do
50+
if [[ "$xpu_case" != *"*"* && "$xpu_case" != *.so && "$xpu_case" != *.a ]]; then
51+
case_name=$(basename "$xpu_case")
52+
cd ../ut_log/torch_xpu
53+
grep -E "FAILED" binary_ut_${ut_suite}_${case_name}_test.log | awk '{print $2}' > ./binary_ut_${ut_suite}_${case_name}_failed.log
54+
echo $(cat ./binary_ut_${ut_suite}_${case_name}_failed.log | wc -l) | tee -a ./binary_ut_${ut_suite}_failed_summary.log
55+
grep -E "PASSED|Pass" binary_ut_${ut_suite}_${case_name}_test.log | awk '{print $2}' > ./binary_ut_${ut_suite}_${case_name}_passed.log
56+
echo $(cat ./binary_ut_${ut_suite}_${case_name}_passed.log | wc -l) | tee -a ./binary_ut_${ut_suite}_passed_summary.log
57+
cd -
58+
fi
59+
done
60+
echo -e "========================================================================="
61+
echo -e "Show Failed cases in ${ut_suite}"
62+
echo -e "========================================================================="
63+
cd ../ut_log/torch_xpu
64+
cat ./binary_ut_${ut_suite}_${case_name}_failed.log
65+
num_failed_binary_ut=$(awk '{sum += $1};END {print sum}' binary_ut_${ut_suite}_failed_summary.log)
66+
num_passed_binary_ut=$(awk '{sum += $1};END {print sum}' binary_ut_${ut_suite}_passed_summary.log)
67+
let num_failed=num_failed_binary_ut
68+
if [[ $num_failed -gt 0 ]] && [[ $num_passed_binary_ut -lt 0 ]]; then
69+
echo -e "[ERROR] UT ${ut_suite} test Fail"
70+
exit 1
71+
else
72+
echo -e "[PASS] UT ${ut_suite} test Pass"
73+
fi
74+
fi

.github/workflows/_linux_ut.yml

+42-7
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,19 @@ jobs:
142142
if: contains(inputs.ut, 'op_regression') || github.event_name == 'schedule'
143143
run: |
144144
cd ${{ github.workspace }}
145+
mkdir -p ut_log/op_regression
145146
xpu-smi discovery
146147
source .github/scripts/env.sh ${{ inputs.pytorch }}
147148
source activate xpu_op_${ZE_AFFINITY_MASK}
148149
cd ${{ github.workspace }}
149150
cd test/regressions
150151
pip install pytest
151-
timeout 8000 pytest -v
152+
timeout 8000 pytest -v 2>&1 | tee ${{ github.workspace }}/ut_log/op_regression/op_regression_test.log
152153
- name: Run XPU OP Regressions test on device 1
153154
if: contains(inputs.ut, 'op_regression_dev1') || github.event_name == 'schedule'
154155
run: |
155156
cd ${{ github.workspace }}
157+
mkdir -p ut_log/op_regression_dev1
156158
xpu-smi discovery
157159
source .github/scripts/env.sh ${{ inputs.pytorch }}
158160
source activate xpu_op_${ZE_AFFINITY_MASK}
@@ -161,35 +163,41 @@ jobs:
161163
cd ${{ github.workspace }}
162164
cd test/regressions
163165
pip install pytest
164-
timeout 8000 pytest -v test_operation_on_device_1.py
166+
timeout 8000 pytest -v test_operation_on_device_1.py 2>&1 | tee ${{ github.workspace }}/ut_log/op_regression_dev1/op_regression_dev1_test.log
165167
export ZE_AFFINITY_MASK=${ZE_AFFINITY_MASK_OLD}
166168
- name: Run XPU OP Extended UT
167169
if: contains(inputs.ut, 'op_extended') || github.event_name == 'schedule'
168170
run: |
169171
source .github/scripts/env.sh ${{ inputs.pytorch }}
170172
source activate xpu_op_${ZE_AFFINITY_MASK}
171173
export PYTORCH_TEST_WITH_SLOW=1
174+
cd ${{ github.workspace }}
175+
mkdir -p ut_log/op_extended
172176
cd ../pytorch/third_party/torch-xpu-ops/test/xpu/extended/
173-
timeout 10000 python run_test_with_skip.py
177+
timeout 10000 python run_test_with_skip.py 2>&1 | tee ${{ github.workspace }}/ut_log/op_extended/op_extended_test.log
174178
- name: Run XPU OP UT
175179
if: contains(inputs.ut, 'op_ut') || github.event_name == 'schedule'
176180
run: |
177181
source .github/scripts/env.sh ${{ inputs.pytorch }}
178182
source activate xpu_op_${ZE_AFFINITY_MASK}
179183
export PYTORCH_ENABLE_XPU_FALLBACK=1
180184
export PYTORCH_TEST_WITH_SLOW=1
185+
cd ${{ github.workspace }}
186+
mkdir -p ut_log/op_ut
181187
cd ../pytorch/third_party/torch-xpu-ops/test/xpu
182-
timeout 10000 python run_test_with_skip.py
188+
timeout 10000 python run_test_with_skip.py 2>&1 | tee ${{ github.workspace }}/ut_log/op_ut/op_ut_with_skip_test.log
183189
# Cases run with a on-demand white list, since some suites are too
184190
# slow to go through all operators on CPU. So add cases on-demand
185191
# when XPU implementatoin is done.
186192
# test_foreach, test_decomp
187-
timeout 10000 python run_test_with_only.py
193+
timeout 10000 python run_test_with_only.py 2>&1 | tee ${{ github.workspace }}/ut_log/op_ut/op_ut_with_only_test.log
188194
- name: Run Torch XPU UT
189195
if: contains(inputs.ut, 'torch_xpu') || github.event_name == 'schedule'
190196
run: |
191197
source .github/scripts/env.sh ${{ inputs.pytorch }}
192198
source activate xpu_op_${ZE_AFFINITY_MASK}
199+
cd ${{ github.workspace }}
200+
mkdir -p ut_log/torch_xpu
193201
cd ../pytorch
194202
TEST_REPORTS_DIR=$(pwd)/test/test-reports
195203
rm -rf "$TEST_REPORTS_DIR" && mkdir -p "$TEST_REPORTS_DIR"
@@ -198,7 +206,7 @@ jobs:
198206
if [[ "$xpu_case" != *"*"* && "$xpu_case" != *.so && "$xpu_case" != *.a ]]; then
199207
case_name=$(basename "$xpu_case")
200208
echo "Testing ${case_name} ..."
201-
"$xpu_case" --gtest_output=xml:"$TEST_REPORTS_DIR"/"$case_name".xml
209+
"$xpu_case" --gtest_output=xml:"$TEST_REPORTS_DIR"/"$case_name".xml 2>&1 | tee ${{ github.workspace }}/ut_log/torch_xpu/binary_ut_torch_xpu_${case_name}_test.log
202210
fi
203211
done
204212
# Run Pytorch XPU python UT
@@ -219,4 +227,31 @@ jobs:
219227
if [ -f "test/test_xpu.py" ]; then
220228
test_cmd="${test_cmd} test_xpu.py"
221229
fi
222-
eval $test_cmd
230+
eval $test_cmd 2>&1 | tee ${{ github.workspace }}/ut_log/torch_xpu/Inductor_ut_torch_xpu_test.log
231+
- name: UT Test Results Check
232+
shell: bash
233+
run: |
234+
function contains() {
235+
contains_status="echo 'Start $2 ...'"
236+
{
237+
[[ $1 =~ (^|,)$2($|,) ]]
238+
} || {
239+
echo "[Warning] $2 is not suppotted type! Skipped!"
240+
contains_status="continue"
241+
}
242+
}
243+
set -xe
244+
for ut_suite in $(echo ${{ inputs.ut }} |sed 's/,/ /g')
245+
do
246+
contains "op_regression,op_regression_dev1,op_extended,op_ut,torch_xpu" $ut_suite
247+
$contains_status
248+
cd ${{ github.workspace }}/ut_log/${ut_suite}
249+
cp ${{ github.workspace }}/.github/scripts/ut_result_check.sh ./
250+
bash ut_result_check.sh ${ut_suite}
251+
done
252+
- name: Upload Inductor XPU UT Log
253+
if: always()
254+
uses: actions/upload-artifact@v4
255+
with:
256+
name: Inductor-XPU-UT-Data-${{ github.event.pull_request.number || github.sha }}-${{ inputs.abi }}
257+
path: ${{ github.workspace }}/ut_log

0 commit comments

Comments
 (0)