Caffe2 - Python API
A deep learning, cross platform ML framework
Public Member Functions | Public Attributes | List of all members
torch.autograd.profiler.profile Class Reference
Inheritance diagram for torch.autograd.profiler.profile:

Public Member Functions

def __init__ (self, enabled=True, use_cuda=False)
 
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_val, exc_tb)
 
def __repr__ (self)
 
def __str__ (self)
 
def table (self, sort_by=None)
 
def export_chrome_trace (self, path)
 
def key_averages (self)
 
def total_average (self)
 

Public Attributes

 enabled
 
 use_cuda
 
 function_events
 
 entered
 

Detailed Description

Context manager that manages autograd profiler state and holds a summary of results.

Arguments:
    enabled (bool, optional): Setting this to False makes this context manager a no-op.
        Default: ``True``.

    use_cuda (bool, optional): Enables timing of CUDA events as well using the cudaEvent API.
        Adds approximately 4us of overhead to each tensor operation.
        Default: ``False``

.. warning:
    This context managers should not be called recursively, i.e. at most one
    instance should be enabled at any given time.

Example:
    >>> x = torch.randn((1, 1), requires_grad=True)
    >>> with torch.autograd.profiler.profile() as prof:
    ...     y = x ** 2
    ...     y.backward()
    >>> # NOTE: some columns were removed for brevity
    ... print(prof)
    -------------------------------------  ---------------  ---------------
    Name                                          CPU time        CUDA time
    -------------------------------------  ---------------  ---------------
    PowConstant                                  142.036us          0.000us
    N5torch8autograd9GraphRootE                   63.524us          0.000us
    PowConstantBackward                          184.228us          0.000us
    MulConstant                                   50.288us          0.000us
    PowConstant                                   28.439us          0.000us
    Mul                                           20.154us          0.000us
    N5torch8autograd14AccumulateGradE             13.790us          0.000us
    N5torch8autograd5CloneE                        4.088us          0.000us

Definition at line 129 of file profiler.py.


The documentation for this class was generated from the following file: