huggingface / huggingface/diffusers
Support out_dim argument for Attention block
- Langage dominant
- Python
- Étoiles
- 34.5k
- Forks
- 7.3k
- Merge moyen
- 3 j 3 h
- PR mergées (30 j)
- 91
Description
**Is your feature request related to a problem? Please describe.**
When i feed the `out_dim` argument in `__init__` in [Attention block](https://github.com/huggingface/diffusers/blob/b69fd990ad8026f21893499ab396d969b62bb8cc/src/diffusers/models/attention_processor.py#L114) it will raise the shape error, because the `query_dim != out_dim`. In this case, the following code try to keep the given channel of `hidden_states`.
> https://github.com/huggingface/diffusers/blob/b69fd990ad8026f21893499ab396d969b62bb8cc/src/diffusers/models/attention_processor.py#L1393
But it should change the channel as the output of `hidden_states = attn.to_out[0](hidden_states)`.
**Describe the solution you'd like.**
I suggest the change of code base : https://github.com/huggingface/diffusers/blob/b69fd990ad8026f21893499ab396d969b62bb8cc/src/diffusers/models/attention_processor.py#L1393
to `hidden_states = hidden_states.transpose(-1, -2).reshape(batch_size, -1, height, width)`, then it will respect the channel of `hidden_states`.
Maybe I will make a PR later.
**Describe alternatives you've considered.**
None.
**Additional context.**
None.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez dans src/diffusers/models/attention_processor.py, au niveau du bloc Attention et du code de traitement référencé autour de la ligne 1393. Reproduisez l’erreur de forme avec query_dim != out_dim, puis vérifiez que la sortie d’Attention conserve la dimension de canaux demandée et que le comportement existant de l’Attention reste inchangé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python, pytorch
- Domaine
- machine-learning
- Type d'issue
- Fonctionnalité
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 48/100