mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Many files in dynamo are currently lacking file/module-level documentation, which makes it hard to know what they do at a glance and without digging into the code. This fixes that. Note: documentation was AI-generated and could be incorrect, please review carefully. Pull Request resolved: https://github.com/pytorch/pytorch/pull/146736 Approved by: https://github.com/jansel, https://github.com/StrongerXi, https://github.com/anijain2305, https://github.com/zou3519
25 lines
765 B
Python
25 lines
765 B
Python
"""Hook system for Dynamo's guard functionality.
|
|
|
|
This module provides a way to register callback functions that are triggered during
|
|
guard-related operations.
|
|
|
|
The Hooks class manages two types of hook functions:
|
|
- guard_export_fn: Called when guards need to be exported, taking a GuardsSet as input
|
|
- guard_fail_fn: Called when a guard check fails, taking a GuardFail object as input
|
|
|
|
These hooks enable customization of guard export and failure handling behaviors.
|
|
"""
|
|
|
|
import dataclasses
|
|
from typing import Callable, Optional
|
|
|
|
from torch._guards import GuardsSet
|
|
|
|
from .types import GuardFail
|
|
|
|
|
|
@dataclasses.dataclass
|
|
class Hooks:
|
|
guard_export_fn: Optional[Callable[[GuardsSet], None]] = None
|
|
guard_fail_fn: Optional[Callable[[GuardFail], None]] = None
|