Grid_sample for sparse matrices

Hello everybody,

I want to translate and rotate a map matrix using the affine_grid and grid_sample method but want to avoid using a full 2d tensor because of very large RAM demand. My data is quite sparse, therefore I reduce the size by only keeping coordinates where values actually exist and reconstruct the map when needed. However I am struggeling to see whether there is any way to use/configure the grid_sample function to transform sparse matrices of this format:
x y value
[[4], [5]], [0.12],
[[4], [10]], [0.35],
[[24], [12]], [0.84],
[[14], [595]], [0.55],

Does anybody know whether this won’t be possible using sample_grid? The values don’t need to be included at all costs either. Thank you!

1 Like


I have exactly the same problem. Did you find a solution?


I’m also having this problem. Any solutions? Is this worth a feature request?