Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: common simplifications #208

Merged
merged 8 commits into from
Jan 2, 2025
Merged

feat: common simplifications #208

merged 8 commits into from
Jan 2, 2025

Conversation

avik-pal
Copy link
Collaborator

@avik-pal avik-pal commented Dec 31, 2024

  • a + (-b) => a - b if -b isn't used anywhere
  • <op>(transpose(a), transpose(b)) => transpose(<op>(a, b)) if only use
  • <op>(transpose(a), cst) => transpose(<op>(a, transposed_cst))
  • no_nan simplifications
    • a - a => 0
    • c = a + b; d = c - b => d = a
    • c = a + b; d = b - c => d = -a

@avik-pal
Copy link
Collaborator Author

@wsmoses is a - a to 0 for floats not a valid transform? There is a is integer check in SubSimplify

    if (isa<IntegerType>(op.getType().getElementType()) &&
        op.getLhs() == op.getRhs()) {

@wsmoses
Copy link
Member

wsmoses commented Dec 31, 2024

To be compliant it might also require checking it isn't nan (or enabling the equivalent of fast math)

@avik-pal
Copy link
Collaborator Author

does stablehlo provide fast math flags? arith seems to provide but can't find anything in stablehlo specs

@wsmoses
Copy link
Member

wsmoses commented Dec 31, 2024

No we've usually been just parameterizing the canonicalizations here where relevant (eg search for like using or something)

@wsmoses
Copy link
Member

wsmoses commented Dec 31, 2024

@avik-pal avik-pal force-pushed the ap/common_simplifications branch 5 times, most recently from ff7d754 to af99cdf Compare January 1, 2025 16:22
@avik-pal avik-pal force-pushed the ap/common_simplifications branch from 721156d to 3cac288 Compare January 2, 2025 00:27
@avik-pal avik-pal marked this pull request as ready for review January 2, 2025 00:51
@avik-pal avik-pal requested a review from wsmoses January 2, 2025 00:51
@wsmoses wsmoses merged commit a8451f9 into main Jan 2, 2025
6 of 10 checks passed
@wsmoses wsmoses deleted the ap/common_simplifications branch January 2, 2025 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants