Removing `.float()` (`autocast` in fp16 will discard this (I think)). (#495)

This commit is contained in:
Nicolas Patry 2022-09-14 08:20:27 +02:00 committed by GitHub
parent ab7a78e8f1
commit 7c4b38baca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -333,7 +333,7 @@ class ResnetBlock2D(nn.Module):
# make sure hidden states is in float32
# when running in half-precision
hidden_states = self.norm1(hidden_states.float()).type(hidden_states.dtype)
hidden_states = self.norm1(hidden_states).type(hidden_states.dtype)
hidden_states = self.nonlinearity(hidden_states)
if self.upsample is not None:
@ -351,7 +351,7 @@ class ResnetBlock2D(nn.Module):
# make sure hidden states is in float32
# when running in half-precision
hidden_states = self.norm2(hidden_states.float()).type(hidden_states.dtype)
hidden_states = self.norm2(hidden_states).type(hidden_states.dtype)
hidden_states = self.nonlinearity(hidden_states)
hidden_states = self.dropout(hidden_states)