Skip to content

Commit 2da9dd7

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b4a890c commit 2da9dd7

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/neurosis/modules/attention.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,13 @@ def forward(
325325

326326
b, _, _ = q.shape
327327
q, k, v = map(
328-
lambda t: t.unsqueeze(3)
329-
.reshape(b, t.shape[1], self.heads, self.dim_head)
330-
.permute(0, 2, 1, 3)
331-
.reshape(b * self.heads, t.shape[1], self.dim_head)
332-
.contiguous(),
328+
lambda t: (
329+
t.unsqueeze(3)
330+
.reshape(b, t.shape[1], self.heads, self.dim_head)
331+
.permute(0, 2, 1, 3)
332+
.reshape(b * self.heads, t.shape[1], self.dim_head)
333+
.contiguous()
334+
),
333335
(q, k, v),
334336
)
335337

src/neurosis/modules/diffusion/model.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,13 @@ def attention(self, h_: Tensor) -> Tensor:
202202
q, k, v = map(lambda x: rearrange(x, "b c h w -> b (h w) c"), (q, k, v))
203203

204204
q, k, v = map(
205-
lambda t: t.unsqueeze(3)
206-
.reshape(B, t.shape[1], 1, C)
207-
.permute(0, 2, 1, 3)
208-
.reshape(B * 1, t.shape[1], C)
209-
.contiguous(),
205+
lambda t: (
206+
t.unsqueeze(3)
207+
.reshape(B, t.shape[1], 1, C)
208+
.permute(0, 2, 1, 3)
209+
.reshape(B * 1, t.shape[1], C)
210+
.contiguous()
211+
),
210212
(q, k, v),
211213
)
212214
out = xops.memory_efficient_attention(q, k, v, attn_bias=None, op=self.attention_op)

0 commit comments

Comments
 (0)