MCPcopy
hub / github.com/tinygrad/tinygrad / Context

Class Context

tinygrad/helpers.py:168–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166def stderr_log(msg:str): print(msg, end='', file=sys.stderr, flush=True)
167
168class Context(contextlib.ContextDecorator):
169 def __init__(self, **kwargs): self.kwargs = kwargs
170 def __enter__(self):
171 self.old_context:dict[str, Any] = {k: ContextVar._cache[k].value for k in self.kwargs}
172 for k,v in self.kwargs.items(): ContextVar._cache[k].value = v
173 def __exit__(self, *args):
174 for k,v in self.old_context.items(): ContextVar._cache[k].value = v
175
176class ContextVar(Generic[T]):
177 _cache: ClassVar[dict[str, ContextVar]] = {}

Callers 15

__call__Method · 0.90
enumerate_devices_strFunction · 0.90
mainFunction · 0.90
time_callFunction · 0.90
__call__Method · 0.90
_get_codeFunction · 0.90
upat_compileFunction · 0.90
__call__Method · 0.90
simplifyMethod · 0.90
substituteMethod · 0.90
type_verifyFunction · 0.90
apply_optsFunction · 0.90

Calls

no outgoing calls

Tested by 15

test_matmulFunction · 0.72
test_matmulFunction · 0.72
test_beamMethod · 0.72
test_imageMethod · 0.72
test_beam_imageMethod · 0.72
save_vizFunction · 0.72
test_inf_loopMethod · 0.72
get_cfgMethod · 0.72
test_aggregateMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…