Skip to content

Commit 2fdf7be

Browse files
authored
Clone tensor if using onnx wasm proxy (#1108)
1 parent 074e97a commit 2fdf7be

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/ops/registry.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createInferenceSession } from "../backends/onnx.js";
1+
import { createInferenceSession, isONNXProxy } from "../backends/onnx.js";
22
import { Tensor } from "../utils/tensor.js";
33

44
/**
@@ -17,7 +17,8 @@ const wrap = async (session_bytes, session_options, names) => {
1717
new Uint8Array(session_bytes), session_options,
1818
);
1919
return /** @type {any} */(async (/** @type {Record<string, Tensor>} */ inputs) => {
20-
const ortFeed = Object.fromEntries(Object.entries(inputs).map(([k, v]) => [k, v.ort_tensor]));
20+
const proxied = isONNXProxy();
21+
const ortFeed = Object.fromEntries(Object.entries(inputs).map(([k, v]) => [k, (proxied ? v.clone() : v).ort_tensor]));
2122
const outputs = await session.run(ortFeed);
2223

2324
if (Array.isArray(names)) {

0 commit comments

Comments
 (0)