mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-08-31 17:26:07 +00:00
ruff rule if-exp-instead-of-or-operator (FURB110) (#5178)
Co-authored-by: chenyu <[email protected]>
This commit is contained in:
co-authored by
chenyu
parent
5b8fda3c65
commit
9704c7d4d4
@@ -27,6 +27,7 @@ lint.select = [
|
||||
"RET506", # superfluous-else-raise
|
||||
"RET507", # superfluous-else-continue
|
||||
"A", # builtin-variable-shadowing, builtin-argument-shadowing, builtin-attribute-shadowing
|
||||
"FURB110",# if-exp-instead-of-or-operator
|
||||
]
|
||||
|
||||
line-length = 150
|
||||
|
||||
@@ -19,7 +19,7 @@ class TestFlopCounter(unittest.TestCase):
|
||||
#lin.hand_coded_optimizations()
|
||||
lin.linearize()
|
||||
ops, mem = lin.uops.flops_mem(ignore_indexing=True)
|
||||
run_count = prod((lin.global_size if lin.global_size else []) + (lin.local_size if lin.local_size else []))
|
||||
run_count = prod((lin.global_size or []) + (lin.local_size or []))
|
||||
self.assertEqual(info.flops, ops*run_count)
|
||||
print(info.flops, info.mem_estimate, "vs", ops*run_count, mem*run_count)
|
||||
#lin.uops.print()
|
||||
|
||||
@@ -522,7 +522,7 @@ class Linearizer(Kernel):
|
||||
src = self.opts.render(name:=to_function_name(self.name), self.uops)
|
||||
if getenv("RUN_PROCESS_REPLAY"): diskcache_put("process_replay", id(self), (self.ast, self.opts, self.applied_opts, name, src))
|
||||
ops, mem = self.uops.flops_mem()
|
||||
run_count = prod((self.global_size if self.global_size else []) + (self.local_size if self.local_size else []))
|
||||
run_count = prod((self.global_size or []) + (self.local_size or []))
|
||||
# NOTE: we use min here to ignore the indexing FLOPS
|
||||
return Program(self.name, src, self.opts.device, self.global_size, self.local_size,
|
||||
self.uops, min(info.flops, ops * run_count), min(info.mem_estimate, mem * run_count))
|
||||
|
||||
+2
-2
@@ -180,8 +180,8 @@ class Compiler:
|
||||
|
||||
class Compiled:
|
||||
def __init__(self, device:str, allocator:Allocator, renderer:Optional[Renderer], compiler:Optional[Compiler], runtime, graph=None):
|
||||
self.dname, self.allocator, self.compiler, self.runtime, self.graph = device, allocator, compiler if compiler else Compiler(), runtime, graph
|
||||
self.renderer = renderer if renderer else Renderer()
|
||||
self.dname, self.allocator, self.compiler, self.runtime, self.graph = device, allocator, compiler or Compiler(), runtime, graph
|
||||
self.renderer = renderer or Renderer()
|
||||
def synchronize(self): pass # override this in your device
|
||||
|
||||
# **************** for HCQ Compatible Devices ****************
|
||||
|
||||
+1
-1
@@ -234,7 +234,7 @@ def fetch(url:str, name:Optional[Union[pathlib.Path, str]]=None, subdir:Optional
|
||||
allow_caching=not getenv("DISABLE_HTTP_CACHE")) -> pathlib.Path:
|
||||
if url.startswith(("/", ".")): return pathlib.Path(url)
|
||||
if name is not None and (isinstance(name, pathlib.Path) or '/' in name): fp = pathlib.Path(name)
|
||||
else: fp = pathlib.Path(_cache_dir) / "tinygrad" / "downloads" / (subdir or "") / (name if name else hashlib.md5(url.encode('utf-8')).hexdigest())
|
||||
else: fp = pathlib.Path(_cache_dir) / "tinygrad" / "downloads" / (subdir or "") / (name or hashlib.md5(url.encode('utf-8')).hexdigest())
|
||||
if not fp.is_file() or not allow_caching:
|
||||
with urllib.request.urlopen(url, timeout=10) as r:
|
||||
assert r.status == 200
|
||||
|
||||
Reference in New Issue
Block a user