Skip to content

[Android] Remove old onStats #10312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/demo-apps/android/LlamaDemo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ Ensure you have the following functions in your callback class that you provided
}

@Override
public void onStats(float tps) {
//...tps (tokens per second) stats is provided by framework
public void onStats(String stats) {
//... will be a json. See extension/llm/stats.h for the field definitions
}

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ public interface LlmCallback {
@DoNotStrip
public void onResult(String result);

/**
* Called when the statistics for the generate() is available.
*
* Note: This is a deprecated API and will be removed in the future. Please use onStats(String stats)
*
* @param tps Tokens/second for generated tokens.
*/
@Deprecated
@DoNotStrip
default public void onStats(float tps) {}

/**
* Called when the statistics for the generate() is available.
*
Expand All @@ -48,5 +37,5 @@ default public void onStats(float tps) {}
* @param stats JSON string containing the statistics for the generate()
*/
@DoNotStrip
default public void onStats(String stats) {}
default void onStats(String stats) {}
}
8 changes: 0 additions & 8 deletions extension/android/jni/jni_layer_llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ class ExecuTorchLlmCallbackJni

void onStats(const llm::Stats& result) const {
static auto cls = ExecuTorchLlmCallbackJni::javaClassStatic();
static const auto tps_method = cls->getMethod<void(jfloat)>("onStats");
double eval_time =
(double)(result.inference_end_ms - result.prompt_eval_end_ms);

float tps = result.num_generated_tokens / eval_time *
result.SCALING_FACTOR_UNITS_PER_SECOND;
tps_method(self(), tps);

static const auto on_stats_method =
cls->getMethod<void(facebook::jni::local_ref<jstring>)>("onStats");
on_stats_method(
Expand Down
Loading