Skip to content

Commit

Permalink
webnn: Rename READ[_FROM] and WRITE[_TO] MLTensorUsageFlags
Browse files Browse the repository at this point in the history
As agreed upon in discussions on the MLTensor explainer:
webmachinelearning/webnn#754

Bug: 361372446
Cq-Include-Trybots: luci.chromium.try:win11-blink-rel
Change-Id: I8bb993c1855c12eac68dc0f2ea359b5f1ae61932
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5858162
Commit-Queue: Austin Sullivan <[email protected]>
Reviewed-by: Reilly Grant <[email protected]>
Reviewed-by: Alex Gough <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1355445}
  • Loading branch information
a-sully authored and chromium-wpt-export-bot committed Sep 14, 2024
1 parent bca18ba commit 31f51a6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions webnn/conformance_tests/byob_readtensor.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ promise_setup(async () => {
mlTensor = await mlContext.createTensor({
dataType: 'int32',
dimensions: [2, 4],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
});
} catch (e) {
throw new AssertionError(
Expand Down Expand Up @@ -141,7 +141,7 @@ promise_test(async (t) => {
const tensor = await mlContext.createTensor({
dataType: 'int32',
dimensions: [2, 2],
usage: MLTensorUsage.READ_FROM,
usage: MLTensorUsage.READ,
});
const arrayBufferView = new Int32Array(2 * 2);
const arrayBuffer = arrayBufferView.buffer;
Expand All @@ -159,7 +159,7 @@ promise_test(async (t) => {
const tensor = await mlContext.createTensor({
dataType: 'int32',
dimensions: [2, 2],
usage: MLTensorUsage.READ_FROM,
usage: MLTensorUsage.READ,
});
const arrayBufferView = new Int32Array(2 * 2);
const arrayBuffer = arrayBufferView.buffer;
Expand Down
18 changes: 9 additions & 9 deletions webnn/conformance_tests/parallel-dispatch.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ promise_test(async () => {
const operandDescriptor = {
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
};

const [mlGraph, inputTensor1, inputTensor2, outputTensor] =
Expand Down Expand Up @@ -73,7 +73,7 @@ promise_test(async () => {
const operandDescriptor = {
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
};
const mlGraph = await buildMulGraph(mlContext, operandDescriptor, 3);

Expand Down Expand Up @@ -101,7 +101,7 @@ promise_test(async () => {
const operandDescriptor = {
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
};
const mlGraph = await buildMulGraph(mlContext, operandDescriptor, 10);

Expand Down Expand Up @@ -140,7 +140,7 @@ promise_test(async () => {
const operandDescriptor = {
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
};
const mlGraph = await buildMulGraph(mlContext, operandDescriptor, 9);

Expand Down Expand Up @@ -178,7 +178,7 @@ promise_test(async () => {
const operandDescriptor = {
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
};
const mlGraph = await buildMulGraph(mlContext, operandDescriptor, 2);

Expand Down Expand Up @@ -211,7 +211,7 @@ promise_test(async () => {
const operandDescriptor = {
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
};

// write/write...
Expand Down Expand Up @@ -250,7 +250,7 @@ promise_test(async () => {
const operandDescriptor = {
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
};

// write/write...
Expand Down Expand Up @@ -288,7 +288,7 @@ promise_test(async () => {
const operandDescriptor = {
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
};

const graphs = await Promise.all([3, 2].map(async (multiplier) => {
Expand Down Expand Up @@ -324,7 +324,7 @@ promise_test(async () => {
const operandDescriptor = {
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
};

const graphs = await Promise.all([2, 3].map(async (multiplier) => {
Expand Down
30 changes: 15 additions & 15 deletions webnn/conformance_tests/tensor.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const testWriteTensor = (testName) => {
const tensorDescriptor = {
dataType: 'int32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO,
usage: MLTensorUsage.WRITE,
};
let mlTensor = await mlContext.createTensor(tensorDescriptor);

Expand Down Expand Up @@ -216,7 +216,7 @@ const testWriteTensor = (testName) => {
const tensorDescriptor = {
dataType: 'int32',
dimensions: [2, 2],
usage: MLTensorUsage.WRITE_TO,
usage: MLTensorUsage.WRITE,
};
let mlTensor = await mlContext.createTensor(tensorDescriptor);

Expand All @@ -233,7 +233,7 @@ const testWriteTensor = (testName) => {
const tensorDescriptor = {
dataType: 'int32',
dimensions: [2, 3],
usage: MLTensorUsage.WRITE_TO,
usage: MLTensorUsage.WRITE,
};
let mlTensor = await mlContext.createTensor(tensorDescriptor);

Expand All @@ -252,7 +252,7 @@ const testWriteTensor = (testName) => {
let mlTensor = await mlContext.createTensor({
dataType: 'int32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
});

// Initialize the tensor.
Expand All @@ -275,7 +275,7 @@ const testWriteTensor = (testName) => {
const tensorDescriptor = {
dataType: 'int32',
dimensions: [2, 2],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
};
let mlTensor = await mlContext.createTensor(tensorDescriptor);

Expand Down Expand Up @@ -326,7 +326,7 @@ const testReadTensor = (testName) => {
let mlTensor = await mlContext.createTensor({
dataType: 'int32',
dimensions: [2, 2],
usage: MLTensorUsage.READ_FROM,
usage: MLTensorUsage.READ,
});

// Reading a destroyed MLTensor should reject.
Expand All @@ -340,7 +340,7 @@ const testReadTensor = (testName) => {
let mlTensor = await mlContext.createTensor({
dataType: 'int32',
dimensions: [2, 3],
usage: MLTensorUsage.READ_FROM,
usage: MLTensorUsage.READ,
});

let promise = mlContext.readTensor(mlTensor);
Expand All @@ -356,7 +356,7 @@ const testReadTensor = (testName) => {
let mlTensor = await mlContext.createTensor({
dataType: 'int32',
dimensions: [1024],
usage: MLTensorUsage.READ_FROM,
usage: MLTensorUsage.READ,
});

await assert_tensor_data_equals(mlContext, mlTensor, new Uint32Array(1024));
Expand All @@ -366,7 +366,7 @@ const testReadTensor = (testName) => {
let mlTensor = await mlContext.createTensor({
dataType: 'int32',
dimensions: [1],
usage: MLTensorUsage.READ_FROM | MLTensorUsage.WRITE_TO,
usage: MLTensorUsage.READ | MLTensorUsage.WRITE,
});

// Initialize the tensor.
Expand All @@ -382,7 +382,7 @@ const testReadTensor = (testName) => {
let mlTensor = await mlContext.createTensor({
dataType: 'int32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
});

// Initialize the tensor.
Expand All @@ -400,7 +400,7 @@ const testReadTensor = (testName) => {
let mlTensor = await mlContext.createTensor({
dataType: 'int32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
});

// Initialize the tensor.
Expand All @@ -418,7 +418,7 @@ const testReadTensor = (testName) => {
let mlTensor = await mlContext.createTensor({
dataType: 'int32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
});

// Initialize the tensor.
Expand All @@ -436,7 +436,7 @@ const testReadTensor = (testName) => {
let mlTensor = await mlContext.createTensor({
dataType: 'int32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
});

const inputData = [0xAA, 0xAA, 0xAA, 0xAA];
Expand All @@ -453,7 +453,7 @@ const testReadTensor = (testName) => {
const tensorDescriptor = {
dataType: 'int32',
dimensions: [2, 3],
usage: MLTensorUsage.READ_FROM,
usage: MLTensorUsage.READ,
};
let mlTensor = await mlContext.createTensor(tensorDescriptor);

Expand Down Expand Up @@ -489,7 +489,7 @@ const testDispatchTensor = (testName) => {
const tensorDescriptor = {
dataType: 'float32',
dimensions: shape,
usage: MLTensorUsage.WRITE_TO | MLTensorUsage.READ_FROM,
usage: MLTensorUsage.WRITE | MLTensorUsage.READ,
};
const lhsOperand = builder.input('lhs', tensorDescriptor);
const rhsOperand = builder.input('rhs', tensorDescriptor);
Expand Down
6 changes: 3 additions & 3 deletions webnn/validation_tests/destroyContext.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ promise_test(async t => {
const tensor = await context.createTensor({
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.READ_FROM,
usage: MLTensorUsage.READ,
});
context.destroy();
promise_rejects_dom(t, 'InvalidStateError', context.readTensor(tensor));
Expand All @@ -146,7 +146,7 @@ promise_test(async t => {
const tensor = await context.createTensor({
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.READ_FROM,
usage: MLTensorUsage.READ,
});
let promise = context.readTensor(tensor);
context.destroy();
Expand All @@ -161,7 +161,7 @@ promise_test(async t => {
const tensor = await context.createTensor({
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO,
usage: MLTensorUsage.WRITE,
});
let arrayBuffer = new ArrayBuffer(4);
context.destroy();
Expand Down
6 changes: 3 additions & 3 deletions webnn/validation_tests/destroyGraph.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@ promise_test(async t => {
const lhsTensor = await context.createTensor({
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO,
usage: MLTensorUsage.WRITE,
});
const rhsTensor = await context.createTensor({
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.WRITE_TO,
usage: MLTensorUsage.WRITE,
});
const outputTensor = await context.createTensor({
dataType: 'float32',
dimensions: [1],
usage: MLTensorUsage.READ_FROM,
usage: MLTensorUsage.READ,
});
// Initialize inputs
const inputData = new Float32Array(1).fill(2.0);
Expand Down

0 comments on commit 31f51a6

Please sign in to comment.