Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ jobs:
# https://github.com/ReactiveCircus/android-emulator-runner. The max number
# of cores we can set is 6, any higher number will be reduced to 6.
cores: 6
ram-size: 12288M
ram-size: 16384M
heap-size: 12288M
force-avd-creation: false
disable-animations: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
Expand Down
13 changes: 7 additions & 6 deletions extension/android/executorch_android/android_test_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then
fi
which "${PYTHON_EXECUTABLE}"

BASEDIR=$(dirname "$0")
BASEDIR=$(dirname "$(realpath $0)")
cp "${BASEDIR}/../../../extension/module/test/resources/add.pte" "${BASEDIR}/src/androidTest/resources"

pushd "${BASEDIR}/../../../"
curl -Ls "https://huggingface.co/karpathy/tinyllamas/resolve/main/stories110M.pt" --output stories110M.pt
curl -Ls "https://raw.githubusercontent.com/karpathy/llama2.c/master/tokenizer.model" --output tokenizer.model
curl -C - -Ls "https://huggingface.co/karpathy/tinyllamas/resolve/main/stories110M.pt" --output stories110M.pt
curl -C - -Ls "https://raw.githubusercontent.com/karpathy/llama2.c/master/tokenizer.model" --output tokenizer.model
# Create params.json file
touch params.json
echo '{"dim": 768, "multiple_of": 32, "n_heads": 12, "n_layers": 12, "norm_eps": 1e-05, "vocab_size": 32000}' > params.json
python -m examples.models.llama.export_llama -c stories110M.pt -p params.json -X -kv --model=stories110m
python -m examples.models.llama.export_llama -c stories110M.pt -p params.json -d fp16 -n stories110m_h.pte -kv
python -m pytorch_tokenizers.tools.llama2c.convert -t tokenizer.model -o tokenizer.bin

cp *.pte "${BASEDIR}/src/androidTest/resources/stories.pte"
cp tokenizer.model "${BASEDIR}/src/androidTest/resources/tokenizer.bin"
cp stories110m_h.pte "${BASEDIR}/src/androidTest/resources/stories.pte"
cp tokenizer.bin "${BASEDIR}/src/androidTest/resources/tokenizer.bin"
popd
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public void testGenerate() throws IOException, URISyntaxException{

@Test
public void testGenerateAndStop() throws IOException, URISyntaxException{
int seqLen = 32;
mModule.generate(TEST_PROMPT, SEQ_LEN, new LlmCallback() {
@Override
public void onResult(String result) {
Expand Down
19 changes: 8 additions & 11 deletions scripts/run_android_emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ $ADB_PATH wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; d
echo "List all running emulators"
$ADB_PATH devices

adb uninstall com.example.executorchllamademo || true
adb uninstall com.example.executorchllamademo.test || true
adb install -t app-debug.apk
adb install -t app-debug-androidTest.apk

adb shell mkdir -p /data/local/tmp/llama
adb push model.pte /data/local/tmp/llama
adb push tokenizer.bin /data/local/tmp/llama
adb shell am instrument -w -r com.example.executorchllamademo.test/androidx.test.runner.AndroidJUnitRunner

adb uninstall org.pytorch.executorch.test || true
adb install -t android-test-debug-androidTest.apk

adb shell am instrument -w -r org.pytorch.executorch.test/androidx.test.runner.AndroidJUnitRunner
adb logcat -c
adb shell am instrument -w -r -e class org.pytorch.executorch.ModuleInstrumentationTest \
org.pytorch.executorch.test/androidx.test.runner.AndroidJUnitRunner >result.txt 2>&1
adb logcat -d > logcat.txt
cat logcat.txt
grep -q FAILURES result.txt && cat result.txt
grep -q FAILURES result.txt && exit -1
exit 0
Loading