forked from pytorch/pytorch
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[inductor] Stop using
x + tl.zeros(...)
in generated triton (pytorc…
…h#100163) For reductions, this changes the accumulator ```python _tmp2 = tl.zeros([XBLOCK, RBLOCK], tl.int8) + -128 ``` to ```python _tmp2 = tl.full([XBLOCK, RBLOCK], -128, tl.int32) ``` which is equivalent since addition does type promotion from `int8` to `int32` For constant indexing, this changes ```python tl.store(in_out_ptr0 + (0 + tl.zeros([XBLOCK, 1], tl.int32)), tmp4, None) ``` to ```python tl.store(in_out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp4, None) ``` For variable indexing, this changes ```python tl.store(out_ptr0 + (0 + tl.zeros([XBLOCK], tl.int32)), tmp1, None) ``` to ```python tl.store(out_ptr0 + (tl.broadcast_to(x0, [XBLOCK])), tmp1, None) ``` Pull Request resolved: pytorch#100163 Approved by: https://github.com/ngimel
- Loading branch information
1 parent
270a331
commit 5b98910
Showing
1 changed file
with
38 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters