xref: /aosp_15_r20/external/executorch/examples/mediatek/shell_scripts/export_llama.sh (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1model=${1:-'llama3.2-3b'}
2chunks=${2:-4}
3tok=${3:-128}
4cache=${4:-512}
5cal=${5:-None}
6pres=${6:-A16W4}
7
8if [ $model = "llama3.2-3b" ]
9then
10	config_path=Llama-3.2-3B-Instruct/config.json
11	pref="--preformatter aot_utils/llm_utils/preformatter_templates/llama3.json"
12elif [ $model = "llama3.2-1b" ]
13then
14	config_path=Llama-3.2-1B-Instruct/config.json
15	pref="--preformatter aot_utils/llm_utils/preformatter_templates/llama3.json"
16elif [ $model = "llama3" ]
17then
18	config_path=llama3-8B-instruct/config.json
19	pref="--preformatter aot_utils/llm_utils/preformatter_templates/llama3.json"
20elif [ $model = "llama2" ]
21then
22	config_path=llama2-7B-chat/config.json
23	pref="--preformatter aot_utils/llm_utils/preformatter_templates/llama2_short.json"
24fi
25
26if [ $cal = "None" ]
27then
28	data=""
29else
30	data="-d aot_utils/llm_utils/prompts/${cal}"
31fi
32
33echo "Model: $model"
34echo "Config Path: $config_path"
35echo "Num Chunks: $chunks"
36echo "Num Tokens: $tok"
37echo "Cache Size: $cache"
38echo "Precision: $pres"
39echo "Calibration Dataset: $cal"
40echo "Preformatter: $pref"
41
42python3 model_export_scripts/llama.py \
43    models/llm_models/weights/${config_path} \
44    -p $pres \
45    --num_chunks $chunks \
46	${data} \
47	${pref} \
48    -shapes ${tok}t${cache}c 1t${cache}c
49