Skip to content

Commit 4755672

Browse files
committed
QuickGELU
1 parent f3abbed commit 4755672

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/diffusers/models/controlnets/controlnet_union.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import torch
1818
from torch import nn
19-
from transformers.activations import QuickGELUActivation as QuickGELU
2019

2120
from ...configuration_utils import ConfigMixin, register_to_config
2221
from ...image_processor import PipelineImageInput
@@ -114,6 +113,15 @@ def __setitem__(self, key, value):
114113
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
115114

116115

116+
class QuickGELU(nn.Module):
117+
"""
118+
Applies GELU approximation that is fast but somewhat inaccurate. See: https://github.com/hendrycks/GELUs
119+
"""
120+
121+
def forward(self, input: torch.Tensor) -> torch.Tensor:
122+
return input * torch.sigmoid(1.702 * input)
123+
124+
117125
class ResidualAttentionMlp(nn.Module):
118126
def __init__(self, d_model: int):
119127
super().__init__()

0 commit comments

Comments
 (0)