Skip to content

Commit f43d3c5

Browse files
authored
fix: expose unload() JSI binding for TextToImageModule (#947)
## Summary `TextToImage::unload()` is implemented in C++ and correctly delegates to its sub-components (encoder, unet, decoder), but the JSI binding was never registered in `ModelHostObject`. This causes a `TypeError: this.nativeModule.unload is not a function` when calling `BaseModule.delete()` from JavaScript. Every other composite model (OCR, VerticalOCR, Kokoro, LLM) already registers `unload` in its `if constexpr` block — this adds the same one-liner for TextToImage. ## Changes - Added `unload` JSI export to the `TextToImage` block in `ModelHostObject.h`, matching the existing pattern used by other models ## Test plan - [x] Call `module.delete()` on a loaded `TextToImageModule` — should no longer throw - [x] Verify model memory is released after `delete()` (encoder, unet, decoder sub-models are unloaded)
1 parent fdbd3e9 commit f43d3c5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

packages/react-native-executorch/common/rnexecutorch/host_objects/ModelHostObject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ template <typename Model> class ModelHostObject : public JsiHostObject {
148148
}
149149

150150
if constexpr (meta::SameAs<Model, models::text_to_image::TextToImage>) {
151+
addFunctions(
152+
JSI_EXPORT_FUNCTION(ModelHostObject<Model>, unload, "unload"));
151153
addFunctions(JSI_EXPORT_FUNCTION(
152154
ModelHostObject<Model>, synchronousHostFunction<&Model::interrupt>,
153155
"interrupt"));

0 commit comments

Comments
 (0)