Skip to content

Random tensor print compile problem with EIGEN_USE_GPU defined

Summary

I tried to use std::cout to print a random tensor, but it returned a series of compilation errors. I also tried using a CXX version code by removing EIGEN_USE_GPU, and it worked as expected. I believe this is a bug.

Environment

  • Operating System : Linux
  • Architecture : x64 ...
  • Eigen Version : master
  • Compiler Version : nvcc(cuda 12.3)
  • Compile Flags : -O

Minimal Example

cmake_minimum_required(VERSION 3.0.0)
project(Test VERSION 0.1.0 LANGUAGES CUDA)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_FLAGS --expt-relaxed-constexpr)

add_executable(Test main.cu)
target_include_directories(Test PUBLIC /home/yang/streams_test/eigen)
#define EIGEN_USE_GPU
#include "eigen3/unsupported/Eigen/CXX11/Tensor"
#include <iostream>
int main() {

  Eigen::Tensor<double, 3, Eigen::RowMajor> a(32, 96, 96);
  a.setRandom();
  std::cout << a << std::endl;

}

Relevant logs

TensorIO

Edited by Ghost User