
    sg	              
           d dl Z d dlmZ d dlmZ d dlmZ d dlmZ ddgZ	 ed	       G d
 d edddg                   Z
 ed	       G d de j                               Zy)    N)
namedtuple)Optional)GraphModule)compatibility
PassResultPassBaseF)is_backward_compatiblec                   "     e Zd ZdZ fdZ xZS )r   z
    Result of a pass:
        graph_module: The modified graph module
        modified: A flag for if the pass has modified the graph module
    c                 &    t         |   | ||      S )N)super__new__)clsgraph_modulemodified	__class__s      R/var/www/html/venv/lib/python3.12/site-packages/torch/fx/passes/infra/pass_base.pyr   zPassResult.__new__   s    wsL(;;    )__name__
__module____qualname____doc__r   __classcell__)r   s   @r   r   r      s    
< <r   r   r   c                   z    e Zd ZdZdedee   fdZej                  dedee   fd       Z
deddfdZdeddfdZy)	r   aV  
    Base interface for implementing passes.

    It is required to implement the `call` function so that we can directly
    pass instances of the Pass directly to the PassManager and call them as a
    function.

    We can directly pass an instance of a class implementing this interface into
    the PassManager's `passes` attribute.
    r   returnc                 l    | j                  |       | j                  |      }| j                  |       |S )z\
        Runs the precondition check, the pass itself, and the postcondition check.
        )requirescallensures)selfr   ress      r   __call__zPassBase.__call__#   s/    
 	l#ii%\"
r   c                      y)z
        The pass that is run through the given graph module. To implement a
        pass, it is required to implement this function.

        Args:
            graph_module: The graph module we will run a pass on
        N r   r   s     r   r   zPassBase.call-       r   Nc                      y)a2  
        This function will be called before the pass is run and will check that
        the given graph module contains the preconditions needed to run the
        pass. It is not required to implement this function.

        Args:
            graph_module: The graph module we will run checks on
        Nr#   r$   s     r   r   zPassBase.requires7   r%   r   c                      y)a2  
        This function will be called after the pass is run and will check that
        the given graph module contains the postconditions needed to run the
        pass. It is not required to implement this function.

        Args:
            graph_module: The graph module we will run checks on
        Nr#   r$   s     r   r   zPassBase.ensuresA   r%   r   )r   r   r   r   r   r   r   r!   abcabstractmethodr   r   r   r#   r   r   r   r      sr    	[ Xj5I  	 *1E  [ T K D r   )r(   collectionsr   typingr   torch.fx.graph_moduler   torch.fx._compatibilityr   __all__r   ABCr   r#   r   r   <module>r0      sn    
 "  - 1 
$e,<L>:*FG < -< e,2sww 2 -2r   