Hello , I have the exact opposite issue !
I have a vector with  n*(n-1)/2 elements . (the elements of an upper triangular matrix matrix without the main diagonal)
I want to assign the vector into an upper triangular matrix (n by n) and still keep the whole  process  differentiable in pytorch.
I have tried : mat[np.triu_indices(n, 1)] = vector
1 is the offset besause i dont use the main diagonal.
and I get the RuntimeError: a leaf Variable that requires grad has been used in an in-place operation.
Any suggestions without using in-place operations ?