mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-06-24 02:14:17 +00:00
const assert
This commit is contained in:
parent
c4d1792edf
commit
4fb29cc0c4
1 changed files with 1 additions and 0 deletions
|
|
@ -493,6 +493,7 @@ class UOp(OpMixin, metaclass=UOpMetaClass):
|
|||
return UOp(op, out_dtype, all_srcs, **kwargs)
|
||||
@staticmethod
|
||||
def const(dtype:DType, b:ConstLike, device:str|tuple[str, ...]|None=None, shape:tuple[sint, ...]|None=None):
|
||||
if shape == (): assert dtype.count == 1, "if shape is () you can't have a vec dtype"
|
||||
if isinstance(b, UOp): return b.unbind()[0] if b.op is Ops.BIND else b
|
||||
if isinstance(b, tuple) and all_same(b):
|
||||
assert len(b) > 0, "can't create const from empty tuple"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue