a
    Aþdå  ã                   @   sN   d dl mZ d dlZd dlZddd„Zdd„ Zdd„ Zg Zd	d
„ Z	dd„ Z
dS )é    )Ú
checkpointNc                 C   s   t | j||ƒS ©N©r   Ú_forward)ÚselfÚxÚcontext© r	   úD/var/www/html/stable-diffusion-webui/modules/sd_hijack_checkpoint.pyÚBasicTransformerBlock_forward   s    r   c                 C   s   t | j|ƒS r   r   )r   r   r	   r	   r
   ÚAttentionBlock_forward   s    r   c                 C   s   t | j||ƒS r   r   )r   r   Úembr	   r	   r
   ÚResBlock_forward   s    r   c                   C   sh   t tƒdkrd S t tjjjjtjjj	j
jtjjj	jjg¡ ttjjj_ttjjj	j
_ttjjj	j_d S )Nr   )ÚlenÚstoredÚextendÚldmÚmodulesÚ	attentionÚBasicTransformerBlockÚforwardÚdiffusionmodulesÚopenaimodelÚResBlockÚAttentionBlockr   r   r   r	   r	   r	   r
   Úadd   s    
ýr   c                   C   sP   t tƒdkrd S td tjjj_td tjjjj	_td tjjjj
_t ¡  d S )Nr   é   é   )r   r   r   r   r   r   r   r   r   r   r   Úclearr	   r	   r	   r
   Úremove%   s    r   )N)Útorch.utils.checkpointr   Úldm.modules.attentionr   Ú(ldm.modules.diffusionmodules.openaimodelr   r   r   r   r   r   r	   r	   r	   r
   Ú<module>   s   
