o
    %ݫi                     @   s(   d Z ddlZddlmZ 	dddZdS )	z\Wrapper to handle PyTorch profiling and benchmarking.

Author:
    * Titouan Parcollet 2024
    N)profiler   tensorboard_logsc                 C   s4   t j|d}tjtjd| |ddt|dddS )a  Wrapper to create a PyTorch profiler to benchmark training of speechbrain.core.Brain instances.
    See ``torch.profiler.profile`` documentation for details (brief summary below).

    Arguments
    ---------
    profile_warmup: int
        Number of warmup step before starting to log.
    profile_steps: int
        Number of steps to log after warmup.
    logdir: str
        Path to the output folder of the logs.

    Returns
    -------
    profiler
    profiler_logsr      )waitwarmupactiverepeatT)scheduleon_trace_readyrecord_shapes
with_stack)ospathjoinr   profiler   tensorboard_trace_handler)profile_warmupprofile_stepslogdir r   O/home/ubuntu/.local/lib/python3.10/site-packages/speechbrain/utils/profiling.pyprepare_profiler   s   r   )r   r   r   )__doc__r   torchr   r   r   r   r   r   <module>   s
    