/usr/local/lib64/python3.6/site-packages/torch/cuda/__pycache__
NameSizeModeActions
comm.cpython-36.pyc3720644editdlrm
error.cpython-36.pyc1430644editdlrm
graphs.cpython-36.pyc158110644editdlrm
memory.cpython-36.pyc217170644editdlrm
nccl.cpython-36.pyc34440644editdlrm
nvtx.cpython-36.pyc19660644editdlrm
profiler.cpython-36.pyc16320644editdlrm
random.cpython-36.pyc55200644editdlrm
sparse.cpython-36.pyc1440644editdlrm
streams.cpython-36.pyc94850644editdlrm
_utils.cpython-36.pyc18920644editdlrm
__init__.cpython-36.pyc232100644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/cuda/__pycache__/graphs.cpython-36.pyc (15811B)
3 EgI@sddlZddlZddlmZeejdsHedejjd<edejjd<ddlmZddlm Z d d Z Gd d d ejjZ Gd dde Z ddZdS)N) _dummy_typeZ_CudaStreamBase _CUDAGraph_graph_pool_handle)r)rcCstS)z Returns an opaque token representing the id of a graph memory pool. See :ref:`Graph memory management`. .. warning:: This API is in beta and may change in future releases. )rrr=/usr/local/lib64/python3.6/site-packages/torch/cuda/graphs.pygraph_pool_handlesrcsjeZdZdZfddZfddZdfdd Zfd d Zfd d Zfd dZ fddZ Z S) CUDAGraphzw Wrapper around a CUDA graph. .. warning:: This API is in beta and may change in future releases. cstt|j|S)N)superr __new__)cls) __class__rrr $szCUDAGraph.__new__cstt|jdS)N)r r __init__)self)r rrr'szCUDAGraph.__init__Ncs,|dkrtt|jntt|j|dS)aX Begins 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()`) that hints this graph may share memory with the indicated pool. See :ref:`Graph memory management`. N)r r capture_begin)rpool)r rrr*szCUDAGraph.capture_begincstt|jdS)aP Ends 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 r capture_end)r)r rrr>s zCUDAGraph.capture_endcstt|jdS)z? Replays the CUDA work captured by this graph. N)r r replay)r)r rrrIszCUDAGraph.replaycstt|jdS)zD Deletes the graph currently held by this instance. N)r r reset)r)r rrrOszCUDAGraph.resetcstt|jS)z Returns 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 r)r)r rrrUszCUDAGraph.pool)N) __name__ __module__ __qualname____doc__r rrrrrr __classcell__rr)r rr s    r c@s.eZdZdZdZd ddZddZddZdS) grapha Context-manager that captures CUDA work into a :class:`torch.cuda.CUDAGraph` object for later replay. See :ref:`CUDA Graphs ` 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()`) hinting this graph's capture may share memory from the specified pool. See :ref:`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. .. 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. NcCsl|jjdkrtjj|j_|dkr&fn|f|_|dk r:|n|jj|_|jdk sRttjj|j|_ ||_ dS)N) r default_capture_streamtorchcudaStreamrZcapture_streamAssertionErrorstream stream_ctx cuda_graph)rr"rr rrrrws zgraph.__init__cCs8tjjtjtjj|jj|jj |j dS)N) rr synchronizegcZcollectZ empty_cacher! __enter__r"rr)rrrrr%s    zgraph.__enter__cCs|jj|jj|||dS)N)r"rr!__exit__)rexc_type exc_value tracebackrrrr&s zgraph.__exit__)NN)rrrrrrr%r&rrrrr^s   rc s&d}t|tsd}|f}fxt|D]\}}t|tjjrt|jdkrjt|jdkrjt|j dksrt d#t dd|j Dst d%t d d|Ds*t d&q*WddD}dd|Dfddt t|D}ddt t|D}ddt t|D}t} tjjtjjtjjxt||D]v\} }} xdt dD]X} | |} t| tjrx| fn| } tjj| tdd| Dtdd| Dddd}qXW~ ~qDWWdQRXtjjg}g}xtt||D]d\} }}tjj|| d| |} WdQRXt| tjr6|jd| f} n |jd|j| qWg}g}xtt|t|t|tD]\} }}}t dd|Dst dtdd|D}tjj|| d*tjj|tdd| D|ddd}WdQRXg}d}x8| D]0}|jr$|j|||d7}n |jdqWt|}|j||j|qxWtt|}tt|}dd }g}xt|D]\}} |||||||||||||||||| }t| tjjrd!d"}|| | j|| j| _|j| n |j|qW|r|dSt|S)'a Accepts callables (functions or :class:`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` 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` 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` 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. .. 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 be a tuple of Tensors. Other types and keyword args 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:: All Tensor outputs of graphed callables must require grad. FTrz_Modules must not have hooks registered at the time they are passed. However, registering hooks zHon modules after passing them through make_graphed_callables is allowed.css|]}|jdkVqdS)FN) requires_grad).0brrr sz)make_graphed_callables..z+In any :class:`~torch.nn.Module` passed to zY:func:`~make_graphed_callables`, only parameters may be trainable. All buffers must have z``requires_grad=False``.css|]}t|tjVqdS)N) isinstancerTensor)r+argrrrr-szIn the beta API, sample_args z[for each callable must be a tuple of Tensors. Other types and keyword args are not allowed.cSsg|] }t|qSr)len)r+argsrrr sz*make_graphed_callables..cSs*g|]"}t|tjjr"t|jnfqSr)r.rnnModuletuple parameters)r+crrrr3scsg|]}||qSrr)r+i)per_callable_module_params sample_argsrrr3scSsg|]}tjjqSr)rrr )r+_rrrr3scSsg|]}tjjqSr)rrr )r+r<rrrr3scss|]}|jr|VqdS)N)r*)r+r9rrrr-scss|]}tj|VqdS)N)r empty_like)r+orrrr-s)outputsinputsZ grad_outputsZ only_inputsZ allow_unusedN)rcss|] }|jVqdS)N)r*)r+r?rrrr-,sz/Outputs of graphed callables must require grad.css|]}tj|VqdS)N)rr>)r+r?rrrr--scss|]}|jr|VqdS)N)r*)r+r9rrrr-1src s8G fdddtjjfdd} | S)Ncs@eZdZefddZeejjjfddZ dS)zOmake_graphed_callables..make_graphed_autograd_function..Graphedcsdx:tD].}|j||jkr |j||q WjttsRttddDS)Ncss|]}|jVqdS)N)detach)r+r?rrrr-]szjmake_graphed_callables..make_graphed_autograd_function..Graphed.forward..)rangedata_ptrcopy_rr.r6r)ctxrAr9) fwd_graph len_user_argsstatic_input_surfacestatic_outputsrrforwardUs zWmake_graphed_callables..make_graphed_autograd_function..Graphed.forwardcspxFt|D]8\}}|dkr*|dksDtq |j|jkr |j|q Wjtts^ttddDS)Ncss"|]}|dk r|jn|VqdS)N)rB)r+r,rrrr-nszkmake_graphed_callables..make_graphed_autograd_function..Graphed.backward..)ziprrDrErr.r6)rFZgradsggrad) bwd_graphstatic_grad_inputsstatic_grad_outputsrrbackward_szXmake_graphed_callables..make_graphed_autograd_function..Graphed.backwardN) rrr staticmethodrKrautogradfunctionZonce_differentiablerRr)rOrGrHrPrQrIrJrrGraphedTs rVcsj|}r|dS|S)Nr)apply) user_argsout)rV module_paramsoutput_was_tensorrrfunctionalizedpszVmake_graphed_callables..make_graphed_autograd_function..functionalized)rrTZFunction) rGrOrZrHr[rIrJrQrPr\r) rVrOrGrHrZr[rPrQrIrJrmake_graphed_autograd_functionKs $z>make_graphed_callables..make_graphed_autograd_functioncsfdd}|S)Ncsjkr|S|SdS)N)training)rX)funcgraph_training_stategraphedorig_fwdrrnew_fwds zEmake_graphed_callables..make_graphed_forward..new_fwdr)r_r`rarbrcr)r_r`rarbrmake_graphed_forwardsz4make_graphed_callables..make_graphed_forwardzModules 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.zIn any :class:`~torch.nn.Module` passed to :func:`~make_graphed_callables`, only parameters may be trainable. All buffers must have zIn any :class:`~torch.nn.Module` passed to :func:`~make_graphed_callables`, only parameters may be trainable. All buffers must have ``requires_grad=False``.zxIn the beta API, sample_args for each callable must be a tuple of Tensors. Other types and keyword args are not allowed.)r.r6rLrr4r5r1Z_backward_hooksZ_forward_hooksZ_forward_pre_hooksrallbuffersrCrrr#r rr/rTrNrappendreversedr*list enumerater^rK) Z callablesr;Zjust_one_callabler8r2Zper_callable_len_user_argsZ"per_callable_static_input_surfacesZ fwd_graphsZ bwd_graphsZmempoolr_rIr<r@Z grad_inputsZper_callable_static_outputsZper_callable_output_was_tensorrGZ per_callable_static_grad_outputsZper_callable_static_grad_inputsrJrOrZrQrPZgrad_idxr0r]retr9rardr)r:r;rmake_graphed_callabless? ,           /   rl)r$r_utilsrhasattr_C__dict__Ztorch._Crrrr objectrrlrrrrs     A<