From 2fdf7be8300b483b1c5d39c5c8db83088442fd13 Mon Sep 17 00:00:00 2001 From: Joshua Lochner Date: Mon, 23 Dec 2024 16:40:17 +0200 Subject: [PATCH] Clone tensor if using onnx wasm proxy (#1108) --- src/ops/registry.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ops/registry.js b/src/ops/registry.js index f641fe878..ba6dd7ecf 100644 --- a/src/ops/registry.js +++ b/src/ops/registry.js @@ -1,4 +1,4 @@ -import { createInferenceSession } from "../backends/onnx.js"; +import { createInferenceSession, isONNXProxy } from "../backends/onnx.js"; import { Tensor } from "../utils/tensor.js"; /** @@ -17,7 +17,8 @@ const wrap = async (session_bytes, session_options, names) => { new Uint8Array(session_bytes), session_options, ); return /** @type {any} */(async (/** @type {Record} */ inputs) => { - const ortFeed = Object.fromEntries(Object.entries(inputs).map(([k, v]) => [k, v.ort_tensor])); + const proxied = isONNXProxy(); + const ortFeed = Object.fromEntries(Object.entries(inputs).map(([k, v]) => [k, (proxied ? v.clone() : v).ort_tensor])); const outputs = await session.run(ortFeed); if (Array.isArray(names)) {