MCPcopy Create free account
hub / github.com/UVA-Computer-Vision-Lab/FrameINO / shape

Method shape

architecture/embeddings.py:1980–1989  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

1978 bs, length, width = x.size()
1979
1980 def shape(x):
1981 # (bs, length, width) --> (bs, length, n_heads, dim_per_head)
1982 x = x.view(bs, -1, self.num_heads, self.dim_per_head)
1983 # (bs, length, n_heads, dim_per_head) --> (bs, n_heads, length, dim_per_head)
1984 x = x.transpose(1, 2)
1985 # (bs, n_heads, length, dim_per_head) --> (bs*n_heads, length, dim_per_head)
1986 x = x.reshape(bs * self.num_heads, -1, self.dim_per_head)
1987 # (bs*n_heads, length, dim_per_head) --> (bs*n_heads, dim_per_head, length)
1988 x = x.transpose(1, 2)
1989 return x
1990
1991 class_token = x.mean(dim=1, keepdim=True) + self.positional_embedding.to(x.dtype)
1992 x = torch.cat([class_token, x], dim=1) # (bs, length+1, width)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected