a
    d                     @   s   d Z ddl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 ddl
mZ ddlmZ eeZG d	d
 d
e	ZdS )a	  
Model Summary
=============

Generates a summary of all layers in a :class:`~pytorch_lightning.core.module.LightningModule`.

The string representation of this summary prints a table with columns containing
the name, type and number of parameters for each layer.

    N)ListTupleUnion)Callback)DeepSpeedSummary)ModelSummary)	summarize)_format_summary_tablec                   @   sx   e Zd ZdZdeddddZdddd	d
dZddeee	f d	ddZ
eeeeee f  eeeddddZdS )r   a  
    Generates a summary of all layers in a :class:`~pytorch_lightning.core.module.LightningModule`.

    Args:
        max_depth: The maximum depth of layer nesting that the summary will include. A value of 0 turns the
            layer summary off.

    Example::

        >>> from pytorch_lightning import Trainer
        >>> from pytorch_lightning.callbacks import ModelSummary
        >>> trainer = Trainer(callbacks=[ModelSummary(max_depth=1)])
       N)	max_depthreturnc                 C   s
   || _ d S N)
_max_depth)selfr    r   r/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/pytorch_lightning/callbacks/model_summary.py__init__4   s    zModelSummary.__init__z
pl.Trainerzpl.LightningModule)trainer	pl_moduler   c                 C   sJ   | j s
d S | ||}| }|j}|j}|j}|jrF| |||| d S r   )r   _summaryZ_get_summary_datatotal_parameterstrainable_parameters
model_sizeZis_global_zeror   )r   r   r   Zmodel_summarysummary_datar   r   r   r   r   r   on_fit_start7   s    zModelSummary.on_fit_startc                 C   s<   ddl m} t|j|r.|jjr.t|| jdS t|| jdS )Nr   )DeepSpeedStrategy)r   )Z&pytorch_lightning.strategies.deepspeedr   
isinstanceZstrategyZzero_stage_3r   r   r   )r   r   r   r   r   r   r   r   D   s    zModelSummary._summary)r   r   r   r   r   c                 C   s&   t |||g| R  }td|  d S )N
)r	   loginfo)r   r   r   r   Zsummary_tabler   r   r   r   K   s    zModelSummary.summarize)r
   )__name__
__module____qualname____doc__intr   r   r   r   Summaryr   staticmethodr   r   strfloatr   r   r   r   r   r   %   s   r   )r#   loggingtypingr   r   r   Zpytorch_lightningplZ$pytorch_lightning.callbacks.callbackr   Z)pytorch_lightning.utilities.model_summaryr   r   r%   r   Z7pytorch_lightning.utilities.model_summary.model_summaryr	   	getLoggerr    r   r   r   r   r   <module>   s   

