Skip to content

Commit

Permalink
[sharktank] Use reshape instead of view (#681)
Browse files Browse the repository at this point in the history
Fixes `RuntimeError: view size is not compatible with input tensor's
size and stride (at least one dimension spans across two contiguous
subspaces). Use .reshape(...) instead.` by using `reshape` which occurs
when running `tests/layers/mmdit_test.py` with Python 3.11.10 and
`torch==2.5.1+cpu`.
  • Loading branch information
marbre authored Dec 13, 2024
1 parent bcecd43 commit 0bec8f1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sharktank/sharktank/layers/mmdit.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def attention(q, k, v, pe):
q=q, k=k, v=v, a=None, is_causal=True, scale=None
)
x = ops.permute(x, (0, 2, 1, 3))
x = x.view(x.shape[0], x.shape[1], -1)
x = x.reshape(x.shape[0], x.shape[1], -1)

return x

Expand Down

0 comments on commit 0bec8f1

Please sign in to comment.