File tree Expand file tree Collapse file tree 3 files changed +3
-22
lines changed
examples/demo-apps/android/LlamaDemo
executorch_android/src/main/java/org/pytorch/executorch/extension/llm Expand file tree Collapse file tree 3 files changed +3
-22
lines changed Original file line number Diff line number Diff line change @@ -135,8 +135,8 @@ Ensure you have the following functions in your callback class that you provided
135135 }
136136
137137 @Override
138- public void onStats(float tps ) {
139- // ...tps (tokens per second) stats is provided by framework
138+ public void onStats(String stats ) {
139+ // ... will be a json. See extension/llm/ stats.h for the field definitions
140140 }
141141
142142```
Original file line number Diff line number Diff line change @@ -28,17 +28,6 @@ public interface LlmCallback {
2828 @ DoNotStrip
2929 public void onResult (String result );
3030
31- /**
32- * Called when the statistics for the generate() is available.
33- *
34- * Note: This is a deprecated API and will be removed in the future. Please use onStats(String stats)
35- *
36- * @param tps Tokens/second for generated tokens.
37- */
38- @ Deprecated
39- @ DoNotStrip
40- default public void onStats (float tps ) {}
41-
4231 /**
4332 * Called when the statistics for the generate() is available.
4433 *
@@ -48,5 +37,5 @@ default public void onStats(float tps) {}
4837 * @param stats JSON string containing the statistics for the generate()
4938 */
5039 @ DoNotStrip
51- default public void onStats (String stats ) {}
40+ default void onStats (String stats ) {}
5241}
Original file line number Diff line number Diff line change @@ -100,14 +100,6 @@ class ExecuTorchLlmCallbackJni
100100
101101 void onStats (const llm::Stats& result) const {
102102 static auto cls = ExecuTorchLlmCallbackJni::javaClassStatic ();
103- static const auto tps_method = cls->getMethod <void (jfloat)>(" onStats" );
104- double eval_time =
105- (double )(result.inference_end_ms - result.prompt_eval_end_ms );
106-
107- float tps = result.num_generated_tokens / eval_time *
108- result.SCALING_FACTOR_UNITS_PER_SECOND ;
109- tps_method (self (), tps);
110-
111103 static const auto on_stats_method =
112104 cls->getMethod <void (facebook::jni::local_ref<jstring>)>(" onStats" );
113105 on_stats_method (
You can’t perform that action at this time.
0 commit comments