From 199a99123722b15719967e15b5ba378fdda05468 Mon Sep 17 00:00:00 2001 From: George Hotz <72895+geohot@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:05:09 +0700 Subject: [PATCH] line reduction [pr] (#7296) --- test/unit/test_shm_tensor.py | 3 +-- tinygrad/device.py | 3 +-- tinygrad/helpers.py | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/test/unit/test_shm_tensor.py b/test/unit/test_shm_tensor.py index 5c68237b8e..6c9ab24861 100644 --- a/test/unit/test_shm_tensor.py +++ b/test/unit/test_shm_tensor.py @@ -1,10 +1,9 @@ import unittest import multiprocessing.shared_memory as shared_memory -from tinygrad.helpers import CI, WIN +from tinygrad.helpers import CI from tinygrad.tensor import Tensor, Device import numpy as np -@unittest.skipIf(WIN, "no shm on Windows") class TestRawShmBuffer(unittest.TestCase): def test_e2e(self): t = Tensor.randn(2, 2, 2).realize() diff --git a/tinygrad/device.py b/tinygrad/device.py index 25f8eb5c50..bb9413ce40 100644 --- a/tinygrad/device.py +++ b/tinygrad/device.py @@ -138,8 +138,7 @@ class Allocator: assert not isinstance(size, int) or size > 0, f"alloc size must be positve, getting {size}" return self._alloc(size, options if options is not None else BufferOptions()) def _alloc(self, size:int, options:BufferOptions): raise NotImplementedError("need alloc") - def free(self, opaque, size:int, options:Optional[BufferOptions]=None): - self._free(opaque, options if options is not None else BufferOptions()) + def free(self, opaque, size:int, options:Optional[BufferOptions]=None): self._free(opaque, options if options is not None else BufferOptions()) def _free(self, opaque, options:BufferOptions): pass # if opaque is a Python object, you don't need a free def copyin(self, dest, src:memoryview): raise NotImplementedError("need copyin") def copyout(self, dest:memoryview, src): raise NotImplementedError("need copyout") diff --git a/tinygrad/helpers.py b/tinygrad/helpers.py index 2da49057af..fabbd10a41 100644 --- a/tinygrad/helpers.py +++ b/tinygrad/helpers.py @@ -13,11 +13,10 @@ def prod(x:Iterable[T]) -> Union[T,int]: return functools.reduce(operator.mul, x # NOTE: helpers is not allowed to import from anything else in tinygrad OSX = platform.system() == "Darwin" -WIN = platform.system() == "Windows" CI = os.getenv("CI", "") != "" # fix colors on Windows, https://stackoverflow.com/questions/12492810/python-how-can-i-make-the-ansi-escape-codes-to-work-also-in-windows -if WIN: os.system("") +if sys.platform == "win32": os.system("") def dedup(x:Iterable[T]): return list(dict.fromkeys(x)) # retains list order def argfix(*x):