Skip to content

Commit

Permalink
[WebNN EP] Remove workaround for dynamic shape (microsoft#17644)
Browse files Browse the repository at this point in the history
As now we have the FreeDimensionOverrides option to support dynamic
shape, we can remove the previous
workaround.
  • Loading branch information
Honry authored Sep 22, 2023
1 parent e70a23f commit ce287a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 5 additions & 2 deletions onnxruntime/core/providers/webnn/builders/helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ bool IsInputSupported(const NodeArg& input, const std::string& parent_name, cons
}

for (const auto& dim : shape_proto->dim()) {
// For now we workaround dynamic shape support by assuming 1.
// WebNN doesn't support dynamic shape - use sessionOptions.freeDimensionOverrides to fix the shape.
if (!dim.has_dim_value()) {
LOGS(logger, VERBOSE) << "Dynamic shape is not supported for now, assume to be 1, for input:" << input_name;
LOGS(logger, VERBOSE) << "Dynamic shape is not supported, "
<< "use sessionOptions.FreeDimensionOverrides to set a fixed shape for input: "
<< input_name;
return false;
}
}

Expand Down
9 changes: 3 additions & 6 deletions onnxruntime/core/providers/webnn/builders/model_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,9 @@ Status ModelBuilder::RegisterModelInputOutput(const NodeArg& node_arg, bool is_i
} else {
dims.reserve(shape.size());
for (const auto& dim : shape) {
if (!dim.has_dim_value()) {
// FIXME: support dyanmic shape.
dims.push_back(1);
} else {
dims.push_back(SafeInt<int32_t>(dim.dim_value()));
}
// dim_param free dimensions should have already been excluded by IsInputSupported().
assert(dim.has_dim_value());
dims.push_back(SafeInt<int32_t>(dim.dim_value()));
}
}
}
Expand Down

0 comments on commit ce287a4

Please sign in to comment.