From 2c94316bd2ed9facaef069ec199f7151a49b1bae Mon Sep 17 00:00:00 2001 From: samm393 <48934811+samm393@users.noreply.github.com> Date: Mon, 29 Jul 2024 16:50:49 +0100 Subject: [PATCH] ull literal support and test (#5789) * ull literal support and test * missing .numpy() --- test/test_dtype.py | 5 ++++- tinygrad/renderer/cstyle.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test_dtype.py b/test/test_dtype.py index 872c46dac1..961aeade48 100644 --- a/test/test_dtype.py +++ b/test/test_dtype.py @@ -267,7 +267,10 @@ class TestInt32DType(TestDType): DTYPE = dtypes.int32 class TestUint32DType(TestDType): DTYPE = dtypes.uint32 class TestInt64DType(TestDType): DTYPE = dtypes.int64 -class TestUint64DType(TestDType): DTYPE = dtypes.uint64 +class TestUint64DType(TestDType): + DTYPE = dtypes.uint64 + def test_uint64_load(self): + assert Tensor(2**64 - 1, dtype=dtypes.uint64).numpy() == 2**64 - 1 class TestBoolDType(TestDType): DTYPE = dtypes.bool diff --git a/tinygrad/renderer/cstyle.py b/tinygrad/renderer/cstyle.py index b391fe3be1..76ab3c5a17 100644 --- a/tinygrad/renderer/cstyle.py +++ b/tinygrad/renderer/cstyle.py @@ -50,6 +50,7 @@ class CStyleLanguage(Renderer): elif math.isinf(x): val = ("-" if x < 0 else "") + "INFINITY" elif dtype.scalar() == dtypes.bool: val = "1" if x else "0" elif dtype.scalar() == dtypes.float: val = f"{x}f" + elif dtype.scalar() == dtypes.uint64: val = f"{x}ULL" else: val = str(x) if dtype.count > 1: return self.render_vectorize([val] * dtype.count, dtype) return (self.render_cast(val, dtype) if dtype not in [dtypes.float, dtypes.int, dtypes.bool] else val)