Open Abhishek-Varma opened 1 year ago
But turns out that the current AtenViewOp's implementation seems to be reinventing the wheel for deciphering ReassociationIndices - I'll have to go through it a bit to make a generic patch.
Yeah, the AtenViewOp
conversion pattern has become quite complex. Any simplifications to it are definitely welcomed!
Ideally all the negative dimension indexing should be normalized. Is there any such pass currently in torch-mlir that's supposed to take care of this? If there isn't, I believe it's worth investing an effort on this front
Yes, all negative dimensions should be properly converted to positive dimensions in torch-mlir when converting to one of the three backends. All patterns converting to one of the three backends should being doing such transformations using the helpers toPositiveDim
and isValidDim
, but it's possible that some ops do not have such handling.
After addressing the above, I saw two instances where negative dimensions were being an issue in the LLVM pipeline :-
DimOfReifyRankedShapedTypeOpInterface. FoldDimOfExpandShape.
Raised a PR : https://github.com/llvm/torch-mlir/pull/2013 to deal with negative dimensions.
Solved this aforementioned part - no need to patch things up at llvm-project
.
createLinalgPayloadCalculationForGatherOps needs special mention here because this function especially led to all the red-herring issues at llvm-project
.
Working on addressing AtenViewOp
next.
Input MLIR :-
On passing it through
--convert-torch-to-linalg
, following error is thrown :-With a fix I have the correct IR gets generated :
%expanded = tensor.expand_shape %collapsed [[0, 1, 2]] : tensor<4096xf16> into tensor<1x4096x1xf16>
(Observe thereassociation
map here)But turns out that the current AtenViewOp's implementation seems to be reinventing the wheel for deciphering
ReassociationIndices
- I'll have to go through it a bit to make a generic patch.This is needed to for ToMe's Support - I believe I should anyway work on raising a patch for the fix.
After addressing the above, I saw two instances where negative dimensions were being an issue in the LLVM pipeline :-
DimOfReifyRankedShapedTypeOpInterface
.FoldDimOfExpandShape
.I've patched them up as well, but two things here :-
externals/llvm-project
. Let me know your thoughts here, I'd accordingly raise patch forllvm-project
separately.torch-mlir
that's supposed to take care of this? If there isn't, I believe it's worth investing an effort on this front.@powderluv @ramiro050