MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / _ThreadLocalStateCache

Class _ThreadLocalStateCache

imperative/python/megengine/xla/lib/config.py:626–637  ·  view source on GitHub ↗

A thread local cache for _ThreadLocalExtraJitContext The extra_jit_context in xla_jit.thread_local_state() may get updated and thus incurring dispatch overhead for comparing this python object during jit calls. We want to duduplicate the objects that have the same hash/equality to also

Source from the content-addressed store, hash-verified

624
625
626class _ThreadLocalStateCache(threading.local):
627 """"A thread local cache for _ThreadLocalExtraJitContext
628
629 The extra_jit_context in xla_jit.thread_local_state() may get updated and thus
630 incurring dispatch overhead for comparing this python object during jit calls.
631 We want to duduplicate the objects that have the same hash/equality to also
632 have the same object ID, since the equality check is much faster if the object
633 IDs match.
634 """
635
636 def __init__(self):
637 self.canonicalize = functools.lru_cache(128)(lambda x: x)
638
639
640_thread_local_state_cache = _ThreadLocalStateCache()

Callers 1

config.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected