Skip to content
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
25 changes: 22 additions & 3 deletions extension/android/jni/jni_layer_llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <executorch/runtime/platform/platform.h>
#include <executorch/runtime/platform/runtime.h>

#include <executorch/extension/android/jni/jni_helper.h>

#if defined(ET_USE_THREADPOOL)
#include <executorch/extension/threadpool/cpuinfo_utils.h>
#include <executorch/extension/threadpool/threadpool.h>
Expand Down Expand Up @@ -404,12 +406,29 @@ class ExecuTorchLlmJni : public facebook::jni::HybridClass<ExecuTorchLlmJni> {
}

jint load() {
int result = -1;
std::stringstream ss;

if (model_type_category_ == MODEL_TYPE_CATEGORY_MULTIMODAL) {
return static_cast<jint>(multi_modal_runner_->load());
result = static_cast<jint>(multi_modal_runner_->load());
if (result != 0) {
ss << "Failed to load multimodal runner: [" << result << "]";
}
} else if (model_type_category_ == MODEL_TYPE_CATEGORY_LLM) {
return static_cast<jint>(runner_->load());
result = static_cast<jint>(runner_->load());
if (result != 0) {
ss << "Failed to load llm runner: [" << result << "]";
}
} else {
ss << "Invalid model type category: " << model_type_category_
<< ". Valid values are: " << MODEL_TYPE_CATEGORY_LLM << " or "
<< MODEL_TYPE_CATEGORY_MULTIMODAL;
}
if (result != 0) {
executorch::jni_helper::throwExecutorchException(
static_cast<uint32_t>(Error::InvalidArgument), ss.str().c_str());
}
return static_cast<jint>(Error::InvalidArgument);
return result; // 0 on success to keep backward compatibility
}

static void registerNatives() {
Expand Down
Loading