Skip to content

Commit 4817834

Browse files
a-sullychromium-wpt-export-bot
authored andcommitted
webnn: Fix WPT data type compatibility matching for constants
The existing code assumes that the supported data types for the input() and constant() methods are the same. This is not true on some platforms Cq-Include-Trybots: luci.chromium.try:win11-blink-rel,mac14-blink-rel,mac14.arm64-blink-rel Change-Id: Id0365b623500f9bdb815e3332c3e9cfe4689bf11 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6064547 Auto-Submit: Austin Sullivan <[email protected]> Commit-Queue: Phillis Tang <[email protected]> Reviewed-by: Phillis Tang <[email protected]> Cr-Commit-Position: refs/heads/main@{#1391227}
1 parent 0c731ef commit 4817834

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

webnn/resources/utils.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,14 @@ const createOperand = (context, builder, operandName, resources) => {
440440
const descriptor = resources.descriptor;
441441
const dataType = descriptor.dataType;
442442

443+
const supportedDataTypes = resources.constant ?
444+
context.opSupportLimits().constant.dataTypes :
445+
context.opSupportLimits().input.dataTypes;
446+
443447
// If input data type is not supported on current platform, attempt to use
444448
// a supported type to pass the data, then cast back to original type.
445-
if (!context.opSupportLimits().input.dataTypes.includes(dataType)) {
446-
const compatibleType =
447-
findCompatibleType(dataType, context.opSupportLimits().input.dataTypes);
449+
if (!supportedDataTypes.includes(dataType)) {
450+
const compatibleType = findCompatibleType(dataType, supportedDataTypes);
448451
if (compatibleType) {
449452
descriptor.castedType = compatibleType;
450453
descriptor.dataType = compatibleType;

0 commit comments

Comments
 (0)