Skip to content

Strided tensor

Shane Parker requested to merge strided_tensor into master

Implement the final Layout option for Tensor_s: StridedLayout. Strided layouts will essentially make no assumptions about how the data is organized in memory, instead only using the stride_ member variable of Tensor_ to compute indices. The motivating use case for StridedTensor_ is to be able to obtain a "view" of the diagonal elements of a tensor so that we can do something like

Tensor<1> fock_eigenvalues = fock_matrix.diagonal();

Many external libraries/functions will not be compatible with fully strided layouts, so these interfaces will have to be disabled for StridedTensor_. This adds a bit of complexity because it will be the first time functions like gemm() care about the layout details.

  • StridedTensor_ prototype that can be used with a simple diagonal()
  • ConstStridedTensor_ prototype that can be used with a simple const_diagonal()
  • norm() (or move to separate function)
  • reorder()
  • transpose()
  • concept for compatibility with strided tensors
  • disable functions that are incompatible with strided tensors
    • gemm
    • verify that contract works
    • most linalg
  • test cases for multidimensional strided tensors

Edit 1

Easiest way to make sure StridedTensor_s doesn't get used in unsafe code is to just update the definition of tensorable (and hence basically all existing functions) to require contiguous or columnwise storage. So by default, algorithms will not work with StridedTensor_s, but instead qleve functions will have to opt in.

Edited by Shane Parker

Merge request reports