Ghosts381937 opened a new pull request, #17765:
URL: https://github.com/apache/tvm/pull/17765
### Description
Update the floormod simplification rule to correctly handle expressions of
the form floormod(c1\*x, c2\*x) by simplifying them to floormod(c1, c2). This
enhancement enables better optimization of expressions that contain common
factors, which frequently appear in transformer model computations.
### Test Case
```py
from tvm import tir
from tvm.arith import Analyzer
from tvm.tir.op import floormod
# Define symbolic variable
past_decoder_sequence_length = tir.Var("past_decoder_sequence_length",
"int64")
# Create expressions with common factor
expr = tir.IntImm("int64", 64) * (past_decoder_sequence_length +
tir.IntImm("int64", 1))
divisor = tir.IntImm("int64", 31) * (past_decoder_sequence_length +
tir.IntImm("int64", 1))
# Create Analyzer
analyzer = Analyzer()
# Before: returns unsimplified expression
# After: correctly simplifies to 2
print(analyzer.simplify(floormod(expr, divisor)))
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]