MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / block_causal_mask

Function block_causal_mask

diffsynth/models/wan_video_vae.py:19–30  ·  view source on GitHub ↗
(x, block_size)

Source from the content-addressed store, hash-verified

17
18
19def block_causal_mask(x, block_size):
20 # params
21 b, n, s, _, device = *x.size(), x.device
22 assert s % block_size == 0
23 num_blocks = s // block_size
24
25 # build mask
26 mask = torch.zeros(b, n, s, s, dtype=torch.bool, device=device)
27 for i in range(num_blocks):
28 mask[:, :,
29 i * block_size:(i + 1) * block_size, :(i + 1) * block_size] = 1
30 return mask
31
32
33class CausalConv3d(nn.Conv3d):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected