How can you view the values of Eigen/unsupported/Tensor objects in a debugger?

125 views Asked by At

I have a c++ program that uses a lot of tensor and matrix arithmetic. I chose the c++ Eigen library for this purpose, even though the Tensor module is not officially supported by the maintainers, because of all the functionalities it offers and because established libraries like tensorflow are also utilizing it.

I am currently always printing the tensor objects when I want to look at the values, since at least in vscode you cannot directly view the tensor values in the debugger:

enter image description here

After doing some research, I found the Native Debug extension, which I thought could allow users to visualize the values of datastructures such as Eigen::Tensor objects, by adding a file, e.g. called eigen.natvis:

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
  <Type Name="Eigen::Tensor&lt;*, *, *, *&gt;">
    <DisplayString>{{ Dimensions={NumDimensions} }}</DisplayString>
    <Expand>
      <ArrayItems>
        <Direction>Row</Direction>
        <Rank>NumDimensions</Rank>
        <IndexListItems>
          <Value>dimensions()[i]</Value>
        </IndexListItems>
        <ValuePointer>data()</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>
</AutoVisualizer>

and then modifying the .vscode/launch.json by adding the line

"setupCommands": [{"text": "Natvis.add %workspaceFolder%/eigen.natvis"}]

But unfortunately this did not have any effect. Did I do something wrong when utilizing the Native Debugger extension, or is there a different way or a different ide that allows you to directly view the values of Eigen objects? Simply doing

std::cout << u_tilde_padded << std::endl;

prints out

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

to the console, is there a way to accomplish this through the debugger as well?

0

There are 0 answers