pytorch_grid_sample_python
pytorch_grid_sample_python copied to clipboard
Inference too slow
I found the grid sample in pytorch is very fast. Maybe the opearation can be done in 1ms. In contrast, this one is quiet slow, costing several mintes! Any suggestions? Tks!
Because pytorch grid sample is written in C++ and I think also it was using multi-threading. I have changed their C++ code and build only zero padding for grid sample. Below is the binary file.
https://drive.google.com/file/d/1kzUKuKMZyoHA_aFT0T2oMwvw8B2BYc3C/view?usp=sharing
You can load this binary file and use it with torch library:
import torch torch.ops.load_library("my_grid_sampler.cpython-36m-x86_64-linux-gnu.so") #Call the function torch.ops.mynamespace.my_grid_sampler(image, grid)
Thank you for your work!When I use your c++ binary,an error will be reported as:
Segmentation fault (core dumped)
And my calling method is as follows(in first-order-model):
import torch torch.ops.load_library("my_grid_sampler.cpython-36m-x86_64-linux-gnu.so") #Call the function #sparse_deformed = F.grid_sample(source_repeat, sparse_motions) sparse_deformed = torch.ops.mynamespace.my_grid_sampler(source_repeat, sparse_motions) Thank you!