From 6dcaee236101a4b900f8dac96a678fe7ca85e452 Mon Sep 17 00:00:00 2001 From: George Hotz Date: Thu, 9 Jun 2022 08:42:42 -0700 Subject: [PATCH] ops enum cleanup --- tinygrad/helpers.py | 22 +++------------------- tinygrad/tensor.py | 2 +- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/tinygrad/helpers.py b/tinygrad/helpers.py index 198501d380..ea5e41f6e2 100644 --- a/tinygrad/helpers.py +++ b/tinygrad/helpers.py @@ -22,22 +22,6 @@ def binary_broadcast(x_shape, y_shape, extra=False): return (shape_ret, dimlist, complist) if extra else shape_ret from enum import Enum -class UnaryOps(Enum): - RELU = 0 - EXP = 1 - LOG = 2 - NEG = 3 - SIGN = 4 - -class BinaryOps(Enum): - ADD = 0 - SUB = 1 - MUL = 2 - DIV = 3 - POW = 4 - A = 5 - CMPEQ = 6 - -class ReduceOps(Enum): - SUM = 0 - MAX = 1 \ No newline at end of file +UnaryOps = Enum("UnaryOps", ["RELU", "EXP", "LOG", "NEG", "SIGN"]) +BinaryOps = Enum("BinaryOps", ["ADD", "SUB", "MUL", "DIV", "POW", "A", "CMPEQ"]) +ReduceOps = Enum("ReduceOps", ["SUM", "MAX"]) diff --git a/tinygrad/tensor.py b/tinygrad/tensor.py index 04d20bd76b..196fd05cba 100644 --- a/tinygrad/tensor.py +++ b/tinygrad/tensor.py @@ -427,4 +427,4 @@ for device in [device for device in Device.__dict__.keys() if device[0] != "_"]: # this registers all the mlops "math" operations for name, cls in inspect.getmembers(importlib.import_module('tinygrad.mlops'), inspect.isclass): - if name[0] != "_" and name != "Function": register(name.lower(), cls) + if name[0] != "_" and name != "Function" and not name.endswith("Ops"): register(name.lower(), cls)