Unverified Commit 74330083 authored by Younes Belkada's avatar Younes Belkada Committed by GitHub
Browse files

[`ViTHybrid`] fix last `accelerate` slow test (#20705)

* fix last slow test

* revert deletion

* Update src/transformers/models/vit_hybrid/modeling_vit_hybrid.py
parent 73198509
......@@ -358,7 +358,6 @@ class ViTHybridOutput(nn.Module):
return hidden_states
# Copied from transformers.models.vit.modeling_vit.ViTLayer with ViT->ViTHybrid
class ViTHybridLayer(nn.Module):
"""This corresponds to the Block class in the timm implementation."""
......@@ -387,7 +386,8 @@ class ViTHybridLayer(nn.Module):
outputs = self_attention_outputs[1:] # add self attentions if we output attention weights
# first residual connection
hidden_states = attention_output + hidden_states
# We assign to correct device for `accelerate`, check: https://github.com/huggingface/transformers/pull/20705/
hidden_states = attention_output + hidden_states.to(attention_output.device)
# in ViTHybrid, layernorm is also applied after self-attention
layer_output = self.layernorm_after(hidden_states)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment