0

webnn: fix int32 quantizeLinear on CoreML and add test

Change-Id: I8c9f7d8098205d1f1772fcc75a18bd74a121ad5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6431631
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Phillis Tang <phillis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1442792}
This commit is contained in:
Phillis Tang
2025-04-04 11:33:04 -07:00
committed by Chromium LUCI CQ
parent d590e4ab07
commit 606a21adfe
2 changed files with 43 additions and 1 deletions
services/webnn/coreml
third_party/blink/web_tests/external/wpt/webnn/conformance_tests

@ -4798,7 +4798,11 @@ GraphBuilderCoreml::AddOperationForQuantizeLinear(
CHECK(context_properties_.data_type_limits.quantize_linear_zero_point
.data_types.Has(zero_point_operand_data_type));
// TODO(crbug.com/338529226): These params must all be constant tensors.
if (zero_point_operand_data_type == OperandDataType::kInt32 ||
zero_point_operand_data_type == OperandDataType::kUint32) {
return AddOperationForQuantizeLinearEmulate(operation, block);
}
if (!constant_operands_->contains(operation.zero_point_operand_id) ||
!constant_operands_->contains(operation.scale_operand_id)) {
return AddOperationForQuantizeLinearEmulate(operation, block);

@ -574,6 +574,44 @@ const quantizeLinearTests = [
}
}
}
},
{
'name': 'quantizeLinear int32 1D tensor with float32 scalar scale',
'graph': {
'inputs': {
'quantizeLinearInput': {
'data': [-22405.495643615723, 7391418.921366602],
'descriptor': {shape: [2], dataType: 'float32'},
'constant': false
},
'quantizeLinearScale': {
'data': [1.1202747821807861, 0.2800687253475189],
'descriptor': {shape: [2], dataType: 'float32'},
'constant': true
},
'quantizeLinearZeroPoint': {
'data': [32345, -2445234],
'descriptor': {shape: [2], dataType: 'int32'},
'constant': true
}
},
'operators': [{
'name': 'quantizeLinear',
'arguments': [
{'input': 'quantizeLinearInput'},
{'scale': 'quantizeLinearScale'},
{'zeroPoint': 'quantizeLinearZeroPoint'}
],
'outputs': 'quantizeLinearOutput'
}],
'expectedOutputs': {
'quantizeLinearOutput': {
'data': [12345, 23946213],
'descriptor': {shape: [2], dataType: 'int32'}
}
}
}
}
];