Skip to content

Commit

Permalink
webnn: Set a max operand rank of 8
Browse files Browse the repository at this point in the history
We likely eventually want this to be part of MLOpSupportsLimits, but
for now this allows us to replace some checked-casts in favor of
static-casts, and not need to worry about tensors with absurd ranks

See webmachinelearning/webnn#456

Bug: 329482489
Cq-Include-Trybots: luci.chromium.try:win11-blink-rel,mac14-blink-rel,mac14.arm64-blink-rel
Change-Id: I021d3b30ea1b8f5f3bef1725130fd2e4c569f494
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5639505
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Reviewed-by: Phillis Tang <phillis@chromium.org>
Reviewed-by: Koji Ishii <kojii@chromium.org>
Commit-Queue: Austin Sullivan <asully@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1344800}
  • Loading branch information
a-sully authored and chromium-wpt-export-bot committed Aug 21, 2024
1 parent 1cbcd67 commit 9918dff
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions webnn/validation_tests/invalid-rank.https.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// META: title=ensure an MLOperand cannot be created with an invalid rank
// META: global=window,dedicatedworker
// META: variant=?cpu
// META: variant=?gpu
// META: variant=?npu
// META: script=../resources/utils_validation.js

promise_test(async t => {
const builder = new MLGraphBuilder(context);

const shapeWithLargeRank = Array(10).fill(2);
assert_throws_js(
TypeError,
() => builder.input(
'a', {dataType: 'float32', dimensions: shapeWithLargeRank}));
}, 'Throw if rank is too large');

0 comments on commit 9918dff

Please sign in to comment.