Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace the numpy.meshgrid() with more efficient torch.meshgrid() (#1475
) Summary: This PR fixes a performance issue for the model [Super-SloMo](/~https://github.com/pytorch/benchmark/tree/main/torchbenchmark/models/Super_SloMo). The [`backwarp` class](/~https://github.com/pytorch/benchmark/blob/main/torchbenchmark/models/Super_SloMo/slomo_model.py#L213) calls `np.meshgrid()` and `torch.tensor()` to create a grid in [the class constructor](/~https://github.com/pytorch/benchmark/blob/main/torchbenchmark/models/Super_SloMo/slomo_model.py#L232). The `torch` modules provides similar API [`torch.meshgrid()`](https://pytorch.org/docs/stable/generated/torch.meshgrid.html) with far better performance. According to my [example profiling script](https://gist.github.com/CuiJinku/d85436d31aade0f49d13cc7e5f4f844b), the `torch.meshgrid()` has **25X** speedup on a single NVIDIA 3090 GPU. Pull Request resolved: #1475 Reviewed By: aaronenyeshi Differential Revision: D43954893 Pulled By: xuzhao9 fbshipit-source-id: 2b38e653594a64364fe299c84a327d5407ba39dc
- Loading branch information