mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-04-07 03:00:26 -04:00
use functools.partialmethod (#369)
Co-authored-by: Kyle <kposborne@gmail.com>
This commit is contained in:
@@ -318,8 +318,7 @@ for device in [device for device in Device.__dict__.keys() if device[0] != "_"]:
|
||||
|
||||
# register all the mlops "math" operations
|
||||
def register(name:str, fxn:Function):
|
||||
def dispatch(*x, **kwargs): return fxn.apply(*x, **kwargs) # TODO: there's probably a very pythonic thing to replace this with
|
||||
setattr(Tensor, "_"+name if (getattr(Tensor, name, None) is not None) else name, dispatch)
|
||||
setattr(Tensor, "_"+name if (getattr(Tensor, name, None) is not None) else name, functools.partialmethod(fxn.apply))
|
||||
for name, cls in inspect.getmembers(importlib.import_module('tinygrad.mlops'), inspect.isclass):
|
||||
if name[0] != "_" and name != "Function" and not name.endswith("Ops"): register(name.lower(), cls)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user