File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change 2323#include < executorch/runtime/platform/platform.h>
2424#include < executorch/runtime/platform/runtime.h>
2525
26+ #include < executorch/extension/android/jni/jni_helper.h>
27+
2628#if defined(ET_USE_THREADPOOL)
2729#include < executorch/extension/threadpool/cpuinfo_utils.h>
2830#include < executorch/extension/threadpool/threadpool.h>
@@ -404,12 +406,29 @@ class ExecuTorchLlmJni : public facebook::jni::HybridClass<ExecuTorchLlmJni> {
404406 }
405407
406408 jint load () {
409+ int result = -1 ;
410+ std::stringstream ss;
411+
407412 if (model_type_category_ == MODEL_TYPE_CATEGORY_MULTIMODAL) {
408- return static_cast <jint>(multi_modal_runner_->load ());
413+ result = static_cast <jint>(multi_modal_runner_->load ());
414+ if (result != 0 ) {
415+ ss << " Failed to load multimodal runner: [" << result << " ]" ;
416+ }
409417 } else if (model_type_category_ == MODEL_TYPE_CATEGORY_LLM) {
410- return static_cast <jint>(runner_->load ());
418+ result = static_cast <jint>(runner_->load ());
419+ if (result != 0 ) {
420+ ss << " Failed to load llm runner: [" << result << " ]" ;
421+ }
422+ } else {
423+ ss << " Invalid model type category: " << model_type_category_
424+ << " . Valid values are: " << MODEL_TYPE_CATEGORY_LLM << " or "
425+ << MODEL_TYPE_CATEGORY_MULTIMODAL;
426+ }
427+ if (result != 0 ) {
428+ executorch::jni_helper::throwExecutorchException (
429+ static_cast <uint32_t >(Error::InvalidArgument), ss.str ().c_str ());
411430 }
412- return static_cast <jint>(Error::InvalidArgument);
431+ return result; // 0 on success to keep backward compatibility
413432 }
414433
415434 static void registerNatives () {
You can’t perform that action at this time.
0 commit comments