Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix react native load from Uint8Array buffer bug #17739

Merged
merged 1 commit into from
Sep 30, 2023
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
4 changes: 3 additions & 1 deletion js/react_native/lib/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ class OnnxruntimeSessionHandler implements SessionHandler {
let results: Binding.ModelLoadInfoType;
// load a model
if (typeof this.#pathOrBuffer === 'string') {
// load model from model path
results = await this.#inferenceSession.loadModel(normalizePath(this.#pathOrBuffer), options);
} else {
// load model from buffer
if (!this.#inferenceSession.loadModelFromBlob) {
throw new Error('Native module method "loadModelFromBlob" is not defined');
}
const modelBlob = jsiHelper.storeArrayBuffer(this.#pathOrBuffer);
const modelBlob = jsiHelper.storeArrayBuffer(this.#pathOrBuffer.buffer);
results = await this.#inferenceSession.loadModelFromBlob(modelBlob, options);
}
// resolve promise if onnxruntime session is successfully created
Expand Down
Loading