Skip to content

Commit e0f580a

Browse files
Riandypytorchbot
authored andcommitted
Add model files support for android tokenizer (#5727)
Summary: Pull Request resolved: #5727 Add model files support for android tokenizer. Previously we only support .bin files, but since the runner also supports .model now, updating the app side logic to allow .model tokenizer files. Reviewed By: larryliu0820 Differential Revision: D63491811 fbshipit-source-id: b01ca836798794cbd0b0b377aa096a5c61a8f715 (cherry picked from commit fcdfe06)
1 parent 9698393 commit e0f580a

File tree

1 file changed

+4
-2
lines changed
  • examples/demo-apps/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo

1 file changed

+4
-2
lines changed

examples/demo-apps/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/SettingsActivity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ private static String[] listLocalFile(String path, String suffix) {
315315
}
316316
return result;
317317
}
318-
return null;
318+
return new String[] {};
319319
}
320320

321321
private void setupModelTypeSelectorDialog() {
@@ -343,8 +343,10 @@ private void setupModelTypeSelectorDialog() {
343343

344344
private void setupTokenizerSelectorDialog() {
345345
String[] binFiles = listLocalFile("/data/local/tmp/llama/", ".bin");
346-
String[] tokenizerFiles = new String[binFiles.length];
346+
String[] modelFiles = listLocalFile("/data/local/tmp/llama/", ".model");
347+
String[] tokenizerFiles = new String[binFiles.length + modelFiles.length];
347348
System.arraycopy(binFiles, 0, tokenizerFiles, 0, binFiles.length);
349+
System.arraycopy(modelFiles, 0, tokenizerFiles, binFiles.length, modelFiles.length);
348350
AlertDialog.Builder tokenizerPathBuilder = new AlertDialog.Builder(this);
349351
tokenizerPathBuilder.setTitle("Select tokenizer path");
350352
tokenizerPathBuilder.setSingleChoiceItems(

0 commit comments

Comments
 (0)