Skip to content

Commit b8b43f6

Browse files
Android fix uninitialized temperature (#10619)
Temperature was garbage value, and could cause issue in llm generation sampler. Co-authored-by: Anthony Shoumikhin <[email protected]>
1 parent 0cd2cff commit b8b43f6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

extension/android/jni/jni_layer_llama.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class ExecuTorchLlmCallbackJni
112112
class ExecuTorchLlmJni : public facebook::jni::HybridClass<ExecuTorchLlmJni> {
113113
private:
114114
friend HybridBase;
115-
float temperature_;
115+
float temperature_ = 0.0f;
116116
int model_type_category_;
117117
std::unique_ptr<llm::IRunner> runner_;
118118
std::unique_ptr<llm::MultimodalRunner> multi_modal_runner_;
@@ -146,6 +146,7 @@ class ExecuTorchLlmJni : public facebook::jni::HybridClass<ExecuTorchLlmJni> {
146146
facebook::jni::alias_ref<jstring> tokenizer_path,
147147
jfloat temperature,
148148
facebook::jni::alias_ref<jstring> data_path = nullptr) {
149+
temperature_ = temperature;
149150
#if defined(ET_USE_THREADPOOL)
150151
// Reserve 1 thread for the main thread.
151152
int32_t num_performant_cores =

0 commit comments

Comments
 (0)