Turning large matrix into a lower triangular matrix

Hi Experts,

I need to turn a large square matrix into a lower triangual matrix (actually, I want to zero the diagonal as well). Is there a cleaner way of doing that than keeping a mask for Hadamard product?

Thank you

Is torch.tril — PyTorch 2.5 documentation what you are looking for?

1 Like