Skip to content

Commit 7970f6a

Browse files
committed
fix(sb_ai): parsing input tensors correctly
1 parent 2d23881 commit 7970f6a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ext/ai/js/onnxruntime/onnx.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TensorProxy {
1919
get(target, property) {
2020
switch (property) {
2121
case 'data':
22-
return target.data.c;
22+
return target.data?.c ?? target.data;
2323

2424
default:
2525
return target[property];
@@ -90,11 +90,10 @@ class InferenceSession {
9090
for (const key in inputs) {
9191
if (Object.hasOwn(inputs, key)) {
9292
const tensorLike = inputs[key];
93-
const { type, data, dims } = tensorLike;
93+
// NOTE:(kallebysantos) we first apply the proxy because data could be either TypedArray or {ty: DataType, c: TypedArray}
94+
const { type, data, dims } = TensorProxy.fromTensor(tensorLike);
9495

95-
sessionInputs[key] = tensorLike instanceof Tensor
96-
? tensorLike
97-
: new Tensor(type, data, dims);
96+
sessionInputs[key] = new Tensor(type, data, dims);
9897
}
9998
}
10099

0 commit comments

Comments
 (0)