pytorch-poisson-image-editing icon indicating copy to clipboard operation
pytorch-poisson-image-editing copied to clipboard

Update functional.py

Open conti3000 opened this issue 1 year ago • 1 comments

Green function and laplacion send to same device in case of using a cuda device

conti3000 avatar Jan 25 '24 21:01 conti3000

Thank you for your interest in this project!

I agree that this needs to be fixed (otherwise it won't run on GPU probably) but I don't think this is the way to do it. Although this would temporarily patch the error, I think we can fix it properly:

  • Currently if green_function is passed in from the outside and it's on the wrong device, this would silently move it when we probably want to notify the user of the problem (as it could be a result of a bug somewhere else in their code).
    • Related, we should probably check the devices of all tensors at the start and give a nice error message if any mismatch
  • It would be nicer to directly create green_function on the GPU, which we could do by passing a device parameter to the helper functions which do that.

If you are already thinking about these sort of things you can edit this pull request to improve it further if you'd like, otherwise I will reject this one and add the above changes myself

matt-baugh avatar Jan 29 '24 10:01 matt-baugh