[DML EP] Restrict MatMul to 4D #26583
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✋⏸️ Pause review for now, as there are some test failures:
Description
Fixes #26529. 5D or greater inputs are unsupported by DML's
DML_GEMM_OPERATOR_DESC(supports 2D to 4D), and so higher ranks need to be reduced to 4D, which is achieved by folding any leading dimensions into the first dimension. So a 5D shape of[3,4,5,6,7]becomes 4D[12,4,5,6,7]. Note this approach is not fully generic for all broadcasting cases (which would need DML support), as it doesn't support a mixture of both broadcasting and non-broadcasting in the leading batch dimensions (yielding an error), but it least supports cases where all the batch dimensions are broadcasted or none of the batch dimensions are broadcasted.{ "tests": [ { "graph_name": "MatMul float32 5D", "op_type": "MatMul", "version": 1, "A": [[[[[1, 2, 3], [4, 5, 6]]]], [[[[2, 3, 4], [5, 6, 7]]]]], "B": [[[[[1, 2], [3, 4], [5, 6]]]], [[[[2, 3], [4, 5], [6, 7]]]]], "Y": [[[[[22, 28], [49, 64]]]], [[[[40, 49], [76, 94]]]]], "T": "float32" }