Skip to content

Commit

Permalink
webnn: Give an MLBuffer an MLOperandDescriptor
Browse files Browse the repository at this point in the history
This CL gives MLBufferDescriptor an MLOperandDescriptor as per
webmachinelearning/webnn#542

To represent this descriptor, this CL also creates a new typemapped
OperandDescriptor type which ensures that the buffer descriptor is
valid. OperandDescriptor will be used more pervasively within WebNN
in follow-up CLs

1) Move Operand::DataType to DataType (MERGED)
2) Create a typemapped OperandDescriptor class for MLBuffer <-- this CL
3) Use OperandDescriptor in mojom::Operand
4+) Remove duplicate code (especially with //components)

Bug: 343638938, 325598628
Cq-Include-Trybots: luci.chromium.try:win11-blink-rel
Change-Id: I775340f5c5e0e80942332cbae750d0d305cdd458
  • Loading branch information
a-sully authored and chromium-wpt-export-bot committed Jun 14, 2024
1 parent a4d4567 commit b196533
Show file tree
Hide file tree
Showing 2 changed files with 279 additions and 102 deletions.
14 changes: 13 additions & 1 deletion webnn/conformance_tests/buffer.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// META: variant=?cpu
// META: variant=?gpu
// META: variant=?npu
// META: script=../resources/utils_validation.js
// META: script=../resources/utils.js
// META: timeout=long

Expand All @@ -11,7 +12,18 @@
// https://webmachinelearning.github.io/webnn/#api-mlbuffer

if (navigator.ml) {
testCreateWebNNBuffer('create', 4);
testCreateWebNNBuffer('create', {dataType: 'float16', dimensions: [2, 3]});
testCreateWebNNBuffer('create', {dataType: 'float32', dimensions: [1, 5]});
testCreateWebNNBuffer('create', {dataType: 'int32', dimensions: [4]});
testCreateWebNNBuffer('create', {dataType: 'uint8', dimensions: [3, 2, 4]});

testCreateWebNNBufferFails(
'createFailsEmptyDimension', {dataType: 'int32', dimensions: [2, 0, 3]});
testCreateWebNNBufferFails('createFailsTooLarge', {
dataType: 'int32',
dimensions: [kMaxUnsignedLong, kMaxUnsignedLong, kMaxUnsignedLong]
});

testDestroyWebNNBuffer('destroyTwice');
testReadWebNNBuffer('read');
testWriteWebNNBuffer('write');
Expand Down
Loading

0 comments on commit b196533

Please sign in to comment.