This is an archive of the discontinued LLVM Phabricator instance.

[mlir][vector] Bring back `maxf`/`minf` reductions
ClosedPublic

Authored by unterumarmung on Aug 23 2023, 12:03 PM.

Details

Summary

This patch is part of a larger initiative aimed at fixing floating-point max and min operations in MLIR: https://discourse.llvm.org/t/rfc-fix-floating-point-max-and-min-operations-in-mlir/72671.

In line with the mentioned RFC, this patch tackles tasks 2.3 and 2.4.
It adds LLVM conversions for the maxf/minf reductions to the non-NaN-propagating LLVM intrinsics.

Depends on D158618

Diff Detail

Event Timeline

unterumarmung created this revision.Aug 23 2023, 12:03 PM
Herald added a reviewer: ftynse. · View Herald Transcript
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
unterumarmung requested review of this revision.Aug 23 2023, 12:03 PM
dcaballe accepted this revision.Aug 23 2023, 3:57 PM
dcaballe added a subscriber: mravishankar.

LGTM, thanks!

@mravishankar, if we convert vector.reduction<minimum/maximum> to vector.reduction<minf/maxf> after this patch, NVTX tests should work.

This revision is now accepted and ready to land.Aug 23 2023, 3:57 PM

Nice! Thanks @dcaballe and @unterumarmung . Is there a way we can land these patches and the conversion from the NaN propagating version to the non-NaN propagating version in vector dialect. Then we can address downstream issues before we do larger changes.

unterumarmung edited the summary of this revision. (Show Details)Aug 25 2023, 10:45 AM

Is there a way we can land these patches and the conversion from the NaN propagating version to the non-NaN propagating version in vector dialect. Then we can address downstream issues before we do larger changes.

Once these patches are applied, we'll end up with two sets of min/max reductions: m**f and m**imumf. The current issue revolves around the m**f reductions, as their lowering is unsupported by certain NVPTX backends. Once these patches are incorporated, the semantics and consequently the lowering of these reductions will shift towards a more conservative approach. This conservative approach has been a part of LLVM for a considerable amount of time. Hence, the older backends shouldn't encounter issues with this altered lowering strategy.

This revision was automatically updated to reflect the committed changes.