Register backend="tvarant" with torch.compile / Dynamo.
Safe to call multiple times; subsequent calls are no-ops. Invoked
automatically on import torch_tvarant.compiler.
Source code in torch_tvarant/compiler.py
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374 | def register() -> None:
"""Register ``backend="tvarant"`` with ``torch.compile`` / Dynamo.
Safe to call multiple times; subsequent calls are no-ops. Invoked
automatically on ``import torch_tvarant.compiler``.
"""
global _registered
if _registered:
return
try:
from torch._dynamo.backends.registry import register_backend
register_backend(_dynamo_backend, name="tvarant")
_registered = True
return
except Exception:
pass
try:
import torch._dynamo as dynamo
if hasattr(dynamo, "register_backend"):
dynamo.register_backend(_dynamo_backend, name="tvarant")
_registered = True
except Exception:
pass
|