diff --git a/setup.py b/setup.py index e7de2ac56b..03ab976f9a 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup(name='tinygrad', "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License" ], - install_requires=["numpy", "requests", "pillow", "tqdm", "networkx", "pyopencl", "PyYAML", + install_requires=["numpy", "requests", "tqdm", "networkx", "pyopencl", "pyobjc-framework-Metal; platform_system=='Darwin'", "pyobjc-framework-Cocoa; platform_system=='Darwin'", "pyobjc-framework-libdispatch; platform_system=='Darwin'"], @@ -37,11 +37,11 @@ setup(name='tinygrad', "typing-extensions", "pre-commit", "ruff", - "types-PyYAML", "types-tqdm", ], 'testing': [ "torch", + "pillow", "pytest", "pytest-xdist", "onnx==1.14.1", diff --git a/tinygrad/runtime/ops_torch.py b/tinygrad/runtime/ops_torch.py index 7122eb54b2..3a183d0ddc 100644 --- a/tinygrad/runtime/ops_torch.py +++ b/tinygrad/runtime/ops_torch.py @@ -18,8 +18,8 @@ def as_strided(x, arg): torch_fxn_for_op: Dict[Op, Callable] = {**base_fxn_for_op, **{ # TODO: torch.tensor should work here - #BufferOps.CONST: lambda val, dtype: torch.tensor(val, dtype=inverse_type_map[dtype]), - BufferOps.CONST: lambda val, dtype: torch.from_numpy(np.array(val, dtype=dtype.np)), + #BufferOps.CONST: lambda val, dtype: torch.tensor(val, device=device, dtype=inverse_type_map[dtype]), + BufferOps.CONST: lambda val, dtype: torch.from_numpy(np.array(val, dtype=dtype.np)).requires_grad_(False).to(device), UnaryOps.NOOP: lambda x: x.contiguous(), UnaryOps.SQRT: lambda x: x.sqrt(), UnaryOps.EXP2: lambda x: x.exp2(), UnaryOps.LOG2: lambda x: x.log2(), UnaryOps.SIN: torch.sin, UnaryOps.CAST: lambda x,y: (x.view if y[1] else x.type)(next(k for k,v in type_map.items() if v==y[0])), BinaryOps.MAX: torch.maximum, BinaryOps.CMPLT: lambda x,y: (x=0 for s in x.strides) else x.copy()).requires_grad_(False).to(device)