teamtomo / torch-fourier-slice

Fourier slice extraction/insertion in PyTorch
BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

Type mismatch #5

Open brisvag opened 1 month ago

brisvag commented 1 month ago

Tried to run the "example" in projection_backprojection_cycle.py.

After adjusting it to make it run on some local data, I get the following error:

  File "/home/brisvag/git/teamtomo/torch-fourier-slice/src/torch_fourier_slice/slice_insertion/_insert_central_slices_rfft_3d.py", line 73, in insert_central_slices_rfft_3d
    dft_3d, weights = insert_into_image_3d(
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/home/brisvag/venv/torch-fourier-slice/lib/python3.12/site-packages/torch_image_lerp/linear_interpolation_3d.py", line 140, in insert_into_image_3d
    add_data_at_corner(0, 0, 0)
  File "/home/brisvag/venv/torch-fourier-slice/lib/python3.12/site-packages/torch_image_lerp/linear_interpolation_3d.py", line 137, in add_data_at_corner
    weights.index_put_(indices=(zc, yc, xc), values=w, accumulate=True)
RuntimeError: Index put requires the source and destination dtypes match, got Double for the destination and ComplexDouble for the source.

I'm not sure I get where the problem needs to be fixed.

alisterburt commented 1 month ago

Hehe, ugh - this one is super annoying and I'm also not sure where is the best place to fix it

I think all tensors generated inside the function should be made compatible with the input tensor. The reason I'm not 100% here is that precision is important when accumulating so originally I was forcing the accumulation to happen in float64...

alisterburt commented 1 month ago

Oh wait, this seems different - weights should be real valued, I must have cast to complex in an effort to fix the issue I described above...

alisterburt commented 1 month ago

c.f. #6 for the start of fixing this