The methods LinearAlgebraOps.diagonal extract the diagonal from a tensor and return a tensor where the two given axis are replaced by the diagonal. In the simplest case of a 2D Tensor, Tensor2[L1, L2, Float32] this just returns a 1D Tensor. Tensor1[?, Float32]. The question is how to label the axis of the extracted tensor. It clearly is neither L1 not L2 but somehow a mixture of both. Currently L1 is chosen, which is convenient but not very precise.
The cleanest possibility seems to introduce a new label Diag[L1,L2] with extension methods to relabel it to something new, e.g.
t.diagonal.relabel(Axis[NewLabel])
The methods
LinearAlgebraOps.diagonalextract the diagonal from a tensor and return a tensor where the two given axis are replaced by the diagonal. In the simplest case of a 2D Tensor,Tensor2[L1, L2, Float32]this just returns a 1D Tensor.Tensor1[?, Float32]. The question is how to label the axis of the extracted tensor. It clearly is neitherL1notL2but somehow a mixture of both. CurrentlyL1is chosen, which is convenient but not very precise.The cleanest possibility seems to introduce a new label
Diag[L1,L2]with extension methods to relabel it to something new, e.g.