Skip to content

Commit cc3152b

Browse files
authored
[Android] Remove old onStats
Differential Revision: D73292616 Pull Request resolved: #10312
1 parent 21adbe2 commit cc3152b

File tree

3 files changed

+3
-22
lines changed

3 files changed

+3
-22
lines changed

examples/demo-apps/android/LlamaDemo/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
```

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff 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
}

extension/android/jni/jni_layer_llama.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff 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(

0 commit comments

Comments
 (0)