Skip to content

Commit fe3c1dc

Browse files
phaitingHaiting Pu
andauthored
Fix the llm module e2e test (pytorch#15275)
The generate API for llm has two issues. - The input image could be null, but prefillImages assume non-null, this cause prefillImages return Error::EndOfMethod, this can be fixed by adding a null check on the java layer - The generate didn't pass prompt which caused stack overflow Test plan Run all e2e test on the local emulator and run via CI Co-authored-by: Haiting Pu <[email protected]>
1 parent 9b744b4 commit fe3c1dc

File tree

1 file changed

+4
-2
lines changed
  • extension/android/executorch_android/src/main/java/org/pytorch/executorch/extension/llm

1 file changed

+4
-2
lines changed

extension/android/executorch_android/src/main/java/org/pytorch/executorch/extension/llm/LlmModule.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,10 @@ public int generate(
182182
LlmCallback llmCallback,
183183
boolean echo) {
184184
prefillPrompt(prompt);
185-
prefillImages(image, width, height, channels);
186-
return generate("", llmCallback, echo);
185+
if (image != null) {
186+
prefillImages(image, width, height, channels);
187+
}
188+
return generate(prompt, seqLen, llmCallback, echo);
187189
}
188190

189191
/**

0 commit comments

Comments
 (0)