TensorPlay
API symbolssparse
Copy
View MarkdownDownload .md

tensorplay.sparse.spdiags

tensorplay.sparse.spdiags(diagonals, offsets, shape, layout=None)[source]

Constructs a sparse tensor from diagonals, mirroring torch.sparse.spdiags (and thereby scipy.sparse.spdiags).

Parameters:
  • diagonals – matrix of shape (len(offsets), L) (or a single vector); row j holds the values of diagonal offsets[j], read starting at column max(offset, 0).

  • offsets – int64 sequence of distinct diagonal offsets (0 = main, positive = above, negative = below).

  • shape – 2-element (M, N) output size.

  • layout – output layout tag — tensorplay.sparse_coo (default) or tensorplay.sparse_csr.

Ask DeepWiki