Skip to content

Commit

Permalink
add more type checks
Browse files Browse the repository at this point in the history
  • Loading branch information
prathikr committed Sep 12, 2024
1 parent 4b76477 commit 1f6dd04
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion js/common/lib/tensor-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ export class Tensor implements TensorInterface {
} else if (arg1 instanceof typedArrayConstructor) {
data = arg1;
} else if (arg1 instanceof Uint8ClampedArray) {
data = Uint8Array.from(arg1);
if (arg0 === 'uint8') {
data = Uint8Array.from(arg1);
} else {
throw new TypeError(`A Uint8ClampedArray tensor's data must be type of uint8`);
}
} else {
throw new TypeError(`A ${type} tensor's data must be type of ${typedArrayConstructor}`);
}
Expand Down

0 comments on commit 1f6dd04

Please sign in to comment.