Skip to content

Commit

Permalink
Update src/models.js - Use conditional operator
Browse files Browse the repository at this point in the history
Co-authored-by: Joshua Lochner <[email protected]>
  • Loading branch information
kungfooman and xenova authored Nov 19, 2023
1 parent f89a296 commit 8bd4ccc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,10 @@ async function validateInputs(session, inputs) {
if (!tensor) {
missingInputs.push(inputName);
} else {
if (env.wasm.proxy) {
// Moving the tensor across Worker boundary moves ownership to the worker,
// which invalidates the tensor. So we simply sacrifize the clone for it.
checkedInputs[inputName] = tensor.clone();
} else {
checkedInputs[inputName] = tensor;
}
// NOTE: When `env.wasm.proxy is true`, when the tensor is moved across the Worker
// boundary, the ownership is transferred to the worker, invalidating the tensor.
// So, in this case, we simply sacrifice a clone for it.
checkedInputs[inputName] = env.wasm.proxy ? tensor.clone() : tensor;
}
}
if (missingInputs.length > 0) {
Expand Down

0 comments on commit 8bd4ccc

Please sign in to comment.