File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
onnxruntime/core/providers/webnn/builders Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -88,11 +88,15 @@ Status ModelBuilder::RegisterInitializers() {
8888 for (const auto & pair : GetInitializerTensors ()) {
8989 const auto & tensor = *pair.second ;
9090 const auto & name = tensor.name ();
91- // Optional tensors can be indicated by an empty name, just ignore it.
92- if (name.empty () || Contains (skipped_initializers_, name))
91+ const auto & shape = tensor.dims ();
92+
93+ // Ignore the following tensors:
94+ // 1. Empty tensors: optional tensors can be indicated by an empty name.
95+ // 2. Tensors in skipped_initializers_: These are tensors that are not used as WebNN Constants.
96+ // Note: Scalar tensors are excluded because ONNX Runtime will optimize same scalar initializers into one.
97+ if (name.empty () || (Contains (skipped_initializers_, name) && !shape.empty ()))
9398 continue ;
9499
95- const auto & shape = tensor.dims ();
96100 std::vector<int32_t > dims;
97101 // When the shape is empty, it is scalar initializer that dims = {};
98102 std::transform (shape.cbegin (), shape.cend (),
You can’t perform that action at this time.
0 commit comments