TensorRef construction fails to compile for several deferred operations

Summary

Creating TensorRef leads to compilation failure for several operation types.

Environment

  • Operating System : Godbolt.org

  • Architecture : x64

  • Compiler Version : GCC14, clang18, clang19

  • Eigen Version : trunk

Minimal Example

See godbolt.

Uncommenting any of the lines 19-21 cause a compilation failure. Lines 23-25 are a sanity check. If the expression can be assigned to a concrete tensor (they can), it is my understanding that TensorRef should work too.

In the case of broadcast, the compiler emits the error "no type named 'Dimensions' in 'Eigen::TensorBroadcastingOp<const std::array<int, 1>, const Eigen::Tensor<double, 1>>'"

Steps to reproduce

  1. Create a tensor
  2. apply a slice/reshape/broadcast (possibly others as well) operation to the tensor. Do not evaluate the expression to concrete values.
  3. Create an Eigen::TensorRef on the deferred operation.
  4. Fails to compile
Edited by Alexandre Foley