mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-21 21:52:11 +00:00
[WebNN EP] Update Prelu restriction for CPU backend (#20878)
This commit is contained in:
parent
55f7f9d7a9
commit
0c80cd2157
2 changed files with 15 additions and 6 deletions
|
|
@ -59,7 +59,7 @@ operators and the supported opset domain/versions in **WebNN EP** by ONNX Runtim
|
|||
| Not | ai.onnx(7+) | logicalnot | ✓ | ✓ | |
|
||||
| Pad | ai.onnx(7-10, 11-12, 13-17, 18, 19-20, 21+) | pad | ✓ | ✓ | modes == 'wrap' is not supported |
|
||||
| Pow | ai.onnx(7-11, 12, 13-14, 15+) | pow | ✓ | ✓ | |
|
||||
| PRelu | ai.onnx(7-8, 9-15, 16+) | prelu | ✓ | ✓ | WebNN CPU restricts slope to be a static value |
|
||||
| PRelu | ai.onnx(7-8, 9-15, 16+) | prelu | ✓ | ✓ | WebNN CPU backend restricts the last dimension of input and slope to be same (Chromium issue: https://issues.chromium.org/issues/335517470) |
|
||||
| Reciprocal | ai.onnx(7-12, 13+) | reciprocal | ✗ | ✓ | |
|
||||
| ReduceL1 | ai.onnx(7-10, 11-12, 13-17, 18+) | reduceL1 | ✗ | ✓ | Input 'axes' if present should be a constant |
|
||||
| ReduceL2 | ai.onnx(7-10, 11-12, 13-17, 18+) | reduceL2 | ✗ | ✓ | Input 'axes' if present should be a constant |
|
||||
|
|
|
|||
|
|
@ -63,14 +63,23 @@ bool BinaryOpBuilder::IsOpSupportedImpl(const InitializedTensorSet& initializers
|
|||
const auto& input_defs = node.InputDefs();
|
||||
const auto& op_type = node.OpType();
|
||||
|
||||
// XNNPACK prelu operator expects slope to be a static value.
|
||||
// https://github.com/google/XNNPACK/issues/4692
|
||||
// TODO: Remove this check after it is solved.
|
||||
if (op_type == "PRelu" && !Contains(initializers, input_defs[1]->Name()) && device_type == WebnnDeviceType::CPU) {
|
||||
LOGS(logger, VERBOSE) << "The second input (slope) for PRelu must be a constant initializer for WebNN CPU backend.";
|
||||
std::vector<int64_t> input0_shape;
|
||||
std::vector<int64_t> input1_shape;
|
||||
if (!GetShape(*input_defs[0], input0_shape, logger) ||
|
||||
!GetShape(*input_defs[1], input1_shape, logger)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 'prelu' op in WebNN CPU backend restricts the last dimension of input and slope to be same.
|
||||
// TODO: Remove this workaround once the associated issue is resolved in Chromium:
|
||||
// https://issues.chromium.org/issues/335517470.
|
||||
if (op_type == "PRelu" && device_type == WebnnDeviceType::CPU) {
|
||||
if (input0_shape.back() != input1_shape.back()) {
|
||||
LOGS(logger, VERBOSE) << "The last dimension of input and slope for PRelu must be same for WebNN CPU backend.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue