Patch GEGLU with inplace multiplication to save GPU memory.
()
| 2 | |
| 3 | |
| 4 | def patch_geglu_inplace(): |
| 5 | """Patch GEGLU with inplace multiplication to save GPU memory.""" |
| 6 | def forward(self, hidden_states): |
| 7 | hidden_states, gate = self.proj(hidden_states).chunk(2, dim=-1) |
| 8 | return hidden_states.mul_(self.gelu(gate)) |
| 9 | diffusers.models.activations.GEGLU.forward = forward |
nothing calls this directly
no outgoing calls
no test coverage detected