Skip to content

Commit 9ce61be

Browse files
adrastogiAditya Rastogi
andauthored
Address DML crashes in WebNN QDQ subgraph tests (#26822)
### Description <!-- Describe your changes. --> This change proposes a fix to some DML crashes observed in WebNN QDQ subgraph tests. The root cause of the problem as analyzed in the issue linked below is that the DML EP does not have kernels implemented for the QLinear versions of LeakyRelu and Softmax. The QDQ transformer has logic to fuse a 3-node sequence in the graph to the associated QLinear custom op. There is an operator registry which contains the mapping between EPs and the ops that the transformer consults for computing the quantized variants. The registry currently has the CPU and DML EPs supporting the same sets of operators (thereby assuming that the fused node would also be supported by the EP), so what I did was split out a separate registration for the LeakyRelu and Softmax ops and associate them with the CPU EP, while removing those ops from the prior list. I was trying to also explore other options like seeing if I could somehow check to see if the EP has a supported kernel for the op before proceeding with the assignment- I could not figure out a way to do this, though. I validated this change by building a private version of ORT and running the affected tests in Edge Canary. The crash did not occur for those tests with the fix in place. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> This bug causes crashes in the web browser's GPU sandbox process, which is a blocker for WebNN origin trials. The crashes need to be resolved. Fixes #26531. --------- Co-authored-by: Aditya Rastogi <adityar@ntdev.microsoft.com>
1 parent 9f95908 commit 9ce61be

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

onnxruntime/core/optimizer/qdq_transformer/selectors_actions/qdq_selector_action_transformer.cc

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,21 +145,34 @@ void UnaryOpQDQRules(SelectorActionRegistry& qdq_selector_action_registry) {
145145
// 3 nodes. DQ, target, Q
146146
// Replace with internal QLinear version of operator. Delete all original nodes.
147147
const std::string action_name{"1DQ"};
148+
const std::string cpu_action_name{"1DQ_CPU"};
148149
std::unique_ptr<Action> action = std::make_unique<QDQ::UnaryReplaceWithQLinear>(kMSDomain);
150+
std::unique_ptr<Action> cpu_action = std::make_unique<QDQ::UnaryReplaceWithQLinear>(kMSDomain);
149151

150152
#if !defined(ORT_MINIMAL_BUILD)
153+
// Operators with DML QLinear kernel support (QLinearAveragePool, QLinearGlobalAveragePool, QLinearSigmoid)
151154
std::vector<const char*> providers = {kCpuExecutionProvider, kDmlExecutionProvider};
152155
std::unique_ptr<NodeSelector> selector = std::make_unique<QDQ::UnarySelector>(providers);
153156
qdq_selector_action_registry.RegisterSelectorAndAction(action_name,
154157
{{"AveragePool", {}},
155-
{"LeakyRelu", {}},
156158
{"GlobalAveragePool", {}},
157-
{"Sigmoid", {}},
158-
{"Softmax", {}}},
159+
{"Sigmoid", {}}},
159160
std::move(selector),
160161
std::move(action));
162+
163+
// Operators without DML QLinear kernel support (CPU only).
164+
// DML EP does not have QLinearLeakyRelu or QLinearSoftmax kernels.
165+
// See https://github.com/microsoft/onnxruntime/issues/26531
166+
std::vector<const char*> cpu_only_provider = {kCpuExecutionProvider};
167+
std::unique_ptr<NodeSelector> cpu_selector = std::make_unique<QDQ::UnarySelector>(cpu_only_provider);
168+
qdq_selector_action_registry.RegisterSelectorAndAction(cpu_action_name,
169+
{{"LeakyRelu", {}},
170+
{"Softmax", {}}},
171+
std::move(cpu_selector),
172+
std::move(cpu_action));
161173
#else
162174
qdq_selector_action_registry.RegisterAction(action_name, std::move(action));
175+
qdq_selector_action_registry.RegisterAction(cpu_action_name, std::move(cpu_action));
163176
#endif
164177
}
165178

0 commit comments

Comments
 (0)