§
    ŠŠtj•  ã                  ó”  — U d dl mZ d dlZd dlZd dlmZ d dlmZmZmZm	Z	 d dl
mZmZmZ d dlZd dlmZ d dlmZ 	 d dlmZmZ n# e$ r dZdZY nw xY werd d	lmZ d d
lmZ ddlmZ g d¢Z ed¦  «        Z ed¦  «        Z  e!ej"        d¦  «        sH ed¦  «        ej"        j#        d<    ed¦  «        ej"        j#        d<    ed¦  «        ej"        j#        d<   d dl$m%Z%m&Z&m'Z' d3d„Z(d4d„Z) G d„ de&¦  «        Z* G d„ d¦  «        Z+e	dede,f         f         Z-d e.d!<   e	 	 	 d5d6d,„¦   «         Z/e	 	 	 d5d7d/„¦   «         Z/	 	 	 d5d8d2„Z/dS )9é    )ÚannotationsN)ÚCallable)ÚoverloadÚTYPE_CHECKINGÚ	TypeAliasÚUnion)Ú	ParamSpecÚSelfÚTypeVar)ÚTensor)Ú_check_cuda_bindings)ÚdriverÚruntime)Ú_POOL_HANDLE©Ú_CUDAGraphInputLivenessTrackeré   )Ú_dummy_type)Úis_current_stream_capturingÚgraph_pool_handleÚ	CUDAGraphÚgraphÚmake_graphed_callablesÚ_RÚ_PÚ_CudaStreamBaseÚ
_CUDAGraphÚ_graph_pool_handleÚ_cuda_isCurrentStreamCapturing)r   r   r   ÚreturnÚboolc                 ó   — t          ¦   «         S )zÌReturn True if CUDA graph capture is underway on the current CUDA stream, False otherwise.

    If a CUDA context does not exist on the current device, returns False without initializing the context.
    )r   © ó    úO/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/torch/cuda/graphs.pyr   r   9   s   € õ
 *Ñ+Ô+Ð+r$   r   c                 óX   — t           j                             t          ¦   «         ¦  «        S )zÚReturn an opaque token representing the id of a graph memory pool.

    See :ref:`Graph memory management<graph-memory-management>`.

    .. warning::
        This API is in beta and may change in future releases.
    )ÚtorchÚcudar   r   r#   r$   r%   r   r   B   s!   € õ Œ:×"Ò"Õ#5Ñ#7Ô#7Ñ8Ô8Ð8r$   c                  óÂ   ‡ — e Zd ZU dZded<   d"d#ˆ fd	„Zd$d„Z	 	 	 d%d&ˆ fd„Zd$ˆ fd„Zd$ˆ fd„Z	d$ˆ fd„Z
d$ˆ fd„Zd'ˆ fd„Zd$ˆ fd„Zd(ˆ fd„Zd)ˆ fd„Zd)ˆ fd„Zd*d!„Zˆ xZS )+r   a-  Wrapper around a CUDA graph.

    Arguments:
        keep_graph (bool, optional): If ``keep_graph=False``, the
            cudaGraphExec_t will be instantiated on GPU at the end of
            ``capture_end`` and the underlying cudaGraph_t will be
            destroyed. Users who want to query or otherwise modify the
            underlying cudaGraph_t before instantiation can set
            ``keep_graph=True`` and access it via ``raw_cuda_graph`` after
            ``capture_end``. Note that the cudaGraphExec_t will not be
            instantiated at the end of ``capture_end`` in this
            case. Instead, it will be instantiated via an explicit called
            to ``instantiate`` or automatically on the first call to
            ``replay`` if ``instantiate`` was not already called. Calling
            ``instantiate`` manually before ``replay`` is recommended to
            prevent increased latency on the first call to ``replay``. It
            is allowed to modify the raw cudaGraph_t after first calling
            ``instantiate``, but the user must call ``instantiate`` again
            manually to make sure the instantiated graph has these
            changes. Pytorch has no means of tracking these changes.

    .. warning::
        This API is in beta and may change in future releases.

    z%_CUDAGraphInputLivenessTracker | NoneÚ_trackerFÚ
keep_graphr!   r    r
   c                óZ   •— t          ¦   «                              | |¦  «        }d |_        |S ©N)ÚsuperÚ__new__r*   )Úclsr+   ÚinstanceÚ	__class__s      €r%   r/   zCUDAGraph.__new__k   s'   ø€ Ý‘7”7—?’? 3¨
Ñ3Ô3ˆØ ˆÔØˆr$   ÚNonec                óx   — 	 | j         d c}| _         |�|                     ¦   «          d S d S # t          $ r Y d S w xY wr-   )r*   ÚstopÚ	Exception)ÚselfÚtrackers     r%   Ú__del__zCUDAGraph.__del__p   sX   € ð	Ø%)¤]°DÐ"ˆG�T”]ØÐ"Ø—’‘”���ð #Ð"øåð 	ð 	ð 	ØˆDˆDð	øøøs   ‚%+ «
9¸9NÚglobalÚpoolú_POOL_HANDLE | NoneÚcapture_error_modeÚstrÚcheck_input_livenessc                ó   •— | j         � | j                              ¦   «          d| _         t          ¦   «                              ||¬¦  «         |r0ddlm}  |¦   «         | _         | j                              ¦   «          dS dS )a  Begin capturing CUDA work on the current stream.

        Typically, you shouldn't call ``capture_begin`` yourself.
        Use :class:`~torch.cuda.graph` or :func:`~torch.cuda.make_graphed_callables`,
        which call ``capture_begin`` internally.

        Arguments:
            pool (optional): Token (returned by :func:`~torch.cuda.graph_pool_handle` or
                :meth:`other_Graph_instance.pool()<torch.cuda.CUDAGraph.pool>`) that hints this graph may share memory
                with the indicated pool.  See :ref:`Graph memory management<graph-memory-management>`.
            capture_error_mode (str, optional): specifies the cudaStreamCaptureMode for the graph capture stream.
                Can be "global", "thread_local" or "relaxed". During cuda graph capture, some actions, such as cudaMalloc,
                may be unsafe. "global" will error on actions in other threads, "thread_local" will only error for
                actions in the current thread, and "relaxed" will not error on these actions. Do NOT change this setting
                unless you're familiar with `cudaStreamCaptureMode <https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g9d0535d93a214cbf126835257b16ba85>`_
            check_input_liveness (bool, optional):
                If ``True``, tracks external tensor inputs during graph capture and
                raises an error if any are deallocated before replay. This helps debug "use after free" errors
                where input tensors are garbage collected between capture and replay. Default: ``False``.

                .. note::
                    Custom CUDA kernels added outside PyTorch (e.g., via cuLaunchKernel or DLPack) are not
                    tracked by this mechanism.
        N)r;   r=   r   r   )r*   r5   r.   Úcapture_beginÚtorch.utils._cuda_debugr   Ústart)r7   r;   r=   r?   r   r2   s        €r%   rA   zCUDAGraph.capture_beginx   s”   ø€ ð< Œ=Ð$ØŒM×ÒÑ Ô Ð Ø ˆDŒMÝ‰Œ×Ò 4Ð<NÐÑOÔOÐOØð 	"ØNÐNÐNÐNÐNÐNà:Ð:Ñ<Ô<ˆDŒMØŒM×ÒÑ!Ô!Ð!Ð!Ð!ð		"ð 	"r$   c                óŒ   •— t          ¦   «                              ¦   «          | j        �| j                             ¦   «          dS dS )aG  End CUDA graph capture on the current stream.

        After ``capture_end``, ``replay`` may be called on this instance.

        Typically, you shouldn't call ``capture_end`` yourself.
        Use :class:`~torch.cuda.graph` or :func:`~torch.cuda.make_graphed_callables`,
        which call ``capture_end`` internally.
        N)r.   Úcapture_endr*   r5   ©r7   r2   s    €r%   rE   zCUDAGraph.capture_end    sE   ø€ õ 	‰Œ×ÒÑÔÐØŒ=Ð$ØŒM×ÒÑ Ô Ð Ð Ð ð %Ð$r$   c                óH   •— t          ¦   «                              ¦   «          dS )a$  Instantiate the CUDA graph. Will be called by
        ``capture_end`` if ``keep_graph=False``, or by ``replay`` if
        ``keep_graph=True`` and ``instantiate`` has not already been
        explicitly called. Does not destroy the cudaGraph_t returned
        by ``raw_cuda_graph``.
        N)r.   ÚinstantiaterF   s    €r%   rH   zCUDAGraph.instantiate­   s!   ø€ õ 	‰Œ×ÒÑÔÐÐÐr$   c                ó®   •— | j         �,| j                              |                      ¦   «         ¦  «         t          ¦   «                              ¦   «          dS )z,Replay the CUDA work captured by this graph.N)r*   Úcheck_aliver;   r.   ÚreplayrF   s    €r%   rK   zCUDAGraph.replay¶   sC   ø€ àŒ=Ð$ØŒM×%Ò% d§i¢i¡k¤kÑ2Ô2Ð2Ý‰Œ�ŠÑÔÐÐÐr$   c                ó–   •— | j         � | j                              ¦   «          d| _         t          ¦   «                              ¦   «          dS )z1Delete the graph currently held by this instance.N)r*   r5   r.   ÚresetrF   s    €r%   rM   zCUDAGraph.reset¼   s;   ø€ àŒ=Ð$ØŒM×ÒÑ Ô Ð Ø ˆDŒMÝ‰Œ�Š‰Œˆˆˆr$   r   c                óD   •— t          ¦   «                              ¦   «         S )zäReturn an opaque token representing the id of this graph's memory pool.

        This id can optionally be passed to another graph's ``capture_begin``,
        which hints the other graph may share the same memory pool.
        )r.   r;   rF   s    €r%   r;   zCUDAGraph.poolÃ   s   ø€ õ ‰wŒw�|Š|‰~Œ~Ðr$   c                óD   •— t          ¦   «                              ¦   «         S )z/Enable debugging mode for CUDAGraph.debug_dump.)r.   Úenable_debug_moderF   s    €r%   rP   zCUDAGraph.enable_debug_modeË   s   ø€ å‰wŒw×(Ò(Ñ*Ô*Ð*r$   Ú
debug_pathc                óF   •— t          ¦   «                              |¦  «        S )zÖ
        Arguments:
            debug_path (required): Path to dump the graph to.

        Calls a debugging function to dump the graph if the debugging is
        enabled via CUDAGraph.enable_debug_mode()
        )r.   Ú
debug_dump)r7   rQ   r2   s     €r%   rS   zCUDAGraph.debug_dumpÏ   s   ø€ õ ‰wŒw×!Ò! *Ñ-Ô-Ð-r$   Úintc                óD   •— t          ¦   «                              ¦   «         S )a|  Returns the underlying cudaGraph_t. ``keep_graph`` must be True.

        See the following for APIs for how to manipulate this object: `Graph Management <https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__GRAPH.html>`_ and `cuda-python Graph Management bindings <https://nvidia.github.io/cuda-python/cuda-bindings/latest/module/runtime.html#graph-management>`_
        )r.   Úraw_cuda_graphrF   s    €r%   rV   zCUDAGraph.raw_cuda_graphÙ   s   ø€ õ
 ‰wŒw×%Ò%Ñ'Ô'Ð'r$   c                óD   •— t          ¦   «                              ¦   «         S )aª  Returns the underlying cudaGraphExec_t. ``instantiate`` must have been called if ``keep_graph`` is True, or ``capture_end`` must have been called if ``keep_graph`` is False. If you call ``instantiate()`` after ``raw_cuda_graph_exec()``, the previously returned cudaGraphExec_t will be destroyed. It is your responsibility not to use this object after destruction.

        See the following for APIs for how to manipulate this object: `Graph Execution <https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__GRAPH__EXEC.html>`_ and `cuda-python Graph Execution bindings <https://nvidia.github.io/cuda-python/cuda-bindings/latest/module/runtime.html#graph-execution>`_
        )r.   Úraw_cuda_graph_execrF   s    €r%   rX   zCUDAGraph.raw_cuda_graph_execà   s   ø€ õ
 ‰wŒw×*Ò*Ñ,Ô,Ð,r$   Údictc                óÆ  — ddl m} t          �t          €t	          d¦  «        ‚ |¦   «         rt	          d¦  «        ‚t          j        j        dt          j        j        dt          j        j        dt          j        j	        d	t          j        j
        d
t          j        j        dt          j        j        dt          j        j        dt          j        j        dt          j        j        di
}|                      ¦   «         }t#          t          j        |d¬¦  «        ¦  «        \  }}t#          t          j        ||¬¦  «        ¦  «        \  }}i }g }t'          |¦  «        D �]Ÿ}	||	         }
|	|t)          |
¦  «        <   t#          t          j        |
¦  «        ¦  «        }t#          t          j        |
¦  «        ¦  «        }|dz	  }|dz  }d}|t          j        j        k    ràt          j        t)          |
¦  «        ¬¦  «        }t          j        |¦  «        \  }}|t          j        j        k    r’t)          |j        ¦  «        r~t          j        t)          |j        ¦  «        ¬¦  «        }t          j        |¦  «        \  }}|t          j        j        k    r+t=          |t>          ¦  «        r|                      ¦   «         n|}| !                    |	| "                    |tG          |¦  «        ¦  «        ||||g g dœ¦  «         �Œ¡t#          t          j$        |d¬¦  «        ¦  «        \  }}}}|dk    rÐt#          t          j$        ||¬¦  «        ¦  «        \  }}}}t'          |¦  «        D ]˜}	| "                    t)          ||	         ¦  «        ¦  «        }| "                    t)          ||	         ¦  «        ¦  «        }|�D|�B||         d          !                    |¦  «         ||         d          !                    |¦  «         Œ™t          j%        |  &                    ¦   «         ¬¦  «        }t#          t          j'        |¦  «        ¦  «        }|D ]}|dz  |d         z  |d<   ||d<   Œ||dœS )a†  Return a dictionary describing the graph's topology and node metadata.

        ``keep_graph`` must be True.  The graph must have been instantiated
        (via :meth:`instantiate`) before calling this method.
        Requires the ``cuda.bindings`` package.

        Returns a dictionary with structure::

            {
                "exec_graph_id": int,
                "nodes": [
                    {
                        "index": int,
                        "node_type": str,
                        "tools_id": int,
                        "graph_id": int,
                        "node_id": int,
                        "kernel_name": str or None,
                        "dependencies": [int, ...],
                        "dependents": [int, ...],
                    },
                    ...,
                ],
            }

        Each node's ``graph_id`` is remapped to the exec graph id so that
        ``tools_id`` values match those reported by CUPTI-based profilers.
        ``dependencies`` and ``dependents`` are lists of node indices within
        the ``nodes`` list.

        This structure is useful for inspecting a profiler trace and
        establishing whether a particular dependency observed in the profile
        is a true dependency (encoded in the graph) or a fake dependency
        caused by mapping of independent streams to the same hardware
        channel.
        r   )Ú_is_tools_id_unavailableNz1get_graph_data requires the cuda.bindings packagez•get_graph_data requires cudaGraphNodeGetToolsId which needs cuda.bindings >= 13.1 and CUDA driver >= 13.1 (or cuda-compat >= 13.1 in LD_LIBRARY_PATH)ÚkernelÚmemcpyÚmemsetÚhostÚchild_graphÚemptyÚ
wait_eventÚevent_recordÚ	mem_allocÚmem_free)ÚnumNodesé    l   ÿÿ )Ú
init_value)ÚindexÚ	node_typeÚtools_idÚgraph_idÚnode_idÚkernel_nameÚdependenciesÚ
dependents)ÚnumEdgesrp   ro   rm   rk   rl   )Úexec_graph_idÚnodes)(Útorch.cuda._graph_annotationsr[   Ú_cuda_runtimeÚ_cuda_driverÚRuntimeErrorÚcudaGraphNodeTypeÚcudaGraphNodeTypeKernelÚcudaGraphNodeTypeMemcpyÚcudaGraphNodeTypeMemsetÚcudaGraphNodeTypeHostÚcudaGraphNodeTypeGraphÚcudaGraphNodeTypeEmptyÚcudaGraphNodeTypeWaitEventÚcudaGraphNodeTypeEventRecordÚcudaGraphNodeTypeMemAllocÚcudaGraphNodeTypeMemFreerV   r   ÚcudaGraphGetNodesÚrangerT   ÚcudaGraphNodeGetTypeÚcudaGraphNodeGetToolsIdÚCUgraphNodeÚcuGraphKernelNodeGetParamsÚCUresultÚCUDA_SUCCESSÚfuncÚ
CUfunctionÚcuFuncGetNameÚ
isinstanceÚbytesÚdecodeÚappendÚgetr>   ÚcudaGraphGetEdgesÚcudaGraphExec_trX   ÚcudaGraphExecGetId)r7   r[   Únode_type_namesÚrawÚ_Únumrs   Úhandle_to_idxÚ
node_infosÚiÚnodeÚntyperk   rl   rm   rn   Úcu_nodeÚerrÚparamsÚcu_funcÚnameÚ	num_edgesÚ
from_nodesÚto_nodesÚ
_edge_dataÚsrcÚdstÚexec_handlerr   Úinfos                                 r%   Úget_graph_datazCUDAGraph.get_graph_dataç   sW  € ðJ 	KÐJÐJÐJÐJÐJåÐ ¥LÐ$8ÝÐRÑSÔSÐSà#Ð#Ñ%Ô%ð 	Ýð>ñô ð õ Ô+ÔCÀXÝÔ+ÔCÀXÝÔ+ÔCÀXÝÔ+ÔAÀ6ÝÔ+ÔBÀMÝÔ+ÔBÀGÝÔ+ÔFÈÝÔ+ÔHÈ.ÝÔ+ÔEÀ{ÝÔ+ÔDÀjð
ˆð ×!Ò!Ñ#Ô#ˆå%¥mÔ&EÀcÐTUÐ&VÑ&VÔ&VÑWÔW‰ˆˆ3Ý)ÝÔ+¨C¸#Ð>Ñ>Ô>ñ
ô 
‰
ˆˆsð )+ˆØ!#ˆ
å�s‘”ð 	ñ 	ˆAØ˜”8ˆDØ'(ˆM�#˜d™)œ)Ñ$å(­Ô)KÈDÑ)QÔ)QÑRÔRˆEÝ+­MÔ,QÐRVÑ,WÔ,WÑXÔXˆHØ 2‘~ˆHØ Ñ+ˆGàˆKØ�Ô7ÔOÒOÐOÝ&Ô2½cÀ$¹i¼iÐHÑHÔH�Ý*ÔEÀgÑNÔN‘��VØ�,Ô/Ô<Ò<Ð<ÅÀVÄ[ÑAQÔAQÐ<Ý*Ô5ÅÀVÄ[ÑAQÔAQÐRÑRÔR�GÝ ,Ô :¸7Ñ CÔ C‘I�C˜Ø�lÔ3Ô@Ò@Ð@Ý7AÀ$ÍÑ7NÔ7NÐ&X d§k¢k¡m¤m mÐTX˜à×ÒàØ!0×!4Ò!4°U½CÀ¹J¼JÑ!GÔ!GØ (Ø (Ø&Ø#.Ø$&Ø"$ð	ð 	ñô ð ñ õ 2ÝÔ+¨C¸!Ð<Ñ<Ô<ñ
ô 
Ñˆˆ1ˆa�ð �qŠ=ˆ=Ý:NÝÔ/°¸iÐHÑHÔHñ;ô ;Ñ7ˆJ˜ *¨iõ ˜9Ñ%Ô%ð @ð @�Ø#×'Ò'­¨J°q¬MÑ(:Ô(:Ñ;Ô;�Ø#×'Ò'­¨H°Q¬KÑ(8Ô(8Ñ9Ô9�Ø�? s Ø˜s”O LÔ1×8Ò8¸Ñ=Ô=Ð=Ø˜s”O NÔ3×:Ò:¸3Ñ?Ô?Ð?øå#Ô3Ø×/Ò/Ñ1Ô1ð
ñ 
ô 
ˆõ -ÝÔ,¨[Ñ9Ô9ñ
ô 
ˆð ð 	-ð 	-ˆDØ -°Ñ 3°t¸I´ÑFˆD�ÑØ,ˆD�ÑÐð +Øð
ð 
ð 	
r$   )F)r+   r!   r    r
   ©r    r3   )Nr:   F)r;   r<   r=   r>   r?   r!   r    r3   ©r    r   )rQ   r>   r    r3   )r    rT   )r    rY   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r/   r9   rA   rE   rH   rK   rM   r;   rP   rS   rV   rX   r¬   Ú__classcell__)r2   s   @r%   r   r   N   sÉ  ø€ € € € € € ðð ð4 4Ð3Ð3Ñ3ðð ð ð ð ð ð ð
ð ð ð ð %)Ø"*Ø%*ð	&"ð &"ð &"ð &"ð &"ð &"ð &"ðP!ð !ð !ð !ð !ð !ðð ð ð ð ð ðð ð ð ð ð ðð ð ð ð ð ðð ð ð ð ð ð+ð +ð +ð +ð +ð +ð.ð .ð .ð .ð .ð .ð(ð (ð (ð (ð (ð (ð-ð -ð -ð -ð -ð -ðC
ð C
ð C
ð C
ð C
ð C
ð C
ð C
r$   r   c                  óF   — e Zd ZU dZdZded<   	 	 	 	 	 ddd„Zdd„Zdd„ZdS )r   aŽ  Context-manager that captures CUDA work into a :class:`torch.cuda.CUDAGraph` object for later replay.

    See :ref:`CUDA Graphs <cuda-graph-semantics>` for a general introduction,
    detailed use, and constraints.

    Arguments:
        cuda_graph (torch.cuda.CUDAGraph): Graph object used for capture.
        pool (optional): Opaque token (returned by a call to :func:`~torch.cuda.graph_pool_handle()` or
            :meth:`other_Graph_instance.pool()<torch.cuda.CUDAGraph.pool>`) hinting this graph's capture
            may share memory from the specified pool. See :ref:`Graph memory management<graph-memory-management>`.
        stream (torch.cuda.Stream, optional): If supplied, will be set as the current stream in the context.
            If not supplied, ``graph`` sets its own internal side stream as the current stream in the context.
        capture_error_mode (str, optional): specifies the cudaStreamCaptureMode for the graph capture stream.
            Can be "global", "thread_local" or "relaxed". During cuda graph capture, some actions, such as cudaMalloc,
            may be unsafe. "global" will error on actions in other threads, "thread_local" will only error for
            actions in the current thread, and "relaxed" will not error on actions. Do NOT change this setting
            unless you're familiar with `cudaStreamCaptureMode <https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g9d0535d93a214cbf126835257b16ba85>`_
        enable_annotations (bool, optional): If ``True``, enables kernel annotation
            recording on entry and automatically calls
            :func:`~torch.cuda._graph_annotations.resolve_pending_annotations` before
            the capture ends.  Annotations are **not** cleared on exit so that multiple
            graphs in the same workload can accumulate annotations.
            Requires ``cuda.bindings`` package and cuda-compat >= 13.1 or CUDA driver >= 13.1.
        check_input_liveness (bool, optional): If ``True``, tracks external tensor inputs during graph capture and
            raises an error if any are deallocated before replay. This helps debug "use after free" errors
            where input tensors are garbage collected between capture and replay. Default: ``False``.

            .. note::
                Custom CUDA kernels added outside PyTorch (e.g., via cuLaunchKernel or DLPack) are not
                tracked by this mechanism.

    .. note::
        For effective memory sharing, if you pass a ``pool`` used by a previous capture and the previous capture
        used an explicit ``stream`` argument, you should pass the same ``stream`` argument to this capture.

    .. warning::
        This API is in beta and may change in future releases.

    .. _cudaStreamCaptureMode:
        https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__STREAM.html#group__CUDART__STREAM_1g9d0535d93a214cbf126835257b16ba85
    Nútorch.cuda.Stream | NoneÚdefault_capture_streamr:   FÚ
cuda_graphr   r;   r<   Ústreamr=   r>   Úenable_annotationsr!   r?   c                ój  — |€4| j         j        €(t          j                             ¦   «         | j         _        |€dn|f| _        |�|n| j         j        | _        | j        €t          d¦  «        ‚t          j                             | j        ¦  «        | _	        || _
        || _        || _        || _        d S )Nr#   zcapture_stream must not be None)r2   r·   r'   r(   ÚStreamr;   Úcapture_streamÚAssertionErrorr¹   Ú
stream_ctxr¸   r=   Ú_enable_annotationsr?   )r7   r¸   r;   r¹   r=   rº   r?   s          r%   Ú__init__zgraph.__init__š  s®   € ð ˆ>˜dœnÔCÐKÝ49´J×4EÒ4EÑ4GÔ4GˆDŒNÔ1à;?¸<°R°RÈdÈWˆŒ	àÐ(ˆFˆF¨d¬nÔ.Sð 	Ôð ÔÐ&Ý Ð!BÑCÔCÐCÝœ*×+Ò+¨DÔ,?Ñ@Ô@ˆŒØ$ˆŒØ"4ˆÔØ#5ˆÔ Ø$8ˆÔ!Ð!Ð!r$   r    r3   c                ó°  — t           j                             ¦   «          t           j        j        j        rt          j        ¦   «          t           j                             ¦   «          t           j	         
                    ¦   «          | j        rddlm}  |¦   «          | j                             ¦   «           | j        j        | j        | j        | j        dœŽ d S )Nr   )rº   )r=   r?   )r'   r(   ÚsynchronizeÚcompilerÚconfigÚforce_cudagraph_gcÚgcÚcollectÚempty_cacheÚ_CÚ_host_emptyCacherÀ   rt   rº   r¿   Ú	__enter__r¸   rA   r;   r=   r?   )r7   Ú_enable_anns     r%   rÌ   zgraph.__enter__µ  sÒ   € åŒ
×ÒÑ Ô Ð åŒ>Ô Ô3ð 	õ ŒJ‰LŒLˆLåŒ
×ÒÑ Ô Ð åŒ×!Ò!Ñ#Ô#Ð#àÔ#ð 	ØWÐWÐWÐWÐWÐWàˆK‰MŒMˆMð 	Œ×!Ò!Ñ#Ô#Ð#à%ˆŒÔ%àŒYà#Ô6à!%Ô!:ð	
ð 	
ð 	
ð 	
ð 	
ð 	
r$   ÚargsÚobjectc                óÂ   — | j         rddlm}  |¦   «          | j                             ¦   «           | j        j        |Ž  | j         rddlm}  || j        ¦  «         d S d S )Nr   )Úresolve_pending_annotations)Úremap_to_exec_graph)rÀ   rt   rÑ   r¸   rE   r¿   Ú__exit__rÒ   )r7   rÎ   rÑ   rÒ   s       r%   rÓ   zgraph.__exit__×  s”   € ØÔ#ð 	*ØQÐQÐQÐQÐQÐQà'Ð'Ñ)Ô)Ð)àŒ×#Ò#Ñ%Ô%Ð%Ø ˆŒÔ  $Ð'Ð'àÔ#ð 	1ØIÐIÐIÐIÐIÐIàÐ ¤Ñ0Ô0Ð0Ð0Ð0ð	1ð 	1r$   )NNr:   FF)r¸   r   r;   r<   r¹   r¶   r=   r>   rº   r!   r?   r!   r­   )rÎ   rÏ   r    r3   )	r¯   r°   r±   r²   r·   r³   rÁ   rÌ   rÓ   r#   r$   r%   r   r   m  sˆ   € € € € € € ð(ð (ðT 8<ÐÐ;Ð;Ð;Ñ;ð
 %)Ø+/Ø"*Ø#(Ø%*ð9ð 9ð 9ð 9ð 9ð6 
ð  
ð  
ð  
ðD1ð 1ð 1ð 1ð 1ð 1r$   r   útorch.nn.Module.r   Ú_ModuleOrCallableé   FÚ	callablesÚsample_argsútuple[Tensor, ...]Únum_warmup_itersrT   Úallow_unused_inputr;   r<   c                ó   — d S r-   r#   ©r×   rØ   rÚ   rÛ   r;   s        r%   r   r   ê  s	   € ð ˜r$   útuple[_ModuleOrCallable, ...]útuple[tuple[Tensor, ...], ...]c                ó   — d S r-   r#   rÝ   s        r%   r   r   ô  s	   € ð %( Cr$   ú1_ModuleOrCallable | tuple[_ModuleOrCallable, ...]ú3tuple[Tensor, ...] | tuple[tuple[Tensor, ...], ...]c                ó”  ‡)‡*— t          j        ¦   «         r"t          j        ¦   «         rt          d¦  «        ‚d}t	          | t
          ¦  «        s.d}| f} t          j        t
          t          df         |¦  «        f}n4t          j        t
          t
          t          df         df         |¦  «        }g Š)t          | |¦  «        D �]\  }}t	          |t           j
        j        ¦  «        r‘t          |j        ¦  «        dk    r0t          |j        ¦  «        dk    rt          |j        ¦  «        dk    st!          d¦  «        ‚t#          d„ |                     ¦   «         D ¦   «         ¦  «        st!          d¦  «        ‚t          j        j        j        |Ž }	‰)                     t          |	¦  «        ¦  «         t#          d	„ |	D ¦   «         ¦  «        st!          d
¦  «        ‚�Œd„ ‰)D ¦   «         }
d„ | D ¦   «         Š*ˆ)ˆ*fd„t/          t          | ¦  «        ¦  «        D ¦   «         }d„ t/          t          | ¦  «        ¦  «        D ¦   «         }d„ t/          t          | ¦  «        ¦  «        D ¦   «         }|€t1          ¦   «         n|}t           j                             ¦   «          t           j                             t           j                             ¦   «         ¦  «        5  t          | ||¦  «        D ]Ì\  }}}d\  }}}t/          |¦  «        D ]§}t           j        j                              ||Ž ¦  «        }t          d„ |D ¦   «         ¦  «        }t          |¦  «        dk    rRt           j                             |t          d„ |D ¦   «         ¦  «        t          d„ |D ¦   «         ¦  «        d|¬¦  «        }Œ¨|||fD ]}~ŒŒÍ	 ddd¦  «         n# 1 swxY w Y   t           j                             ¦   «          g }g }t          | ||¦  «        D ]¢\  }}}t           j                              ||¬¦  «        5   ||Ž }ddd¦  «         n# 1 swxY w Y   t           j        j         !                    |¦  «        \  }}|                     t          |¦  «        ¦  «         |                     |¦  «         Œ£g }g }t          tE          |¦  «        tE          |¦  «        tE          |¦  «        ¦  «        D �]Z\  }}}t          d„ |D ¦   «         ¦  «        } t          d„ |D ¦   «         ¦  «        }d}t          |¦  «        dk    r‹t           j                              ||¬¦  «        5  t           j                             |t          d„ |D ¦   «         ¦  «        t          d„ | D ¦   «         ¦  «        d|¬¦  «        }ddd¦  «         n# 1 swxY w Y   g }!d}"|D ]A}#|#j#        r#|�!|!                     ||"         ¦  «         |"dz  }"Œ,|!                     d¦  «         ŒBt          |!¦  «        }!|                     | ¦  «         |                     |!¦  «         �Œ\| $                    ¦   «          | $                    ¦   «          d6d-„}$g }%tK          | ¦  «        D ]¹\  }&} |$||&         ||&         ‰*|&         |
|&         ||&         ||&         ||&         ||&         ||&         ¦	  «	        }'t	          |t           j
        j        ¦  «        r7d7d5„}( |(||j&        |'|j'        ¦  «        |_'        |%                     |¦  «         Œ¤|%                     |'¦  «         Œº|r|%d         S t          |%¦  «        S )8aÙ  Accept callables (functions or :class:`nn.Module<torch.nn.Module>`\ s) and returns graphed versions.

    Each graphed callable's forward pass runs its source callable's
    forward CUDA work as a CUDA graph inside a single autograd node.

    The graphed callable's forward pass also appends
    a backward node to the autograd graph. During backward, this node runs the
    callable's backward work as a CUDA graph.

    Therefore, each graphed callable should be a drop-in replacement for its source callable
    in an autograd-enabled training loop.

    See :ref:`Partial-network capture<partial-network-capture>` for detailed use and constraints.

    If you pass a tuple of several callables, their captures will use the same memory pool.
    See :ref:`Graph memory management<graph-memory-management>` for when this is appropriate.

    Arguments:
        callables (torch.nn.Module or Python function, or tuple of these): Callable or callables to graph.
            See :ref:`Graph memory management<graph-memory-management>` for when passing a tuple of callables
            is appropriate.  If you pass a tuple of callables, their order in the tuple must be the same order
            they'll run in the live workload.
        sample_args (tuple of Tensors, or tuple of tuples of Tensors): Samples args for each callable.
            If a single callable was passed, ``sample_args`` must be a single tuple of argument Tensors.
            If a tuple of callables was passed, ``sample_args`` must be tuple of tuples of argument Tensors.
        num_warmup_iters (int): The number of warmup iterations. Currently, ``DataDistributedParallel`` needs
            11 iterations for warm up. Default: ``3``.
        allow_unused_input (bool): If False, specifying inputs that were not used when computing outputs
            (and therefore their grad is always zero) is an error. Defaults to False.
        pool (optional): Token (returned by :func:`~torch.cuda.graph_pool_handle` or
            :meth:`other_Graph_instance.pool()<torch.cuda.CUDAGraph.pool>`) that hints this graph may share memory
            with the indicated pool.  See :ref:`Graph memory management<graph-memory-management>`.

    .. note::
        The ``requires_grad`` state of each Tensor in ``sample_args`` must match the state
        that's expected for the corresponding real input in the training loop.

    .. warning::
        This API is in beta and may change in future releases.

    .. warning::
        ``sample_args`` for each callable must contain only Tensors. Other types are not allowed.

    .. warning::
        Returned callables do not support higher order differentiation (e.g., double backward).

    .. warning::
        In any :class:`~torch.nn.Module` passed to :func:`~make_graphed_callables`, only parameters
        may be trainable. Buffers must have ``requires_grad=False``.

    .. warning::
        After you pass a :class:`torch.nn.Module` through :func:`~make_graphed_callables`,
        you may not add or remove any of that Module's parameters or buffers.

    .. warning::
        :class:`torch.nn.Module`\s passed to :func:`~torch.cuda.make_graphed_callables` must not have module hooks
        registered on them at the time they are passed. However, registering hooks on modules *after* passing them
        through :func:`~torch.cuda.make_graphed_callables` is allowed.

    .. warning::
        When running a graphed callable, you must pass its arguments in the same order and format
        they appeared in that callable's ``sample_args``.

    .. warning::
        The automatic mixed precision is supported in :func:`~torch.cuda.make_graphed_callables` only with disabled
        caching. The context manager `torch.cuda.amp.autocast()` must have `cache_enabled=False`.
    z_make_graphed_callables does not support the autocast caching. Please set `cache_enabled=False`.FT.r   z§Modules must not have hooks registered at the time they are passed. However, registering hooks on modules after passing them through make_graphed_callables is allowed.c              3  ó(   K  — | ]}|j         d u V — ŒdS )FN©Úrequires_grad©Ú.0Úbs     r%   ú	<genexpr>z)make_graphed_callables.<locals>.<genexpr>d  s)   è è € ÐEÐE°A�q”¨%Ð/ÐEÐEÐEÐEÐEÐEr$   zœIn any :class:`~torch.nn.Module` passed to :func:`~make_graphed_callables`, only parameters may be trainable. All buffers must have ``requires_grad=False``.c              3  óJ   K  — | ]}t          |t          j        ¦  «        V — Œd S r-   )rŽ   r'   r   )rè   Úargs     r%   rê   z)make_graphed_callables.<locals>.<genexpr>l  s.   è è € ÐHÐH°S•:˜c¥5¤<Ñ0Ô0ÐHÐHÐHÐHÐHÐHr$   zfIn the beta API, sample_args for each callable must contain only Tensors. Other types are not allowed.c                ó,   — g | ]}t          |¦  «        ‘ŒS r#   )Úlen)rè   rÎ   s     r%   ú
<listcomp>z*make_graphed_callables.<locals>.<listcomp>t  s   € Ð!LÐ!LÐ!L°¥# d¡)¤)Ð!LÐ!LÐ!Lr$   c                ó’   — g | ]D}t          |t          j        j        ¦  «        r!t	          |                     ¦   «         ¦  «        nd ‘ŒES )r#   )rŽ   r'   ÚnnÚModuleÚtupleÚ
parameters)rè   Úcs     r%   rï   z*make_graphed_callables.<locals>.<listcomp>u  sP   € ð "ð "ð "àõ ",¨A­u¬x¬Ñ!?Ô!?ÐG�ˆa�lŠl‰nŒnÑÔÐÀRð"ð "ð "r$   c                ó2   •— g | ]}‰|         ‰|         z   ‘ŒS r#   r#   )rè   rœ   Úflatten_sample_argsÚper_callable_module_paramss     €€r%   rï   z*make_graphed_callables.<locals>.<listcomp>y  s9   ø€ ð *ð *ð *àð 	˜AÔÐ!;¸AÔ!>Ñ>ð*ð *ð *r$   c                óJ   — g | ] }t           j                             ¦   «         ‘Œ!S r#   ©r'   r(   r   ©rè   r˜   s     r%   rï   z*make_graphed_callables.<locals>.<listcomp>~  ó&   € ÐHÐHÐH¨Q•%”*×&Ò&Ñ(Ô(ÐHÐHÐHr$   c                óJ   — g | ] }t           j                             ¦   «         ‘Œ!S r#   rú   rû   s     r%   rï   z*make_graphed_callables.<locals>.<listcomp>  rü   r$   N)NNNc              3  ó(   K  — | ]}|j         ¯	|V — Œd S r-   rå   ©rè   Úos     r%   rê   z)make_graphed_callables.<locals>.<genexpr>Ž  s)   è è € Ð$KÐ$K¨1¸1¼?Ð$K QÐ$KÐ$KÐ$KÐ$KÐ$KÐ$Kr$   c              3  ó(   K  — | ]}|j         ¯	|V — Œd S r-   rå   ©rè   rœ   s     r%   rê   z)make_graphed_callables.<locals>.<genexpr>’  s=   è è € ð %ð %Ø"#¸q¼ð%Øð%ð %ð %ð %ð %ð %r$   c              3  óL   K  — | ]}|j         ¯	t          j        |¦  «        V — Œ d S r-   ©ræ   r'   Ú
empty_likerÿ   s     r%   rê   z)make_graphed_callables.<locals>.<genexpr>•  sH   è è € ð +ð +Ø45ÀAÄOð+Ý!Ô,¨QÑ/Ô/ð+ð +ð +ð +ð +ð +r$   )ÚoutputsÚinputsÚgrad_outputsÚonly_inputsÚallow_unused)r;   c              3  óP   K  — | ]!}|j         rt          j        |¦  «        nd V — Œ"d S r-   r  rÿ   s     r%   rê   z)make_graphed_callables.<locals>.<genexpr>¹  sJ   è è € ð $
ð $
ØAB 1¤?Ð<�EÔ˜QÑÔÐ¸ð$
ð $
ð $
ð $
ð $
ð $
r$   c              3  ó(   K  — | ]}|j         ¯	|V — Œd S r-   rå   rÿ   s     r%   rê   z)make_graphed_callables.<locals>.<genexpr>½  s)   è è € ÐJÐJ 1¸!¼/ÐJ˜QÐJÐJÐJÐJÐJÐJr$   c              3  ó(   K  — | ]}|j         ¯	|V — Œd S r-   rå   r  s     r%   rê   z)make_graphed_callables.<locals>.<genexpr>Ã  s)   è è € Ð TÐ T qÀAÄOÐ T Ð TÐ TÐ TÐ TÐ TÐ Tr$   c              3  ó   K  — | ]}|®|V — Œ	d S r-   r#   rÿ   s     r%   rê   z)make_graphed_callables.<locals>.<genexpr>Ä  s"   è è € Ð&WÐ&W¨QÈÈ qÈÈÈÈÐ&WÐ&Wr$   é   Ú	fwd_graphr   Ú	bwd_graphÚmodule_paramsútuple[torch.nn.Parameter, ...]Úlen_user_argsrT   Úoutput_unflatten_specútorch.utils._pytree.TreeSpecÚstatic_input_surfacerÙ   Ústatic_outputsÚstatic_grad_outputsútuple[Tensor | None, ...]Ústatic_grad_inputsr    úCallable[..., object]c	           	     ót   ‡ ‡‡‡‡‡‡‡‡‡
—  G ˆˆ ˆˆˆˆˆfd„dt           j        j        ¦  «        Š
dˆ
ˆˆfd„}	|	S )Nc                  ó€   •— e Zd Zedˆˆˆˆfd„¦   «         Zeej        j        j        dˆ ˆˆfd	„¦   «         ¦   «         Z	d
S )úOmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.GraphedÚctxrÏ   r  r   r    rÙ   c                ó˜  •— t          ‰¦  «        D ]Y}‰|                              ¦   «         ||                              ¦   «         k    r!‰|                              ||         ¦  «         ŒZ‰                     ¦   «          t	          ‰t
          ¦  «        st          dt          ‰¦  «        › �¦  «        ‚t          d„ ‰D ¦   «         ¦  «        S )Nz"static_outputs must be tuple, got c              3  ó>   K  — | ]}|                      ¦   «         V — Œd S r-   ©Údetachrÿ   s     r%   rê   zjmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.forward.<locals>.<genexpr>ö  s*   è è € Ð@Ð@¨A˜QŸXšX™ZœZÐ@Ð@Ð@Ð@Ð@Ð@r$   )r„   Údata_ptrÚcopy_rK   rŽ   ró   r¾   Útype)r   r  rœ   r  r  r  r  s      €€€€r%   ÚforwardzWmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.forwardê  sÐ   ø€ õ ˜}Ñ-Ô-ð Að A�AØ+¨AÔ.×7Ò7Ñ9Ô9¸VÀA¼Y×=OÒ=OÑ=QÔ=QÒQÐQØ,¨QÔ/×5Ò5°f¸Q´iÑ@Ô@Ð@øØ× Ò Ñ"Ô"Ð"Ý! .µ%Ñ8Ô8ð Ý(ØS½TÀ.Ñ=QÔ=QÐSÐSñô ð õ Ð@Ð@°Ð@Ñ@Ô@Ñ@Ô@Ð@r$   Úgradsc                ó  •— t          |¦  «        t          ‰¦  «        k    r/t          dt          |¦  «        › dt          ‰¦  «        › �¦  «        ‚t          ‰|¦  «        D ]F\  }}|�?|                     ¦   «         |                     ¦   «         k    r|                     |¦  «         ŒG‰                     ¦   «          t          ‰t          ¦  «        st          dt          ‰¦  «        › �¦  «        ‚t          d„ ‰D ¦   «         ¦  «        S )Nzlen(grads)=z != len(static_grad_outputs)=z&static_grad_inputs must be tuple, got c              3  óF   K  — | ]}|�|                      ¦   «         n|V — Œd S r-   r#  rç   s     r%   rê   zkmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.backward.<locals>.<genexpr>  sH   è è € ð ð ð ð #$ -�A—H’H‘J”J�J°Qðð ð ð ð ð r$   )	rî   r¾   Úzipr%  r&  rK   rŽ   ró   r'  )r   r)  ÚgÚgradr  r  r  s       €€€r%   ÚbackwardzXmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.Graphed.backwardø  s$  ø€ õ �u‘:”:¥Ð%8Ñ!9Ô!9Ò9Ð9Ý(Øi¥c¨%¡j¤jÐiÐiÍsÐSfÑOgÔOgÐiÐiñô ð õ  #Ð#6¸Ñ>Ô>ð *ð *‘G�A�tØ�}ð Ÿ:š:™<œ<¨4¯=ª=©?¬?Ò:Ð:ØŸGšG D™MœM˜MøØ× Ò Ñ"Ô"Ð"õ "Ð"4µeÑ<Ô<ð Ý(Ø[ÅÐFXÑAYÔAYÐ[Ð[ñô ð õ ð ð ð 0ðñ ô ñ ô ð r$   N)r   rÏ   r  r   r    rÙ   )r   rÏ   r)  r   r    rÙ   )
r¯   r°   r±   Ústaticmethodr(  r'   ÚautogradÚfunctionÚonce_differentiabler/  )r  r  r  r  r  r  r  s   €€€€€€€r%   ÚGraphedr  é  sœ   ø€ € € € € Øð
Að 
Að 
Að 
Að 
Að 
Að 
Að 
Añ Œ\ð
Að ØŒ^Ô$Ô8ðð ð ð ð ð ð ñ 9Ô8ñ Œ\ðð ð r$   r4  Ú	user_argsrÏ   r    c                 ó²   •— t          j        j        j        | Ž } ‰j        t          |¦  «        ‰z   Ž }t           j        j                             |‰¦  «        S r-   )r'   ÚutilsÚ_pytreeÚarg_tree_leavesÚapplyró   Útree_unflatten)r5  Úflatten_user_argsÚoutr4  r  r  s      €€€r%   ÚfunctionalizedzVmake_graphed_callables.<locals>.make_graphed_autograd_function.<locals>.functionalized  sP   ø€ õ !&¤Ô 3Ô CÀYÐ OÐØ�'”-¥%Ð(9Ñ":Ô":¸]Ñ"JÐLˆCÝ”;Ô&×5Ò5°cÐ;PÑQÔQÐQr$   )r5  rÏ   r    rÏ   )r'   r1  ÚFunction)r  r  r  r  r  r  r  r  r  r>  r4  s   ````````` @r%   Úmake_graphed_autograd_functionz>make_graphed_callables.<locals>.make_graphed_autograd_functionÞ  sœ   øøøøøøøøøø€ ð(	ð (	ð (	ð (	ð (	ð (	ð (	ð (	ð (	ð (	ð (	ð (	ð (	•e”nÔ-ñ (	ô (	ð (	ðT	Rð 	Rð 	Rð 	Rð 	Rð 	Rð 	Rð 	Rð Ðr$   r‹   rÔ   Úgraph_training_stater!   ÚgraphedúCallable[_P, _R]Úorig_fwdc                ó    ‡ ‡‡‡— dˆ ˆˆˆfd„}|S )	Nr5  ú_P.argsÚuser_kwargsú	_P.kwargsr    r   c                 ó:   •— ‰j         ‰k    r ‰| i |¤ŽS  ‰| i |¤ŽS r-   )Útraining)r5  rG  r‹   rA  rB  rD  s     €€€€r%   Únew_fwdzEmake_graphed_callables.<locals>.make_graphed_forward.<locals>.new_fwd4  s=   ø€ ð ”}Ð(<Ò<Ð<Ø&˜w¨	ÐA°[ÐAÐAÐAà'˜x¨ÐB°kÐBÐBÐBr$   )r5  rF  rG  rH  r    r   r#   )r‹   rA  rB  rD  rK  s   ```` r%   Úmake_graphed_forwardz4make_graphed_callables.<locals>.make_graphed_forward.  sC   øøøø€ ðCð Cð Cð Cð Cð Cð Cð Cð Cð �r$   )r  r   r  r   r  r  r  rT   r  r  r  rÙ   r  rÙ   r  r  r  rÙ   r    r  )
r‹   rÔ   rA  r!   rB  rC  rD  rC  r    rC  )(r'   Úis_autocast_enabledÚis_autocast_cache_enabledrw   rŽ   ró   ÚtypingÚcastr   r,  rñ   rò   rî   Ú_backward_hooksÚ_forward_hooksÚ_forward_pre_hooksr¾   ÚallÚbuffersr7  r8  r9  r‘   r„   r   r(   rÃ   r¹   r¼   Útree_leavesr1  r.  r   Útree_flattenÚreversedræ   ÚreverseÚ	enumeraterJ  r(  )+r×   rØ   rÚ   rÛ   r;   Újust_one_callableÚ_sample_argsrõ   rÎ   Úflatten_argÚper_callable_len_user_argsÚ"per_callable_static_input_surfacesÚ
fwd_graphsÚ
bwd_graphsÚmempoolr‹   r  Úgrad_inputsr  Úoutputs_gradr˜   ÚvÚper_callable_static_outputsÚ"per_callable_output_unflatten_specr  Úfunc_outputsÚflatten_outputsÚspecÚ per_callable_static_grad_outputsÚper_callable_static_grad_inputsr  r  r  r  Úgrad_idxrì   r@  Úretrœ   rB  rL  r÷   rø   s+                                            @@r%   r   r   þ  s	  øø€ õT Ô Ñ"Ô"ð 
¥uÔ'FÑ'HÔ'Hð 
ÝØmñ
ô 
ð 	
ð Ðõ �i¥Ñ'Ô'ð PØ ÐØ�Lˆ	Ýœ¥E­&°#¨+Ô$6¸ÑDÔDÐFˆˆå”{¥5­­v°s¨{Ô);¸SÐ)@Ô#AÀ;ÑOÔOˆàÐå�y ,Ñ/Ô/ð ñ ‰ˆˆ4Ý�a�œœÑ)Ô)ð 	å�AÔ%Ñ&Ô&¨!Ò+Ð+Ý˜Ô(Ñ)Ô)¨QÒ.Ð.Ý˜Ô,Ñ-Ô-°Ò2Ð2å$ðañô ð õ ÐEÐE¸¿º¹¼ÐEÑEÔEÑEÔEð Ý$ð1ñô ð õ
 ”kÔ)Ô9¸4Ð@ˆØ×"Ò"¥5¨Ñ#5Ô#5Ñ6Ô6Ð6ÝÐHÐH¸KÐHÑHÔHÑHÔHð 	Ý ð^ñô ð ñ	ð "MÐ!LÐ8KÐ!LÑ!LÔ!LÐð"ð "àð"ñ "ô "Ðð*ð *ð *ð *ð *å•s˜9‘~”~Ñ&Ô&ð*ñ *ô *Ð&ð
 IÐHµ%½¸I¹¼Ñ2GÔ2GÐHÑHÔH€JØHÐHµ%½¸I¹¼Ñ2GÔ2GÐHÑHÔH€Jà%) \ÕÑ!Ô!Ð!°t€Gõ
 
„J×ÒÑÔÐÝ	Œ×	Ò	�5œ:×,Ò,Ñ.Ô.Ñ	/Ô	/ð ð Ý03Ø�|Ð%Gñ1
ô 1
ð 	ð 	Ñ,ˆD�$Ð,ð 2BÑ.ˆK˜ ,ÝÐ+Ñ,Ô,ð ð �Ýœ+Ô-×9Ò9¸$¸$À¸+ÑFÔF�Ý$Ð$KÐ$K°Ð$KÑ$KÔ$KÑKÔK�Ý�|Ñ$Ô$ qÒ(Ð(Ý"'¤.×"5Ò"5Ø ,Ý$ð %ð %Ø';ð%ñ %ô %ñ  ô  õ &+ð +ð +Ø9@ð+ñ +ô +ñ &ô &ð %)Ø%7ð #6ñ 
#ô 
#�Køð ˜|¨[Ð9ð ð �Ø�Aðð'	ðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð õ. 
„J×ÒÑÔÐð #%ÐØ)+Ð&Ý!$ Y°¸jÑ!IÔ!Ið 8ð 8Ñˆˆd�IÝŒZ×Ò˜i¨gÐÑ6Ô6ð 	'ð 	'Ø˜4 ˜;ˆLð	'ð 	'ð 	'ñ 	'ô 	'ð 	'ð 	'ð 	'ð 	'ð 	'ð 	'øøøð 	'ð 	'ð 	'ð 	'õ !&¤Ô 3× @Ò @ÀÑ NÔ NÑˆ˜Ø#×*Ò*­5°Ñ+AÔ+AÑBÔBÐBØ*×1Ò1°$Ñ7Ô7Ð7Ð7ð (*Ð$Ø&(Ð#Ý;>ÝÐ3Ñ4Ô4ÝÐ,Ñ-Ô-Ý�ÑÔñ<ô <ð %Cñ %CÑ7Ð˜n¨iõ $ð $
ð $
ØFTð$
ñ $
ô $
ñ 
ô 
Ðõ ÐJÐJ¨ÐJÑJÔJÑJÔJˆØˆÝˆ|ÑÔ˜qÒ Ð Ý”×!Ò! )°'Ð!Ñ:Ô:ð ð Ý#œn×1Ò1Ø(Ý Ð TÐ TÐ,@Ð TÑ TÔ TÑTÔTÝ!&Ð&WÐ&WÐ2EÐ&WÑ&WÔ&WÑ!WÔ!WØ $Ø!3ð 2ñ ô �ðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð ð  ÐØˆØ'ð 	0ð 	0ˆCØÔ ð 0 [Ð%<Ø"×)Ò)¨+°hÔ*?Ñ@Ô@Ð@Ø˜A‘��à"×)Ò)¨$Ñ/Ô/Ð/Ð/Ý"Ð#5Ñ6Ô6Ðà(×/Ò/Ð0CÑDÔDÐDØ'×.Ò.Ð/AÑBÔBÐBÑBð %×,Ò,Ñ.Ô.Ð.Ø#×+Ò+Ñ-Ô-Ð-ð=ð =ð =ð =ð@ $&€CÝ˜YÑ'Ô'ð $ ð $ ‰ˆˆ4Ø0Ð0Ø�qŒMØ�qŒMØ& qÔ)Ø& qÔ)Ø.¨qÔ1Ø.¨qÔ1Ø'¨Ô*Ø,¨QÔ/Ø+¨AÔ.ñ

ô 

ˆõ �d�EœHœOÑ,Ô,ð 	 ðð ð ð ð  0Ð/Ø�d”m W¨d¬lñô ˆDŒLð �JŠJ�tÑÔÐÐà�JŠJ�wÑÔÐÐàð Ø�1Œvˆå�‰:Œ:Ðs8   ËCOÏOÏOÐ&P8Ð8P<	Ð?P<	ÕAV,Ö,V0	Ö3V0	)r    r!   r®   )rÖ   FN)r×   rÕ   rØ   rÙ   rÚ   rT   rÛ   r!   r;   r<   r    rÕ   )r×   rÞ   rØ   rß   rÚ   rT   rÛ   r!   r;   r<   r    rÞ   )r×   rá   rØ   râ   rÚ   rT   rÛ   r!   r;   r<   r    rá   )0Ú
__future__r   rÇ   rO  Úcollections.abcr   r   r   r   r   Útyping_extensionsr	   r
   r   r'   r   Útorch.cuda._utilsr   Úcuda.bindingsr   rv   r   ru   ÚImportErrorÚ
torch.cudar   rB   r   Ú_utilsr   Ú__all__r   r   ÚhasattrrÊ   Ú__dict__Útorch._Cr   r   r   r   r   r   r   rÏ   rÕ   r³   r   r#   r$   r%   ú<module>r{     sN  ðà "Ð "Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø €€€Ø $Ð $Ð $Ð $Ð $Ð $Ø <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6à €€€Ø Ð Ð Ð Ð Ð Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2ððð ð ð ð ð ð ð ð øð ð ð ð Ø€LØ€M€M€Mðøøøð
 ð Gà'Ð'Ð'Ð'Ð'Ð'ØFÐFÐFÐFÐFÐFà  Ð  Ð  Ð  Ð  Ð  ðð ð €ð €WˆT�]„]€Ø€Yˆt�_„_€ð €wˆuŒxÐ*Ñ+Ô+ð à&1 k°,Ñ&?Ô&?€E„HÔ�lÑ#Ø.9¨kÐ:NÑ.OÔ.O€E„HÔÐ*Ñ+Ø:E¸+Ø(ñ;ô ;€E„HÔÐ6Ñ7ð TÐ SÐ SÐ SÐ SÐ SÐ SÐ SÐ SÐ Sð,ð ,ð ,ð ,ð9ð 9ð 9ð 9ð\
ð \
ð \
ð \
ð \
�
ñ \
ô \
ð \
ð~v1ð v1ð v1ð v1ð v1ñ v1ô v1ð v1ðt  %Ð%6¸ÀÀfÀÔ8MÐ%MÔNÐ Ð NÐ NÐ NÑ Nð 
ð Ø$Ø $ðð ð ð ñ 
„ðð 
ð Ø$Ø $ð(ð (ð (ð (ñ 
„ð(ð Ø$Ø $ðJð Jð Jð Jð Jð Jð Js   ½A Á	AÁA