27/42
Part 4 of 6 · Shapes and the maskLearn and do
If the name doesn't come to you, build the mask in forward
In an interview you can build the triangle inside forward, on the input's device:
mask = torch.tril(torch.ones(T, T, dtype=torch.bool, device=x.device))
That builds a small triangle on every call, with the same result. Say that you would keep it as a buffer, and that's a fine answer. The task in the editor names the call for you.
Buffers are saved by default. How much does a 1024 × 1024 bool mask add to each layer of a checkpoint?
Pick an answer above to see the rest