mlir icon indicating copy to clipboard operation
mlir copied to clipboard

AffineApplyNormalizer::renumber returns invalid map

Open bondhugula opened this issue 6 years ago • 4 comments

AffineApplyNormalizer::renumber isn't a publicly exposed method - it however generates invalid maps in some cases. Reproduce with two normalizers created with the maps below:

( )[s0] -> (s0) (%v1) ( )[s0] -> (s0) (%v2)

Calling renumber on the first with the second as argument yields: ( ) (s0) -> (s1) // invalid

The expressions it generates are correct, but the returned map's input dim/symbol count is incorrect (one instead of two here).

https://github.com/tensorflow/mlir/blob/d4e60ddaa853fd5954864a0165773314a8981de4/lib/AffineOps/AffineOps.cpp#L276

bondhugula avatar Aug 18 '19 12:08 bondhugula

@nicolasvasilache I think the last line of AffineApplyNormalizer::renumber should have been

return map.replaceDimsAndSymbols(dimRemapping, symRemapping,
                                   reorderedDims.size(),
                                   concatenatedSymbols.size());

instead of

return map.replaceDimsAndSymbols(dimRemapping, symRemapping,
                                   dimRemapping.size(), symRemapping.size())

?

https://github.com/tensorflow/mlir/blob/d4e60ddaa853fd5954864a0165773314a8981de4/lib/AffineOps/AffineOps.cpp#L337

It doesn't affect any of the current test cases, but I think that's the bug here that may cause incorrect behavior if someone adds another helper method that reuses renumber.

bondhugula avatar Aug 23 '19 16:08 bondhugula

Thanks for your bug report, I am out till the middle of next week, I'll address when I come back.

On Fri, Aug 23, 2019, 12:40 PM Uday Bondhugula [email protected] wrote:

@nicolasvasilache https://github.com/nicolasvasilache I think the last line of AffineApplyNormalizer::renumber should have been

return map.replaceDimsAndSymbols(dimRemapping, symRemapping, reorderedDims.size(), concatenatedSymbols.size());

instead of

return map.replaceDimsAndSymbols(dimRemapping, symRemapping, dimRemapping.size(), symRemapping.size())

?

https://github.com/tensorflow/mlir/blob/d4e60ddaa853fd5954864a0165773314a8981de4/lib/AffineOps/AffineOps.cpp#L337

It doesn't affect any of the current test cases, but I think that's the bug here that may cause incorrect behavior if someone adds another helper method that reuses renumber.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/mlir/issues/89?email_source=notifications&email_token=ACNNU5FSZM3U5ZF2ZJ7JCBTQGAHIZA5CNFSM4IMSSR5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5AXFMY#issuecomment-524382899, or mute the thread https://github.com/notifications/unsubscribe-auth/ACNNU5CBCNWY2IGRV5YTMFLQGAHIZANCNFSM4IMSSR5A .

nicolasvasilache avatar Aug 26 '19 20:08 nicolasvasilache

Oops, sorry my bad. Didn't notice @nicolasvasilache is OOO since this week. Reassigning to @andydavis1.

antiagainst avatar Aug 26 '19 23:08 antiagainst

Somehow I cannot set @andydavis1 as the assignee. So just @ here.

antiagainst avatar Aug 26 '19 23:08 antiagainst