mirror of https://github.com/commaai/tinygrad.git
beautiful mnist works on windows (#7100)
* beautiful mnist works on windows [pr] * add comment for that (no pr)
This commit is contained in:
parent
fc306ba89d
commit
cd61e81f55
|
@ -91,8 +91,8 @@ class dtypes:
|
|||
uint16: Final[DType] = DType(4, 2, "unsigned short", 'H', 1)
|
||||
int32: Final[DType] = DType(5, 4, "int", 'i', 1)
|
||||
uint32: Final[DType] = DType(6, 4, "unsigned int", 'I', 1)
|
||||
int64: Final[DType] = DType(7, 8, "long", 'l', 1)
|
||||
uint64: Final[DType] = DType(8, 8, "unsigned long", 'L', 1)
|
||||
int64: Final[DType] = DType(7, 8, "long", 'q', 1)
|
||||
uint64: Final[DType] = DType(8, 8, "unsigned long", 'Q', 1)
|
||||
float16: Final[DType] = DType(9, 2, "half", 'e', 1)
|
||||
# bfloat16 has higher priority than float16, so least_upper_dtype(dtypes.int64, dtypes.uint64) = dtypes.float16
|
||||
bfloat16: Final[DType] = DType(10, 2, "__bf16", None, 1)
|
||||
|
|
|
@ -13,8 +13,12 @@ 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("")
|
||||
|
||||
def dedup(x:Iterable[T]): return list(dict.fromkeys(x)) # retains list order
|
||||
def argfix(*x):
|
||||
if x and x[0].__class__ in (tuple, list):
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import annotations
|
||||
import os, sys, mmap, _posixshmem, io, ctypes, ctypes.util, platform, contextlib
|
||||
import os, sys, mmap, io, ctypes, ctypes.util, platform, contextlib
|
||||
from typing import Optional, Generator, Tuple, Callable, List
|
||||
from tinygrad.helpers import OSX, round_up
|
||||
from tinygrad.device import Compiled, Allocator
|
||||
with contextlib.suppress(ImportError):
|
||||
import _posixshmem
|
||||
from tinygrad.runtime.autogen import io_uring, libc
|
||||
|
||||
class DiskBuffer:
|
||||
|
@ -87,7 +89,7 @@ class DiskDevice(Compiled):
|
|||
self.mem = mmap.mmap(fd, self.size, mmap.MAP_SHARED | MAP_POPULATE | MAP_LOCKED)
|
||||
os.close(fd)
|
||||
else:
|
||||
try: self.fd = os.open(filename, os.O_RDWR|os.O_CREAT|(0 if OSX else os.O_DIRECT))
|
||||
try: self.fd = os.open(filename, os.O_RDWR|os.O_CREAT|getattr(os, "O_DIRECT", 0))
|
||||
except OSError: self.fd = os.open(filename, os.O_RDWR|os.O_CREAT)
|
||||
if os.fstat(self.fd).st_size < self.size: os.ftruncate(self.fd, self.size)
|
||||
self.mem = mmap.mmap(self.fd, self.size)
|
||||
|
|
Loading…
Reference in New Issue