Skip to content
Closed
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
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
12 changes: 10 additions & 2 deletions scripts/run_android_emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ 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 logcat -c
adb shell am instrument -w -r com.example.executorchllamademo.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

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 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
Loading