mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-06-11 23:46:02 +08:00
line reduction [pr] (#7296)
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user