mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-08-29 14:56:06 +00:00
make ASSIGN arg optional [pr] (#7966)
This commit is contained in:
@@ -82,7 +82,7 @@ class LazyBuffer(MathTrait):
|
||||
def assign(self, x:LazyBuffer) -> LazyBuffer:
|
||||
assert x.size == self.size, f"assign target must have same size {self.size=} != {x.size=}"
|
||||
assert self.is_realized, f"assign target must be realized {self}"
|
||||
return LazyBuffer.metaop(Ops.ASSIGN, self.shape, self.dtype, self.device, arg=() if self.st.contiguous else (self.st,),
|
||||
return LazyBuffer.metaop(Ops.ASSIGN, self.shape, self.dtype, self.device, arg=None if self.st.contiguous else self.st,
|
||||
src=(self.base, x), enable_cache=True)
|
||||
|
||||
def can_view(self):
|
||||
|
||||
@@ -131,7 +131,7 @@ def merge_double_reduce(root:UOp, first_reduce:UOp) -> UOp:
|
||||
view_right = merge_views+PatternMatcher([
|
||||
# ASSIGN can override st
|
||||
(UPat(Ops.STORE, src=(UPat.var("b"), UPat.var("st"), UPat(Ops.ASSIGN, name="a"))),
|
||||
lambda a,b,st: UOp.store(b, (a.arg[0]+st.arg).to_uop(), a.replace(arg=())) if a.arg else None),
|
||||
lambda a,b,st: None if a.arg is None else UOp.store(b, (a.arg+st.arg).to_uop(), a.replace(arg=None))),
|
||||
# non contiguous VIEW on a reduce creates a new VIEW
|
||||
(UPat(Ops.REDUCE_AXIS, src=(UPat.var("src"),), name="r").view(name="v"), lambda v,r,src: None if v.st.contiguous else swizzle_r(r, src, v.st)),
|
||||
# push a VIEW down to STORE, through a reduce (ONLY reshapes)
|
||||
|
||||
Reference in New Issue
Block a user