Inspecting a tensor in Visual Studio

Hi,

I found very hard to inspect a tensor (sizes, dim and data) through the watcher of the Visual Studio IDE. I can read the data with the following line (the tensor variable is myTensor with numel() == 200):

((float *)myTensor.impl_.target_->storage_.storage_impl_.target_->data_ptr_.ptr_.data_),200

but I found no way to watch the sizes, for example. If I try to print the sizes through the immediate window, I obtain the message (although I’m in debug configuration):

Function at::Tensor::sizes has no address, possibly due to compiler optimizations.

This is really too frustrating. Any solution to this?

Thanks in advance.

1 Like

Ok, I can inspect sizes with (if dim() == 2):

(int64_t *)(*((c10::AlignedCharArray<8,8>*)&(*((c10::SmallVectorTemplateCommon<__int64,void>*)&(*((c10::SmallVectorTemplateBase<__int64,1>*)&(*((c10::SmallVectorImpl<__int64>*)&myTensor.impl_.target_->sizes_)))))).FirstEl)).buffer,2

Phew, what an ugly expression! IMHO this should be improved absolutely (at least in debug configuration).