mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-27 20:02:15 +00:00
Set Transpose Attribute instead for manipulating MatMul Strides (#21927)
### Description Update DML EP for `FusedMatMul` ORT graph node have TransA/B attribute set instead of updating the strides. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->
This commit is contained in:
parent
bd60add8ce
commit
73b5c3354c
3 changed files with 6 additions and 13 deletions
|
|
@ -36,9 +36,9 @@ public:
|
|||
"Two inputs should have same rank and rank >= 3 if transBatchA or transBatchB is true");
|
||||
}
|
||||
|
||||
auto [sizesA, stridesA] = OperatorHelper::GetFusedMatMulSizesAndStrides(inputShape0, transBatchA, transA);
|
||||
auto [sizesA, stridesA] = OperatorHelper::GetFusedMatMulSizesAndStrides(inputShape0, transBatchA);
|
||||
|
||||
auto [sizesB, stridesB] = OperatorHelper::GetFusedMatMulSizesAndStrides(inputShape1, transBatchB, transB);
|
||||
auto [sizesB, stridesB] = OperatorHelper::GetFusedMatMulSizesAndStrides(inputShape1, transBatchB);
|
||||
|
||||
OperatorHelper::FusedMatMulShapeMapping(sizesA, stridesA, sizesB, stridesB, outputShape);
|
||||
|
||||
|
|
@ -67,8 +67,8 @@ public:
|
|||
gemmDesc.BTensor = &inputDescs[1];
|
||||
gemmDesc.CTensor = nullptr;
|
||||
gemmDesc.OutputTensor = &outputDescs[0];
|
||||
gemmDesc.TransA = DML_MATRIX_TRANSFORM_NONE;
|
||||
gemmDesc.TransB = DML_MATRIX_TRANSFORM_NONE;
|
||||
gemmDesc.TransA = (transA && inputShape0.size() != 1 ? DML_MATRIX_TRANSFORM_TRANSPOSE : DML_MATRIX_TRANSFORM_NONE);
|
||||
gemmDesc.TransB = (transB && inputShape1.size() != 1 ? DML_MATRIX_TRANSFORM_TRANSPOSE : DML_MATRIX_TRANSFORM_NONE);
|
||||
gemmDesc.Alpha = alpha;
|
||||
gemmDesc.Beta = 0.0f;
|
||||
gemmDesc.FusedActivation = fusedActivation ? &fusedActivationDmlDesc : nullptr;
|
||||
|
|
|
|||
|
|
@ -606,8 +606,7 @@ namespace OperatorHelper
|
|||
|
||||
std::pair<std::vector<uint32_t>, std::vector<uint32_t>> GetFusedMatMulSizesAndStrides(
|
||||
gsl::span<const uint32_t> sizes,
|
||||
int32_t transBatch,
|
||||
int32_t transpose)
|
||||
int32_t transBatch)
|
||||
{
|
||||
const uint32_t dimensionCount = gsl::narrow_cast<uint32_t>(sizes.size());
|
||||
std::vector<uint32_t> newStrides(dimensionCount);
|
||||
|
|
@ -633,11 +632,6 @@ namespace OperatorHelper
|
|||
std::rotate(newStrides.begin(), newStrides.begin() + 1, newStrides.end() - 1);
|
||||
}
|
||||
|
||||
if (transpose && dimensionCount > 1)
|
||||
{
|
||||
std::swap(newStrides[dimensionCount - 2], newStrides[dimensionCount - 1]);
|
||||
std::swap(newSizes[dimensionCount - 2], newSizes[dimensionCount - 1]);
|
||||
}
|
||||
|
||||
return std::make_pair(newSizes, newStrides);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -285,8 +285,7 @@ void FusedMatMulShapeMapping(
|
|||
|
||||
std::pair<std::vector<uint32_t>, std::vector<uint32_t>> GetFusedMatMulSizesAndStrides(
|
||||
gsl::span<const uint32_t> sizes,
|
||||
int32_t transBatch = 0,
|
||||
int32_t transpose = 0);
|
||||
int32_t transBatch = 0);
|
||||
|
||||
class GetOutputShapeAsInputShapeHelper
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue