From 891175d5d66187798a6ea08c59e620fb1c1ca4c1 Mon Sep 17 00:00:00 2001 From: Patrice Vignola Date: Mon, 5 Oct 2020 19:30:00 +0000 Subject: [PATCH] Merged PR 5253310: Fix 0-sized dimension broadcasting Tensors that contain 0-sized dimensions were being broadcasted to higher dimensions, which would remove the possibility to remove them from the graph. 0-sized dimensions represent empty tensors, so whatever operator needs to broadcast it shouldn't try to call into DML. --- .../providers/dml/OperatorAuthorHelper/OperatorHelper.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp index d21daa36c3..c79a984b2b 100644 --- a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp +++ b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp @@ -550,6 +550,13 @@ namespace OperatorHelper ++inDim1Iter; } + // 0-sized dimensions indicate an empty tensor and shouldn't be broadcasted to higher dimensions + if (inDimension0 == 0 || inDimension1 == 0) + { + inDimension0 = 0; + inDimension1 = 0; + } + ML_CHECK_VALID_ARGUMENT((inDimension0 == inDimension1) || (inDimension0 == 1) || (inDimension1 == 1)); *outDimIter = std::max(inDimension0, inDimension1); }