Skip to content

Commit 1d4b161

Browse files
Honryfdwr
andauthored
[WebNN EP] Support ConvTranspose for TFLite backend (#21291)
### Description Chromium supports ConvTranspose for TFLite in https://chromium-review.googlesource.com/c/chromium/src/+/5635194 With constraint that only default dilations and groups are supported. --------- Co-authored-by: Dwayne Robinson <[email protected]>
1 parent e7aa116 commit 1d4b161

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

Diff for: js/web/docs/webnn-operators.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ operators and the supported opset domain/versions in **WebNN EP** by ONNX Runtim
2222
| Clip | ai.onnx(7-10, 11, 12, 13+) | clamp ||| WebNN CPU backend only supports 3 specific ranges: [0.0, infinity], [-1.0, 1.0], [0.0, 6.0] (Chromium issue: https://issues.chromium.org/issues/326156496) |
2323
| Concat | ai.onnx(7-10, 11-12, 13+) | concat ||| |
2424
| Conv | ai.onnx(7-10, 11+) | conv2d ||| Only supports 3-D or 4-D input and 'W' (weight) |
25-
| ConvTranspose | ai.onnx(7-10, 11+) | convTranspose2d | || Only supports 3-D or 4-D input and 'W' (weight). |
25+
| ConvTranspose | ai.onnx(7-10, 11+) | convTranspose2d | || Only supports 3-D or 4-D input and 'W' (weight). WebNN CPU backend only supports default dilations and group |
2626
| Cos | ai.onnx(7+) | cos ||| |
2727
| Div | ai.onnx(7-12, 13, 14+) | div ||| |
2828
| Elu | ai.onnx(7+) | elu ||| WebNN CPU backend only supports 'alpha' value is 1.0 |

Diff for: onnxruntime/core/providers/webnn/builders/helper.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static const InlinedHashMap<std::string, WebnnOpInfo> op_map = {
167167
{"Concat", {"concat", true}},
168168
{"Conv", {"conv2d", true}},
169169
{"ConvInteger", {"conv2dInteger", false}},
170-
{"ConvTranspose", {"convTranspose2d", false}},
170+
{"ConvTranspose", {"convTranspose2d", true}},
171171
{"Cos", {"cos", true}},
172172
{"Div", {"div", true}},
173173
{"DequantizeLinear", {"dequantizeLinear", false}},

Diff for: onnxruntime/core/providers/webnn/builders/impl/conv_op_builder.cc

+16
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,22 @@ bool ConvOpBuilder::HasSupportedInputsImpl(const Node& node, const WebnnDeviceTy
427427
return false;
428428
}
429429

430+
// WebNN CPU backend (TFLite) only supports default dilations and group.
431+
// https://source.chromium.org/chromium/chromium/src/+/main:services/webnn/tflite/graph_builder_tflite.cc;l=1040
432+
if (device_type == WebnnDeviceType::CPU && op_type == "ConvTranspose") {
433+
NodeAttrHelper helper(node);
434+
const auto dilations = helper.Get("dilations", std::vector<int64_t>{1, 1});
435+
const auto group = helper.Get("group", 1);
436+
if (dilations[0] != 1 || (dilations.size() > 1 && dilations[1] != 1)) {
437+
LOGS(logger, VERBOSE) << op_type << " for WebNN CPU backend only supports default dilation 1.";
438+
return false;
439+
}
440+
if (group != 1) {
441+
LOGS(logger, VERBOSE) << op_type << " for WebNN CPU backend only supports default group 1.";
442+
return false;
443+
}
444+
}
445+
430446
return true;
431447
}
432448

0 commit comments

Comments
 (0)