forked from tinygrad/tinygrad
hotfix: use is for enum compare, a few more
This commit is contained in:
+4
-4
@@ -74,8 +74,8 @@ class LazyBuffer:
|
||||
if self.dtype == dtype: return self
|
||||
return create_lazybuffer(self.device, ShapeTracker.from_shape(self.shape), dtype, UnaryOps.CAST, (dtype, bitcast), (self,))
|
||||
|
||||
def is_unrealized_const(self): return not self.base.realized and self.base.op == LoadOps.CONST
|
||||
def is_unrealized_contiguous_const(self): return self.base == self and not self.base.realized and self.op == LoadOps.CONST
|
||||
def is_unrealized_const(self): return not self.base.realized and self.base.op is LoadOps.CONST
|
||||
def is_unrealized_contiguous_const(self): return self.base == self and not self.base.realized and self.op is LoadOps.CONST
|
||||
|
||||
def schedule(self, seen=None): return create_schedule([self], seen)
|
||||
|
||||
@@ -90,7 +90,7 @@ class LazyBuffer:
|
||||
if self.device == device: return self
|
||||
|
||||
# double COPY = one COPY
|
||||
if self.st.contiguous and self.size == self.base.size and not self.base.realized and self.base.op == LoadOps.COPY:
|
||||
if self.st.contiguous and self.size == self.base.size and not self.base.realized and self.base.op is LoadOps.COPY:
|
||||
return self.base.srcs[0].copy_to_device(device).reshape(self.st.shape)
|
||||
|
||||
# const doesn't have to be copied (issues with disk tensor)
|
||||
@@ -111,7 +111,7 @@ class LazyBuffer:
|
||||
srcs.append(root._view(s.base.contiguous_child[1]))
|
||||
else:
|
||||
srcs.append(s)
|
||||
assert all_same(dts:=[x.dtype.scalar() for x in (srcs if op != TernaryOps.WHERE else srcs[1:])]), f"all dtypes must match {dts} on {op}"
|
||||
assert all_same(dts:=[x.dtype.scalar() for x in (srcs[1:] if op is TernaryOps.WHERE else srcs)]), f"all dtypes must match {dts} on {op}"
|
||||
assert all_same([x.shape for x in srcs]), f"all shapes must be the same {[x.shape for x in srcs]}"
|
||||
if op is TernaryOps.WHERE: assert srcs[0].dtype == dtypes.bool, "TernaryOps.WHERE must have the first arg be bool"
|
||||
out_dtype = srcs[-1].dtype if op not in (BinaryOps.CMPLT, BinaryOps.CMPEQ) else dtypes.bool
|
||||
|
||||
Reference in New Issue
Block a user