mmcv/tests/test_utils/test_torch_ops.py
Philipp Allgeuer f5425ab761
Add torch_meshgrid wrapper due to PyTorch change (#2044)
* Add torch_meshgrid_ij wrapper due to PyTorch change

* Update torch_meshgrid name/doc/version implementation

* Make imports local

* add ut

* ignore ut when torch is not available

Co-authored-by: zhouzaida <zhouzaida@163.com>
2022-06-15 20:36:48 +08:00

16 lines
375 B
Python

# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.utils import torch_meshgrid
def test_torch_meshgrid():
# torch_meshgrid should not throw warning
with pytest.warns(None) as record:
x = torch.tensor([1, 2, 3])
y = torch.tensor([4, 5, 6])
grid_x, grid_y = torch_meshgrid(x, y)
assert len(record) == 0