(self, input_tensor: torch.Tensor, temb: torch.Tensor, *args, **kwargs)
| 146 | ) |
| 147 | |
| 148 | def forward(self, input_tensor: torch.Tensor, temb: torch.Tensor, *args, **kwargs) -> torch.Tensor: |
| 149 | if len(args) > 0 or kwargs.get("scale", None) is not None: |
| 150 | deprecation_message = "The `scale` argument is deprecated and will be ignored. Please remove it, as passing it will raise an error in the future. `scale` should directly be passed while calling the underlying pipeline component i.e., via `cross_attention_kwargs`." |
| 151 | deprecate("scale", "1.0.0", deprecation_message) |
| 152 | |
| 153 | hidden_states = input_tensor |
| 154 | |
| 155 | hidden_states = self.norm1(hidden_states, temb) |
| 156 | |
| 157 | hidden_states = self.nonlinearity(hidden_states) |
| 158 | |
| 159 | if self.upsample is not None: |
| 160 | # upsample_nearest_nhwc fails with large batch sizes. see https://github.com/huggingface/diffusers/issues/984 |
| 161 | if hidden_states.shape[0] >= 64: |
| 162 | input_tensor = input_tensor.contiguous() |
| 163 | hidden_states = hidden_states.contiguous() |
| 164 | input_tensor = self.upsample(input_tensor) |
| 165 | hidden_states = self.upsample(hidden_states) |
| 166 | |
| 167 | elif self.downsample is not None: |
| 168 | input_tensor = self.downsample(input_tensor) |
| 169 | hidden_states = self.downsample(hidden_states) |
| 170 | |
| 171 | hidden_states = self.conv1(hidden_states) |
| 172 | |
| 173 | hidden_states = self.norm2(hidden_states, temb) |
| 174 | |
| 175 | hidden_states = self.nonlinearity(hidden_states) |
| 176 | |
| 177 | hidden_states = self.dropout(hidden_states) |
| 178 | hidden_states = self.conv2(hidden_states) |
| 179 | |
| 180 | if self.conv_shortcut is not None: |
| 181 | input_tensor = self.conv_shortcut(input_tensor) |
| 182 | |
| 183 | output_tensor = (input_tensor + hidden_states) / self.output_scale_factor |
| 184 | |
| 185 | return output_tensor |
| 186 | |
| 187 | |
| 188 | class ResnetBlock2D(nn.Module): |
nothing calls this directly
no test coverage detected