[1/N] DP-Refactor: move communicators into tokenizer_communicator_mixin (#10028)

This commit is contained in:
Liangsheng Yin
2025-09-08 16:27:37 +08:00
committed by GitHub
parent bfd7a18d8d
commit 78f139812a
5 changed files with 503 additions and 459 deletions

View File

@@ -473,6 +473,10 @@ class TypeBasedDispatcher:
def __init__(self, mapping: List[Tuple[Type, Callable]]):
self._mapping = mapping
def __iadd__(self, other: "TypeBasedDispatcher"):
self._mapping.extend(other._mapping)
return self
def __call__(self, obj: Any):
for ty, fn in self._mapping:
if isinstance(obj, ty):