Skip to content
Closed
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
42 changes: 35 additions & 7 deletions extension/android/jni/jni_layer_llama.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
Expand Down Expand Up @@ -203,13 +203,41 @@
data_files_vector,
cpp_load_mode);
std::string decoder_model = "llama3"; // use llama3 for now
runner_ = std::make_unique<example::Runner<uint16_t>>( // QNN runner
std::move(module),
decoder_model.c_str(),
model_path->toStdString().c_str(),
tokenizer_path->toStdString().c_str(),
"",
"");
// Using 8bit as default since this meta is introduced with 16bit kv io
// support and older models only have 8bit kv io.
example::KvBitWidth kv_bitwidth = example::KvBitWidth::kWidth8;
if (module->method_names()->count("get_kv_io_bit_width") > 0) {
kv_bitwidth = static_cast<example::KvBitWidth>(
module->get("get_kv_io_bit_width")
.get()
.toScalar()
.to<int64_t>());
}

if (kv_bitwidth == example::KvBitWidth::kWidth8) {
runner_ = std::make_unique<example::Runner<uint8_t>>(
std::move(module),
decoder_model.c_str(),
model_path->toStdString().c_str(),
tokenizer_path->toStdString().c_str(),
"",
"",
temperature_);
} else if (kv_bitwidth == example::KvBitWidth::kWidth16) {
runner_ = std::make_unique<example::Runner<uint16_t>>(
std::move(module),
decoder_model.c_str(),
model_path->toStdString().c_str(),
tokenizer_path->toStdString().c_str(),
"",
"",
temperature_);
} else {
ET_CHECK_MSG(
false,
"Unsupported kv bitwidth: %ld",
static_cast<int64_t>(kv_bitwidth));
}
model_type_category_ = MODEL_TYPE_CATEGORY_LLM;
#endif
#if defined(EXECUTORCH_BUILD_MEDIATEK)
Expand Down
Loading