`tril` function for tensors

Hello everyone.
Does anyone know how to make tril work on tensor without using a loop as suggested here? I would appreciate any help.

Do you mean batched tril?

I used numpy’s triu_indices to set things to 0 above the diagonal (see below). An alternative can be you could also use a mask.

Best regards

Thomas

2 Likes

Yes, that is what I meant.

Nice, this is a good workaround. Thank you a lot, Thomas!