CoolFace
Apppublic

declare-lab/tango2

sourceHugging Faceupdated 2y agoView on Hugging Face
92likes
accelerate_utils.cpython-39.pyc16 linesDownload Raw Back to __pycache__
1a

2��'d/�@s6dZddlmZddlmZe�r*ddlZdd�ZdS)z73Accelerate utilities: Utilities related to accelerate4�)�version�)�is_accelerate_availableNcs@t�s5�St�tj�j}t�|�t�d�kr0�S�fdd�}|S)a6    Decorator that applies a registered CpuOffload hook to an arbitrary function rather than `forward`. This is useful7    for cases where a PyTorch module provides functions other than `forward` that should trigger a move to the8    appropriate acceleration device. This is the case for `encode` and `decode` in [`AutoencoderKL`].9 10    This decorator looks inside the internal `_hf_hook` property to find a registered offload hook.11 12    :param method: The method to decorate. This method should be a method of a PyTorch module.13    z0.17.0cs8t|d�r"t|jd�r"|j�|��|g|�Ri|��S)N�_hf_hook�pre_forward)�hasattrrr)�self�args�kwargs��method��U/home/deep/Projects/audio_diffusion/diffusers/src/diffusers/utils/accelerate_utils.py�wrapper+sz#apply_forward_hook.<locals>.wrapper)rr�parse�14accelerate�__version__�base_version)rZaccelerate_versionrr
rr�apply_forward_hooks15r)�__doc__�	packagingr�import_utilsrrrr
r
r
r�<module>s16