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() {
88
88
for (const auto & pair : GetInitializerTensors ()) {
89
89
const auto & tensor = *pair.second ;
90
90
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 ()))
93
98
continue ;
94
99
95
- const auto & shape = tensor.dims ();
96
100
std::vector<int32_t > dims;
97
101
// When the shape is empty, it is scalar initializer that dims = {};
98
102
std::transform (shape.cbegin (), shape.cend (),
You can’t perform that action at this time.
0 commit comments