Skip to content

Commit 272537b

Browse files
committed
in-place sums to reduce memory allocations
1 parent c586b4b commit 272537b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/diffusers/models/autoencoders/autoencoder_kl_cogvideox.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def forward(
303303
hidden_states, new_conv_cache["conv1"] = self.conv1(hidden_states, conv_cache=conv_cache.get("conv1"))
304304

305305
if temb is not None:
306-
hidden_states = hidden_states + self.temb_proj(self.nonlinearity(temb))[:, :, None, None, None]
306+
hidden_states.add_(self.temb_proj(self.nonlinearity(temb))[:, :, None, None, None])
307307

308308
if zq is not None:
309309
hidden_states, new_conv_cache["norm2"] = self.norm2(hidden_states, zq, conv_cache=conv_cache.get("norm2"))
@@ -322,7 +322,7 @@ def forward(
322322
else:
323323
inputs = self.conv_shortcut(inputs)
324324

325-
hidden_states = hidden_states + inputs
325+
hidden_states.add_(inputs)
326326
return hidden_states, new_conv_cache
327327

328328

0 commit comments

Comments
 (0)