blob: 9a18e1b753812b1f7f3fb944fafd3282ba5e921d (
plain)
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
|
#!/bin/bash
#####################################################################
# SUMMARY: Decode fbgemm + intgemm 8bit for the output layer
# TAGS: cpu student shortlist intgemm fbgemm
#####################################################################
# Exit on error
set -e
# Skip if requirements are not met
if [ ! $MRT_MARIAN_USE_FBGEMM ]; then
echo "Marian is not compiled with FBGEMM" 1>&2
exit 100
elif ! grep -q "avx2" /proc/cpuinfo; then
echo "Your CPU does not support AVX2, which is required" 1>&2
exit 100
fi
# Outputs differ on CPUs supporting AVX AVX2 or AVX512
suffix=avx2
if grep -q "avx512_vnni" /proc/cpuinfo; then
suffix=avx512_vnni
elif grep -q "avx512" /proc/cpuinfo; then
suffix=avx512
fi
prefix=fbgemm_intgemm_8bit
# Remove previous outputs
rm -f $prefix.out $prefix.$suffix.bin
# Pack the model
$MRT_MARIAN/marian-conv -f $MRT_MODELS/student-eten/model.npz -t $prefix.$suffix.bin --gemm-type packed8$suffix
test -s $prefix.$suffix.bin
# Run test
$MRT_MARIAN/marian-decoder \
-m $prefix.$suffix.bin -v $MRT_MODELS/student-eten/{vocab.spm,vocab.spm} \
-i newstest2018.src -o $prefix.out \
-b 1 --mini-batch 32 --maxi-batch 100 --maxi-batch-sort src -w 128 \
--shortlist $MRT_MODELS/student-eten/lex.s2t 50 50 --cpu-threads 1 --int8 \
--quiet-translation
# Print current and expected BLEU for debugging
python3 $MRT_TOOLS/sacrebleu/sacrebleu.py newstest2018.ref < $prefix.out | tee $prefix.out.bleu
cat $prefix.$suffix.expected.bleu
# Compare with the expected output
$MRT_TOOLS/diff.sh $prefix.out $prefix.$suffix.expected > $prefix.diff
# Exit with success code
exit 0
|