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.
This commit is contained in:
Patrice Vignola 2020-10-05 19:30:00 +00:00
parent 3165d8045b
commit 891175d5d6

View file

@ -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);
}