csarofeen / pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration
http://pytorch.org
Other
26 stars 7 forks source link

Add new expr simplification pass distributeGcdRemainderDivMod #2543

Closed zasdfgbnm closed 1 year ago

zasdfgbnm commented 1 year ago

This pass helps View, Transpose, Welford, and Matmul. It does simplification like:

(a * 8 + 7) / 32  -->  (a * 8) / 32
(a * 8 + 7) % 32  -->  (a * 8) % 32 + 7

For the above example, other passes can further simplify the expr as:

(a * 8) / 32  -->  a / 4
(a * 8) % 32 + 7  -->  (a % 4) * 8 + 7

Example kernel diff:

zasdfgbnm commented 1 year ago

FIXME: in https://www.diffchecker.com/0rILZnqM/, why i17526 / i3683 is not simplified?