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
135
135
}
136
136
137
137
@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
140
140
}
141
141
142
142
```
Original file line number Diff line number Diff line change @@ -28,17 +28,6 @@ public interface LlmCallback {
28
28
@ DoNotStrip
29
29
public void onResult (String result );
30
30
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
-
42
31
/**
43
32
* Called when the statistics for the generate() is available.
44
33
*
@@ -48,5 +37,5 @@ default public void onStats(float tps) {}
48
37
* @param stats JSON string containing the statistics for the generate()
49
38
*/
50
39
@ DoNotStrip
51
- default public void onStats (String stats ) {}
40
+ default void onStats (String stats ) {}
52
41
}
Original file line number Diff line number Diff line change @@ -100,14 +100,6 @@ class ExecuTorchLlmCallbackJni
100
100
101
101
void onStats (const llm::Stats& result) const {
102
102
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
-
111
103
static const auto on_stats_method =
112
104
cls->getMethod <void (facebook::jni::local_ref<jstring>)>(" onStats" );
113
105
on_stats_method (
You can’t perform that action at this time.
0 commit comments