Shortcuts

mmcv.utils.torch_ops 源代码

# Copyright (c) OpenMMLab. All rights reserved.
import torch

from .parrots_wrapper import TORCH_VERSION
from .version_utils import digit_version

_torch_version_meshgrid_indexing = (
    'parrots' not in TORCH_VERSION
    and digit_version(TORCH_VERSION) >= digit_version('1.10.0a0'))


[文档]def torch_meshgrid(*tensors): """A wrapper of torch.meshgrid to compat different PyTorch versions. Since PyTorch 1.10.0a0, torch.meshgrid supports the arguments ``indexing``. So we implement a wrapper here to avoid warning when using high-version PyTorch and avoid compatibility issues when using previous versions of PyTorch. Args: tensors (List[Tensor]): List of scalars or 1 dimensional tensors. Returns: Sequence[Tensor]: Sequence of meshgrid tensors. """ if _torch_version_meshgrid_indexing: return torch.meshgrid(*tensors, indexing='ij') else: return torch.meshgrid(*tensors) # Uses indexing='ij' by default
Read the Docs v: v1.6.2
Versions
latest
stable
2.x
v1.6.2
v1.6.1
v1.6.0
v1.5.3
v1.5.2_a
v1.5.1
v1.5.0
v1.4.8
v1.4.7
v1.4.6
v1.4.5
v1.4.4
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.3.18
v1.3.17
v1.3.16
v1.3.15
v1.3.14
v1.3.13
dev-2.x
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.