Skip to content

Commit 13fcfa6

Browse files
Honryankitm3k
authored andcommitted
Fixed a minor bug in layout transformation for Resize (microsoft#21954)
Since opset 18, 'scales' and 'sizes' constant inputs can be 2D tensors, transpose for 2D tensors are not supported at current implementation, fix it by only allowing 4D constant inputs.
1 parent 888abb3 commit 13fcfa6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

onnxruntime/core/optimizer/layout_transformation/layout_transformation.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ Status TransformLayoutForEP(Graph& graph, bool& modified, const IExecutionProvid
177177
for (size_t i = 2; i < node->Inputs().size(); i++) {
178178
auto constant = api_graph->GetConstant(node->Inputs()[i]);
179179
if (constant != nullptr && constant->Data().size() > 0) {
180-
input_perms.push_back(&input_perm);
180+
// Starting from opset version 18, the 'scales' and 'sizes' can be any length up to the input rank.
181+
// However, our current implementation only supports the transposition of 4D tensors.
182+
if (constant->NumElements() == 4) {
183+
input_perms.push_back(&input_perm);
184+
}
181185
} else {
182186
// TODO: Fix inconsistency. We should Transpose the non-const inputs so that the result of our changes
183187
// is consistent - all layout specific inputs are in NHWC format when we're done.

0 commit comments

Comments
 (0)