MatX icon indicating copy to clipboard operation
MatX copied to clipboard

[QST] Compilation issues with make_static_tensor and RealView

Open deanljohnson opened this issue 1 year ago • 2 comments

I am trying to get a feel for the matx api and usage and am running into compilation issues with static tensors. With the following code:

constexpr int N = 1'000;
auto t_samples = matx::make_static_tensor<cuda::std::complex<float>, N>();
auto real = t_samples.RealView();

I get the following compilation error:

/usr/local/include/matx/core/tensor.h(815): error: too many initializer values
      Desc new_desc{this->desc_.Shape(), std::move(strides)};
                    ^
          detected during instantiation of "auto matx::tensor_t<T, RANK, Storage, Desc>::RealView() const noexcept [with T=cuda::std::__4::complex<float>, RANK=1, Storage=matx::basic_storage<matx::raw_pointer_buffer<cuda::std::__4::complex<float>, matx::matx_allocator<cuda::std::__4::complex<float>>>>, Desc=matx::static_tensor_desc_t<1000000000LL>, U=cuda::std::__4::complex<float>]" at line 154 of /root/src/sw/algo/unit_test/test.cu

If I comment out the call to RealView I get the error:

/usr/local/include/matx/core/tensor_desc.h(374): error: identifier "matx::static_tensor_desc_t<(long long)1000000000ll  > ::shape_" is undefined in device code

Is there a reason I should not expect this to work using static tensors? The same code using make_tensor<cuda::std::complex<float>>({N}); compiles without issue.

NVCC compiler

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Wed_Aug_14_10:10:22_PDT_2024
Cuda compilation tools, release 12.6, V12.6.68
Build cuda_12.6.r12.6/compiler.34714021_0

MatX commit: 86b74bcdce3d4ef0cc1c2b7ec3bd5e6c8861ebcc (current master)

Host Compiler: gcc 11.4.1 20231218

deanljohnson avatar Oct 04 '24 02:10 deanljohnson

Hi @deanljohnson , unfortunately static tensors are one of the sources where we've had lots of compatibility issues between different compilers and versions. We will look into this, but I would recommend not using static tensors yet until you get the functionality working. Static tensors exist for saving instructions to compute offsets, which can be very helpful for tensors with many dimensions. For roughly 3 dimensions and below it won't make much of a difference.

cliffburdick avatar Oct 04 '24 02:10 cliffburdick

Thanks for the quick response @cliffburdick.

I'll avoid them for now. I don't imagine they will make too large of a difference for what I am doing anyways. This was just me trying to get a feel for matx in general.

deanljohnson avatar Oct 04 '24 02:10 deanljohnson