Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ template <typename Model> class ModelHostObject : public JsiHostObject {
JSI_HOST_FUNCTION(unload) {
try {
model->unload();
thisValue.asObject(runtime).setExternalMemoryPressure(runtime, 0);
} catch (const RnExecutorchError &e) {
jsi::Object errorData(runtime);
errorData.setProperty(runtime, "code", e.getNumericCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@
return runner_->get_max_context_length();
}

void LLM::unload() noexcept { runner_.reset(nullptr); }
void LLM::unload() noexcept {
runner.reset(nullptr);

Check failure on line 259 in packages/react-native-executorch/common/rnexecutorch/models/llm/LLM.cpp

View workflow job for this annotation

GitHub Actions / build

use of undeclared identifier 'runner'; did you mean 'runner_'?
Comment thread
barhanc marked this conversation as resolved.
Outdated
BaseModel::unload();
}

} // namespace rnexecutorch::models::llm
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ export class LLMController {
await ResourceFetcher.fs.readAsString(tokenizerConfigPath!)
);

if (this.nativeModule) {
this.nativeModule.unload();
}

this.nativeModule = await global.loadLLM(
modelPath,
tokenizerPath,
Expand Down
Loading