Skip to content

Android JNI llama cache temperature in class #10287

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 2 commits into from
Apr 22, 2025
Merged
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
9 changes: 4 additions & 5 deletions extension/android/jni/jni_layer_llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class ExecuTorchLlmCallbackJni
class ExecuTorchLlmJni : public facebook::jni::HybridClass<ExecuTorchLlmJni> {
private:
friend HybridBase;
float temperature_;
int model_type_category_;
std::unique_ptr<llm::IRunner> runner_;
std::unique_ptr<llm::MultimodalRunner> multi_modal_runner_;
Expand Down Expand Up @@ -175,20 +176,17 @@ class ExecuTorchLlmJni : public facebook::jni::HybridClass<ExecuTorchLlmJni> {
runner_ = std::make_unique<example::Runner>(
model_path->toStdString().c_str(),
tokenizer_path->toStdString().c_str(),
temperature,
data_path->toStdString().c_str());
} else {
runner_ = std::make_unique<example::Runner>(
model_path->toStdString().c_str(),
tokenizer_path->toStdString().c_str(),
temperature);
tokenizer_path->toStdString().c_str());
}
#if defined(EXECUTORCH_BUILD_MEDIATEK)
} else if (model_type_category == MODEL_TYPE_MEDIATEK_LLAMA) {
runner_ = std::make_unique<MTKLlamaRunner>(
model_path->toStdString().c_str(),
tokenizer_path->toStdString().c_str(),
temperature);
tokenizer_path->toStdString().c_str());
// Interpret the model type as LLM
model_type_category_ = MODEL_TYPE_CATEGORY_LLM;
#endif
Expand Down Expand Up @@ -228,6 +226,7 @@ class ExecuTorchLlmJni : public facebook::jni::HybridClass<ExecuTorchLlmJni> {
executorch::extension::llm::GenerationConfig config{
.echo = static_cast<bool>(echo),
.seq_len = seq_len,
.temperature = temperature_,
};
runner_->generate(
prompt->toStdString(),
Expand Down
Loading