Skip to content

Commit d276879

Browse files
committed
Update logging in MainActivity
1 parent 4df9ab2 commit d276879

File tree

1 file changed

+6
-6
lines changed
  • mobile/examples/phi-3/android/app/src/main/java/ai/onnxruntime/genai/demo

1 file changed

+6
-6
lines changed

mobile/examples/phi-3/android/app/src/main/java/ai/onnxruntime/genai/demo/MainActivity.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ protected void onCreate(Bundle savedInstanceState) {
8080
public void onSettingsApplied(int maxLength, int lengthPenalty) {
8181
MainActivity.this.maxLength = maxLength;
8282
MainActivity.this.lengthPenalty = lengthPenalty;
83-
Log.i(TAG, "Max Response length: " + maxLength);
84-
Log.i(TAG, "Length penalty: " + lengthPenalty);
83+
Log.i(TAG, "Setting max response length to: " + maxLength);
84+
Log.i(TAG, "Setting length penalty to: " + lengthPenalty);
8585
}
8686
});
8787
bottomSheet.show(getSupportFragmentManager(), "BottomSheet");
@@ -141,17 +141,14 @@ public void run() {
141141
generatorParams.setSearchOption("length_penalty", lengthPenalty);
142142
generatorParams.setSearchOption("max_length", maxLength);
143143

144-
Log.i(TAG, "Length penalty: " + lengthPenalty);
145-
Log.i(TAG, "Max Response length: " + maxLength);
146-
147-
148144
encodedPrompt = tokenizer.encode(promptQuestion_formatted);
149145
generatorParams.setInput(encodedPrompt);
150146

151147
generator = new Generator(model, generatorParams);
152148

153149
// try to measure average time taken to generate each token.
154150
long startTime = System.currentTimeMillis();
151+
long currentTime = startTime;
155152
int numTokens = 0;
156153
while (!generator.isDone()) {
157154
generator.computeLogits();
@@ -160,7 +157,10 @@ public void run() {
160157
int token = generator.getLastTokenInSequence(0);
161158

162159
tokenListener.accept(stream.decode(token));
160+
163161
Log.i(TAG, "Generated token: " + token + ": " + stream.decode(token));
162+
Log.i(TAG, "Time taken to generate token: " + (System.currentTimeMillis() - currentTime)/ 1000.0 + " seconds");
163+
currentTime = System.currentTimeMillis();
164164
numTokens++;
165165
}
166166
long totalTime = System.currentTimeMillis() - startTime;

0 commit comments

Comments
 (0)