MCPcopy
hub / github.com/cubiq/ComfyUI_InstantID / reshape_tensor

Function reshape_tensor

resampler.py:19–27  ·  view source on GitHub ↗
(x, heads)

Source from the content-addressed store, hash-verified

17
18
19def reshape_tensor(x, heads):
20 bs, length, width = x.shape
21 #(bs, length, width) --> (bs, length, n_heads, dim_per_head)
22 x = x.view(bs, length, heads, -1)
23 # (bs, length, n_heads, dim_per_head) --> (bs, n_heads, length, dim_per_head)
24 x = x.transpose(1, 2)
25 # (bs, n_heads, length, dim_per_head) --> (bs*n_heads, length, dim_per_head)
26 x = x.reshape(bs, heads, length, -1)
27 return x
28
29
30class PerceiverAttention(nn.Module):

Callers 1

forwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected