mirror of https://github.com/commaai/tinygrad.git
move mul consts like add consts (#6684)
This commit is contained in:
parent
de259e3f09
commit
84072166db
|
@ -505,6 +505,9 @@ constant_folder = PatternMatcher([
|
|||
# ** move add consts to end (NOTE: this is still happening before constant folding) **
|
||||
(UPat(UOps.ALU, arg=BinaryOps.ADD, src=(UPat.cvar("c1"), UPat.var("x"))), lambda c1,x: x+c1 if x.op not in (UOps.CONST, UOps.VCONST) else None),
|
||||
(UPat(UOps.ALU, arg=BinaryOps.ADD, src=(UPat.var("x"), UPat.cvar("c1"))) + UPat.var("y"), lambda x,c1,y: (x+y)+c1),
|
||||
# ** move mul consts to end (NOTE: this is still happening before constant folding) **
|
||||
(UPat(UOps.ALU, arg=BinaryOps.MUL, src=(UPat.cvar("c1"), UPat.var("x"))), lambda c1,x: x*c1 if x.op not in (UOps.CONST, UOps.VCONST) else None),
|
||||
(UPat(UOps.ALU, arg=BinaryOps.MUL, src=(UPat.var("x"), UPat.cvar("c1"))) * UPat.var("y"), lambda x,c1,y: (x*y)*c1),
|
||||
])
|
||||
|
||||
# *** uop expander ***
|
||||
|
|
Loading…
Reference in New Issue