Skip to content

Commit c258351

Browse files
whhonecopybara-github
authored andcommitted
No public description
LiteRT-LM-PiperOrigin-RevId: 908892173
1 parent 00f8059 commit c258351

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

kotlin/java/com/google/ai/edge/litertlm/jni/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ cc_binary(
4545
"//runtime/executor:executor_settings_base",
4646
"//runtime/executor:llm_executor_settings",
4747
"//runtime/proto:sampler_params_cc_proto",
48+
"//runtime/util:file_util",
4849
"//runtime/util:litert_lm_loader",
4950
"//runtime/util:logging",
5051
"//schema/capabilities:capabilities_c",

kotlin/java/com/google/ai/edge/litertlm/jni/litertlm.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "runtime/executor/executor_settings_base.h"
4242
#include "runtime/executor/llm_executor_settings.h"
4343
#include "runtime/proto/sampler_params.pb.h"
44+
#include "runtime/util/file_util.h"
4445
#include "runtime/util/logging.h"
4546
#include "schema/capabilities/capabilities_c.h"
4647
#include "tflite/logger.h" // from @litert
@@ -69,6 +70,7 @@ using litert::lm::ConversationConfig;
6970
using litert::lm::Engine;
7071
using litert::lm::EngineFactory;
7172
using litert::lm::EngineSettings;
73+
using litert::lm::FileExists;
7274
using litert::lm::InputAudio;
7375
using litert::lm::InputData;
7476
using litert::lm::InputImage;
@@ -352,9 +354,7 @@ LITERTLM_JNIEXPORT jlong JNICALL JNI_METHOD(nativeCreateEngine)(
352354
std::string model_path_str(model_path_chars);
353355
env->ReleaseStringUTFChars(model_path, model_path_chars);
354356

355-
// Check if the file exists.
356-
struct stat buffer;
357-
if (stat(model_path_str.c_str(), &buffer) != 0) {
357+
if (!FileExists(model_path_str)) {
358358
ThrowLiteRtLmJniException(env, "Model file not found: " + model_path_str);
359359
return 0;
360360
}
@@ -527,9 +527,7 @@ LITERTLM_JNIEXPORT jlong JNICALL JNI_METHOD(nativeCreateBenchmark)(
527527
std::string model_path_str(model_path_chars);
528528
env->ReleaseStringUTFChars(model_path, model_path_chars);
529529

530-
// Check if the file exists.
531-
struct stat buffer;
532-
if (stat(model_path_str.c_str(), &buffer) != 0) {
530+
if (!FileExists(model_path_str)) {
533531
ThrowLiteRtLmJniException(env, "Model file not found: " + model_path_str);
534532
return 0;
535533
}

0 commit comments

Comments
 (0)