Skip to content

Commit

Permalink
[WebNN EP] WebNN CPU backend only support up to 4 Split outputs (micr…
Browse files Browse the repository at this point in the history
  • Loading branch information
Honry authored Apr 19, 2024
1 parent 4d1963c commit 7c80c39
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions onnxruntime/core/providers/webnn/builders/impl/split_op_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SplitOpBuilder : public BaseOpBuilder {
// Operator support related.
private:
bool IsOpSupportedImpl(const InitializedTensorSet& initializers, const Node& node,
const WebnnDeviceType /* device_type */, const logging::Logger& logger) const override;
const WebnnDeviceType device_type, const logging::Logger& logger) const override;
};

// Add operator related.
Expand Down Expand Up @@ -94,7 +94,7 @@ Status SplitOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder,

bool SplitOpBuilder::IsOpSupportedImpl(const InitializedTensorSet& initializers,
const Node& node,
const WebnnDeviceType /* device_type */,
const WebnnDeviceType device_type,
const logging::Logger& logger) const {
const auto& input_defs = node.InputDefs();
std::vector<int64_t> input_shape;
Expand Down Expand Up @@ -126,6 +126,10 @@ bool SplitOpBuilder::IsOpSupportedImpl(const InitializedTensorSet& initializers,
LOGS(logger, VERBOSE) << "Cannot get split.";
return false;
}
if (split.size() > 4 && device_type == WebnnDeviceType::CPU) {
LOGS(logger, VERBOSE) << "WebNN CPU backend only supports up to 4 outputs.";
return false;
}
} else {
if (helper.HasAttr("num_outputs")) {
// Split has 'num_outputs' attribute when opset is 18.
Expand All @@ -134,6 +138,10 @@ bool SplitOpBuilder::IsOpSupportedImpl(const InitializedTensorSet& initializers,
LOGS(logger, VERBOSE) << "The 'num_outputs' must be a positive integer.";
return false;
}
if (num_outputs > 4 && device_type == WebnnDeviceType::CPU) {
LOGS(logger, VERBOSE) << "WebNN CPU backend only supports up to 4 outputs.";
return false;
}
} else {
const auto opset = node.SinceVersion();
if (opset >= 18) {
Expand Down

0 comments on commit 7c80c39

Please sign in to comment.