Skip to content

Commit 1b59c6e

Browse files
wangw-1991chromium-wpt-export-bot
authored andcommitted
[WebNN] Support device tensor for WebGPU EP on ORT backend
Device tensor is already supported for OpenVINO EP on ORT backend in [1], this CL supports device tensor for WebGPU EP on ORT backend. The main difference is that device tensor is only used when WebNN developers do not need to access the underlying data, because the WebGPU EP does not allow clients to access underlying tensors directly. [1] https://chromium-review.googlesource.com/c/chromium/src/+/6972837 Bug: 445971854 Change-Id: Iff08fde488117c2c9dabbe7a7bb66d53f850726d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7088044 Reviewed-by: Rafael Cintron <[email protected]> Reviewed-by: Hu, Ningxin <[email protected]> Commit-Queue: Wang, Wei4 <[email protected]> Cr-Commit-Position: refs/heads/main@{#1549642}
1 parent 6bfc921 commit 1b59c6e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

webnn/conformance_tests/tensor.https.any.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,28 @@ const testDispatchTensor = (testName) => {
13301330
mlContext, outputTensor,
13311331
new Float32Array(sizeOfShape(shape)).fill(1.0));
13321332
}, `${testName} / same constant multiple graphs`);
1333+
1334+
promise_test(async () => {
1335+
// Construct a simple graph: OUTPUT = IDENTITY(INPUT) to test whether the default
1336+
// tensor is initialized to zero.
1337+
const builder = new MLGraphBuilder(mlContext);
1338+
const inputOperand = builder.input('input', {dataType: 'int32', shape: [1024]});
1339+
const graph = await builder.build({'output': builder.identity(inputOperand)});
1340+
1341+
const inputTensor = await mlContext.createTensor({
1342+
dataType: inputOperand.dataType,
1343+
shape: inputOperand.shape
1344+
});
1345+
1346+
const outputTensor = await mlContext.createTensor({
1347+
dataType: inputOperand.dataType,
1348+
shape: inputOperand.shape,
1349+
readable: true
1350+
});
1351+
1352+
mlContext.dispatch(graph, {'input': inputTensor}, {'output': outputTensor});
1353+
await assert_tensor_data_equals(mlContext, outputTensor, new Uint32Array(1024));
1354+
}, `${testName} / default tensor uninitialized`);
13331355
};
13341356

13351357
/**

0 commit comments

Comments
 (0)