pytorch_grid_sample_python icon indicating copy to clipboard operation
pytorch_grid_sample_python copied to clipboard

Inference too slow

Open AlanLu0808 opened this issue 4 years ago • 2 comments

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!

AlanLu0808 avatar Jan 12 '21 01:01 AlanLu0808

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)

OrkhanHI avatar Jan 12 '21 07:01 OrkhanHI

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!

zhangziwenHIT avatar Jan 18 '21 01:01 zhangziwenHIT