From 54396f5cb3a03b36db08ca281c5d0346c05b32ef Mon Sep 17 00:00:00 2001 From: ttomsa Date: Sat, 20 Dec 2025 20:46:58 +0000 Subject: [PATCH] woops --- test/test_ops.py | 2 ++ tinygrad/helpers.py | 2 +- tinygrad/renderer/__init__.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/test_ops.py b/test/test_ops.py index 89e2db9583..87a24c7410 100644 --- a/test/test_ops.py +++ b/test/test_ops.py @@ -3053,6 +3053,7 @@ class TestOps(unittest.TestCase): helper_test_op([(32,10), (32,10)], lambda x,y: torch.nn.functional.binary_cross_entropy_with_logits(x,y.clip(0,1), pos_weight=torch.tensor(pos_weight)), lambda x,y: x.binary_crossentropy_logits(y.clip(0,1),pos_weight=Tensor(pos_weight))) + def test_cross_entropy_class_probabilities(self): helper_test_op([(32,), (32,)], lambda x,y: torch.nn.functional.cross_entropy(x, y), lambda x,y: x.cross_entropy(y)) helper_test_op([(32,10), (32,10)], lambda x,y: torch.nn.functional.cross_entropy(x, y), lambda x,y: x.cross_entropy(y)) @@ -3071,6 +3072,7 @@ class TestOps(unittest.TestCase): lambda x,y: x.cross_entropy(y, reduction=r)) self.helper_test_exception([(32,10), (32,10)], lambda x,y: torch.nn.functional.cross_entropy(x, y, reduction="typo"), lambda x,y: x.cross_entropy(y, reduction="typo"), expected=ValueError) + def test_cross_entropy_smoothing(self): for ls in (0., 0.3, 0.7, 1.): helper_test_op([(32,10), (32,10)], lambda x,y: torch.nn.functional.cross_entropy(x, y, label_smoothing=ls), diff --git a/tinygrad/helpers.py b/tinygrad/helpers.py index 324764b296..5033f93a2f 100644 --- a/tinygrad/helpers.py +++ b/tinygrad/helpers.py @@ -190,7 +190,7 @@ ALLOW_DEVICE_USAGE, MAX_BUFFER_SIZE = ContextVar("ALLOW_DEVICE_USAGE", 1), Conte EMULATE = ContextVar("EMULATE", "") CPU_COUNT = ContextVar("CPU_COUNT", max(1, len(os.sched_getaffinity(0)) if hasattr(os, "sched_getaffinity") else (os.cpu_count() or 1))) # Compilers -CPU_LLVM, CPU_LVP, AMD_LLVM = ContextVar("CPU_LLVM", 0), ContextVar("CPU_LVP", 0), ContextVar("AMD_LLVM", 0) +CPU_LLVM, CPU_X86, CPU_LVP, AMD_LLVM = ContextVar("CPU_LLVM", 0), ContextVar("CPU_X86", 0), ContextVar("CPU_LVP", 0), ContextVar("AMD_LLVM", 0) NV_PTX, CUDA_PTX, NV_NAK, QCOM_IR3 = ContextVar("NV_PTX", 0), ContextVar("CUDA_PTX", 0), ContextVar("NV_NAK", 0), ContextVar("QCOM_IR3", 0) NULL_IR3, NULL_NAK = ContextVar("NULL_IR3", 0), ContextVar("NULL_NAK", 0) AMD_CC, CPU_CC, NV_CC, CUDA_CC = ContextVar("AMD_CC", ""), ContextVar("CPU_CC", ""), ContextVar("NV_CC", ""), ContextVar("CUDA_CC", "") diff --git a/tinygrad/renderer/__init__.py b/tinygrad/renderer/__init__.py index fcf0787417..c63dbff3df 100644 --- a/tinygrad/renderer/__init__.py +++ b/tinygrad/renderer/__init__.py @@ -44,9 +44,9 @@ class Estimates: mem[(buf, u.op)] = buf.ptrdtype.size * buf.dtype.itemsize if u.op is Ops.RANGE: mult_stack.append(mults) - #mults *= cast(sint, u.src[0].ssimplify()) + mults *= cast(sint, u.src[0].ssimplify()) # SPECIAL are already counted in mults - #mults = mults.substitute({x:x.const_like(0) for x in mults.toposort() if x.op is Ops.SPECIAL}) if isinstance(mults, UOp) else mults + mults = mults.substitute({x:x.const_like(0) for x in mults.toposort() if x.op is Ops.SPECIAL}) if isinstance(mults, UOp) else mults elif u.op is Ops.END: mults = mult_stack.pop(-1) elif u.op is Ops.SPECIAL: mults *= cast(sint, u.src[0].ssimplify()) # NOTE: we don't push to the mult_stack here, you can't end these elif u.op is Ops.LOAD and (not isinstance(u.src[0].dtype, PtrDType) or u.src[0].dtype.addrspace != AddrSpace.REG):