From e8de3f5736aad0475a7dfedfe273b52c088cc0db Mon Sep 17 00:00:00 2001 From: George Hotz <72895+geohot@users.noreply.github.com> Date: Sun, 5 Mar 2023 08:41:11 -0800 Subject: [PATCH] Revert "less lines (#643)" (#644) This reverts commit 30f2238994df0f6ca42e66570c5453e4cfe79d3a. --- tinygrad/ops.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tinygrad/ops.py b/tinygrad/ops.py index 30379c5c0d..7f4d85d0b3 100644 --- a/tinygrad/ops.py +++ b/tinygrad/ops.py @@ -67,7 +67,10 @@ class DeviceBuffer(RawBuffer): # this is a quick "buffer" class for flop tracking and getting the output shape class GenericShape: def __init__(self, shape:Tuple[int, ...], flops:int=0): self.shape, self.flops = shape, flops - def consume_flops(self): return (self.flops, setattr(self, 'flops', 0))[0] + def consume_flops(self): + ret = self.flops + self.flops = 0 + return ret shape_fxn_for_op : Dict[Op, Callable] = { **{op:lambda self: GenericShape(self.shape, self.consume_flops() + prod(self.shape)) for op in UnaryOps}, **{op:lambda self,y: GenericShape(self.shape, self.consume_flops() + y.consume_flops() + prod(self.shape)) for op in BinaryOps},