From df49439b9af907dcebc9ac5ed2e37dbdb4101b85 Mon Sep 17 00:00:00 2001 From: chenyu Date: Sun, 3 Nov 2024 13:11:56 -0500 Subject: [PATCH] remove reassoc from LLVM flags (#7512) reassoc reorders compute and breaks transcendental --- test/helpers.py | 3 ++- test/test_transcendental.py | 1 - tinygrad/renderer/llvmir.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/helpers.py b/test/helpers.py index a3990b18a8..706297bc10 100644 --- a/test/helpers.py +++ b/test/helpers.py @@ -42,7 +42,8 @@ def is_dtype_supported(dtype: DType, device: str = Device.DEFAULT): # PYTHON supports half memoryview in 3.12+ https://github.com/python/cpython/issues/90751 if dtype == dtypes.half: if device == "GPU": return not CI and not OSX - if device in ["LLVM", "CUDA", "NV"]: return not CI + if device in ["CUDA", "NV"]: return not CI + if device == "LLVM": return OSX if device == "PYTHON": return sys.version_info >= (3, 12) if dtype == dtypes.float64: return device != "METAL" and not (OSX and device == "GPU") return True diff --git a/test/test_transcendental.py b/test/test_transcendental.py index 8a1417db34..8e75b56ab5 100644 --- a/test/test_transcendental.py +++ b/test/test_transcendental.py @@ -40,7 +40,6 @@ class TestTranscendentalMath(unittest.TestCase): op[1](np.array([x], dtype=_to_np_dtype(dtypes.float16))), atol=1e-2, rtol=5e-3) # exp can have bigger rtol - @unittest.skipIf(Device.DEFAULT=="LLVM", "FIXME: LLVM might change compute") @given(strat.sampled_from([(dtypes.float64, 709.5), (dtypes.float32, 88.7), (dtypes.float16, 11)])) def test_exp_near_inf(self, dtype_x): # reordering compute might return inf diff --git a/tinygrad/renderer/llvmir.py b/tinygrad/renderer/llvmir.py index 987f3a7259..df8d38befa 100644 --- a/tinygrad/renderer/llvmir.py +++ b/tinygrad/renderer/llvmir.py @@ -4,7 +4,7 @@ from tinygrad.dtype import DType, PtrDType, dtypes from tinygrad.ops import Op, UnaryOps, BinaryOps, TernaryOps, Ops, UOp from tinygrad.renderer import Renderer -MFLAGS = ('nsz', 'arcp', 'contract', 'afn', 'reassoc') # All from fast math, but nnan and ninf +MFLAGS = ('nsz', 'arcp', 'contract', 'afn') # All from fast math, but nnan and ninf and reassoc def is_bool_or_unsigned(dtype: DType): return dtype == dtypes.bool or dtypes.is_unsigned(dtype)