Skip to content

Commit

Permalink
Clone tensor if using onnx wasm proxy (#1108)
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova authored Dec 23, 2024
1 parent 074e97a commit 2fdf7be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ops/registry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createInferenceSession } from "../backends/onnx.js";
import { createInferenceSession, isONNXProxy } from "../backends/onnx.js";
import { Tensor } from "../utils/tensor.js";

/**
Expand All @@ -17,7 +17,8 @@ const wrap = async (session_bytes, session_options, names) => {
new Uint8Array(session_bytes), session_options,
);
return /** @type {any} */(async (/** @type {Record<string, Tensor>} */ 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)) {
Expand Down

0 comments on commit 2fdf7be

Please sign in to comment.