From 8bd4ccc32234561e66ad14ec696a9d9629826a47 Mon Sep 17 00:00:00 2001 From: Hermann Rolfes Date: Sun, 19 Nov 2023 16:33:53 +0100 Subject: [PATCH] Update src/models.js - Use conditional operator Co-authored-by: Joshua Lochner --- src/models.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/models.js b/src/models.js index 59a4b4723..59674a86c 100644 --- a/src/models.js +++ b/src/models.js @@ -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) {