repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
factor | factor-master/docs/source/conf.py | # -*- coding: utf-8 -*-
#
# Factor documentation build configuration file, created by
# sphinx-quickstart on Wed May 27 11:02:27 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# Al... | 8,698 | 30.179211 | 79 | py |
DDQ | DDQ-main/tools/test.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import os.path as osp
import sys # noqa
import time
import warnings
import mmcv
import torch
from mmcv import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.ru... | 11,906 | 38.956376 | 95 | py |
DDQ | DDQ-main/tools/train.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import copy
import os
import os.path as osp
import sys # noqa
import time
import warnings
import cv2
import mmcv
from mmcv import Config, DictAction
from mmcv.runner import get_dist_info, init_dist
from mmcv.utils import get_git_hash
from mmdet import ... | 9,647 | 36.984252 | 95 | py |
DDQ | DDQ-main/mmcv-1.4.7/setup.py | import glob
import os
import platform
import re
import warnings
from pkg_resources import DistributionNotFound, get_distribution
from setuptools import find_packages, setup
EXT_TYPE = ''
try:
import torch
if torch.__version__ == 'parrots':
from parrots.utils.build_extension import BuildExtension
... | 16,829 | 38.881517 | 125 | py |
DDQ | DDQ-main/mmcv-1.4.7/examples/train.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torchvision.transforms as transforms
from torch.utils.data import DataLoader
from torchvision.datasets import CIFAR10
from mmcv.parallel import MMDataParallel
from mmcv.runner import EpochBasedRunner
from mmcv.utils i... | 2,813 | 32.105882 | 76 | py |
DDQ | DDQ-main/mmcv-1.4.7/.dev_scripts/check_installation.py | import numpy as np
import torch
from mmcv.ops import box_iou_rotated
from mmcv.utils import collect_env
def check_installation():
"""Check whether mmcv-full has been installed successfully."""
np_boxes1 = np.asarray(
[[1.0, 1.0, 3.0, 4.0, 0.5], [2.0, 2.0, 3.0, 4.0, 0.6],
[7.0, 7.0, 8.0, 8.0,... | 1,443 | 31.088889 | 77 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_parallel.py | # Copyright (c) OpenMMLab. All rights reserved.
from unittest.mock import MagicMock, patch
import pytest
import torch
import torch.nn as nn
from torch.nn.parallel import DataParallel, DistributedDataParallel
from mmcv.parallel import (MODULE_WRAPPERS, MMDataParallel,
MMDistributedDataParall... | 5,220 | 32.902597 | 74 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_load_model_zoo.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import os.path as osp
from unittest.mock import patch
import pytest
import mmcv
from mmcv.runner.checkpoint import (DEFAULT_CACHE_DIR, ENV_MMCV_HOME,
ENV_XDG_CACHE_HOME, _get_mmcv_home,
_l... | 5,478 | 36.272109 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_image/test_image_misc.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
from numpy.testing import assert_array_equal
import mmcv
try:
import torch
except ImportError:
torch = None
@pytest.mark.skipif(torch is None, reason='requires torch library')
def test_tensor2imgs():
# test tensor obj
... | 2,207 | 28.837838 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_runner/test_checkpoint.py | # Copyright (c) OpenMMLab. All rights reserved.
import sys
from collections import OrderedDict
from tempfile import TemporaryDirectory
from unittest.mock import MagicMock, patch
import pytest
import torch
import torch.nn as nn
import torch.optim as optim
from torch.nn.parallel import DataParallel
from mmcv.fileio.fil... | 17,082 | 36.710817 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_runner/test_optimizer.py | # Copyright (c) OpenMMLab. All rights reserved.
import sys
import warnings
from unittest.mock import MagicMock
import pytest
import torch
import torch.nn as nn
from mmcv.runner import OPTIMIZER_BUILDERS, DefaultOptimizerConstructor
from mmcv.runner.optimizer import build_optimizer, build_optimizer_constructor
from mm... | 23,873 | 36.24493 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_runner/test_dist_utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
from unittest.mock import patch
import pytest
from mmcv.runner import init_dist
@patch('torch.cuda.device_count', return_value=1)
@patch('torch.cuda.set_device')
@patch('torch.distributed.init_process_group')
@patch('subprocess.getoutput', return_value='127.... | 2,071 | 37.37037 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_runner/test_basemodule.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import pytest
import torch
from torch import nn
import mmcv
from mmcv.cnn.utils.weight_init import update_init_info
from mmcv.runner import BaseModule, ModuleDict, ModuleList, Sequential
from mmcv.utils import Registry, build_from_cfg
COMPONENTS = Regis... | 22,747 | 36.169935 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_runner/test_eval_hook.py | # Copyright (c) OpenMMLab. All rights reserved.
import json
import os.path as osp
import sys
import tempfile
import unittest.mock as mock
from collections import OrderedDict
from unittest.mock import MagicMock, patch
import pytest
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data imp... | 17,906 | 35.997934 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_runner/test_hooks.py | # Copyright (c) OpenMMLab. All rights reserved.
"""Tests the hooks with runners.
CommandLine:
pytest tests/test_runner/test_hooks.py
xdoctest tests/test_hooks.py zero
"""
import logging
import os.path as osp
import platform
import random
import re
import shutil
import sys
import tempfile
from unittest.mock imp... | 63,296 | 33.816832 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_runner/test_runner.py | # Copyright (c) OpenMMLab. All rights reserved.
import logging
import os
import os.path as osp
import platform
import random
import string
import tempfile
import pytest
import torch
import torch.nn as nn
from mmcv.parallel import MMDataParallel
from mmcv.runner import (RUNNERS, EpochBasedRunner, IterBasedRunner,
... | 8,674 | 28.913793 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_runner/test_fp16.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
import torch.nn as nn
from mmcv.runner.fp16_utils import auto_fp16, cast_tensor_type, force_fp32
def test_cast_tensor_type():
inputs = torch.FloatTensor([5.])
src_type = torch.float32
dst_type = torch.int32
... | 10,322 | 31.462264 | 76 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_runner/test_utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import random
import numpy as np
import torch
from mmcv.runner import set_random_seed
from mmcv.utils import TORCH_VERSION, digit_version
is_rocm_pytorch = False
if digit_version(TORCH_VERSION) >= digit_version('1.5'):
from torch.utils.cpp_extension impor... | 1,270 | 30.775 | 66 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_utils/test_logging.py | # Copyright (c) OpenMMLab. All rights reserved.
import logging
import os
import platform
import tempfile
from unittest.mock import patch
import pytest
from mmcv import get_logger, print_log
if platform.system() == 'Windows':
import regex as re
else:
import re
@patch('torch.distributed.get_rank', lambda: 0)... | 4,432 | 36.252101 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_utils/test_hub.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
from torch.utils import model_zoo
from mmcv.utils import TORCH_VERSION, digit_version, load_url
def test_load_url():
url1 = 'https://download.openmmlab.com/mmcv/test_data/saved_in_pt1.5.pth'
url2 = 'https://download.openmmlab.com/mmcv/test_data/sa... | 1,286 | 36.852941 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_utils/test_parrots_jit.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
import mmcv
from mmcv.utils import TORCH_VERSION
skip_no_parrots = pytest.mark.skipif(
TORCH_VERSION != 'parrots', reason='test case under parrots environment')
class TestJit(object):
def test_add_dict(self):
@mmcv.jit
... | 7,365 | 25.496403 | 77 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_utils/test_env.py | # Copyright (c) OpenMMLab. All rights reserved.
import sys
import pytest
import mmcv
def test_collect_env():
try:
import torch # noqa: F401
except ModuleNotFoundError:
pytest.skip('skipping tests that require PyTorch')
from mmcv.utils import collect_env
env_info = collect_env()
... | 913 | 25.114286 | 71 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_utils/test_trace.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.utils import digit_version, is_jit_tracing
@pytest.mark.skipif(
digit_version(torch.__version__) < digit_version('1.6.0'),
reason='torch.jit.is_tracing is not available before 1.6.0')
def test_is_jit_tracing():
def foo(... | 633 | 23.384615 | 64 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_utils/test_testing.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import mmcv
try:
import torch
except ImportError:
torch = None
else:
import torch.nn as nn
def test_assert_dict_contains_subset():
dict_obj = {'a': 'test1', 'b': 2, 'c': (4, 6)}
# case 1
expected_subset = {'a':... | 5,884 | 29.02551 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_build_layers.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
import torch.nn as nn
from mmcv.cnn.bricks import (ACTIVATION_LAYERS, CONV_LAYERS, NORM_LAYERS,
PADDING_LAYERS, PLUGIN_LAYERS,
build_activation_layer, build_conv_layer... | 12,977 | 30.808824 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_hswish.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch.nn.functional import relu6
from mmcv.cnn.bricks import HSwish
def test_hswish():
# test inplace
act = HSwish(inplace=True)
assert act.act.inplace
act = HSwish()
assert not act.act.inplace
input = torch.randn(1, 3, 64, 64... | 542 | 23.681818 | 50 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_hsigmoid.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.cnn.bricks import HSigmoid
def test_hsigmoid():
# test assertion divisor can not be zero
with pytest.raises(AssertionError):
HSigmoid(divisor=0)
# test with default parameters
act = HSigmoid()
input_shap... | 1,134 | 28.868421 | 61 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_flops_counter.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
import torch.nn as nn
from mmcv.cnn import get_model_complexity_info
from mmcv.cnn.utils.flops_counter import flops_to_string, params_to_string
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
# yapf: dis... | 7,060 | 45.150327 | 132 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_scale.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmcv.cnn.bricks import Scale
def test_scale():
# test default scale
scale = Scale()
assert scale.scale.data == 1.
assert scale.scale.dtype == torch.float
x = torch.rand(1, 3, 64, 64)
output = scale(x)
assert output.shape ==... | 559 | 23.347826 | 47 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_wrappers.py | # Copyright (c) OpenMMLab. All rights reserved.
from unittest.mock import patch
import pytest
import torch
import torch.nn as nn
from mmcv.cnn.bricks import (Conv2d, Conv3d, ConvTranspose2d, ConvTranspose3d,
Linear, MaxPool2d, MaxPool3d)
if torch.__version__ != 'parrots':
torch_versi... | 12,136 | 31.193634 | 94 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_depthwise_seperable_conv_module.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
import torch.nn as nn
from mmcv.cnn.bricks import DepthwiseSeparableConvModule
def test_depthwise_separable_conv():
with pytest.raises(AssertionError):
# conv_cfg must be a dict or None
DepthwiseSeparableConvModule(4, 8, 2... | 3,472 | 36.75 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_conv2d_adaptive_padding.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmcv.cnn.bricks import Conv2dAdaptivePadding
def test_conv2d_samepadding():
# test Conv2dAdaptivePadding with stride=1
inputs = torch.rand((1, 3, 28, 28))
conv = Conv2dAdaptivePadding(3, 3, kernel_size=3, stride=1)
output = conv(inputs... | 948 | 31.724138 | 63 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_weight_init.py | # Copyright (c) OpenMMLab. All rights reserved.
import random
from tempfile import TemporaryDirectory
import numpy as np
import pytest
import torch
from scipy import stats
from torch import nn
from mmcv.cnn import (Caffe2XavierInit, ConstantInit, KaimingInit, NormalInit,
PretrainedInit, TruncNor... | 22,748 | 39.623214 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_generalized_attention.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmcv.cnn.bricks import GeneralizedAttention
def test_context_block():
# test attention_type='1000'
imgs = torch.randn(2, 16, 20, 20)
gen_attention_block = GeneralizedAttention(16, attention_type='1000')
assert gen_attention_block.quer... | 2,899 | 36.662338 | 73 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_revert_syncbn.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import platform
import numpy as np
import pytest
import torch
import torch.distributed as dist
from mmcv.cnn.bricks import ConvModule
from mmcv.cnn.utils import revert_sync_batchnorm
if platform.system() == 'Windows':
import regex as re
else:
import r... | 1,949 | 31.5 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_swish.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn.functional as F
from mmcv.cnn.bricks import Swish
def test_swish():
act = Swish()
input = torch.randn(1, 3, 64, 64)
expected_output = input * F.sigmoid(input)
output = act(input)
# test output shape
assert output.sha... | 420 | 23.764706 | 48 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_fuse_conv_bn.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule, fuse_conv_bn
def test_fuse_conv_bn():
inputs = torch.rand((1, 3, 5, 5))
modules = nn.ModuleList()
modules.append(nn.BatchNorm2d(3))
modules.append(ConvModule(3, 5, 3, norm_cfg=dict(type... | 538 | 30.705882 | 65 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_context_block.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.cnn.bricks import ContextBlock
def test_context_block():
with pytest.raises(AssertionError):
# pooling_type should be in ['att', 'avg']
ContextBlock(16, 1. / 4, pooling_type='unsupport_type')
with pytest.rai... | 2,204 | 35.75 | 76 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_model_registry.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
import mmcv
from mmcv.cnn import MODELS, build_model_from_cfg
def test_build_model_from_cfg():
BACKBONES = mmcv.Registry('backbone', build_func=build_model_from_cfg)
@BACKBONES.register_module()
class ResNet(nn.Module):
def _... | 1,861 | 27.646154 | 74 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_conv_module.py | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
from unittest.mock import patch
import pytest
import torch
import torch.nn as nn
from mmcv.cnn.bricks import CONV_LAYERS, ConvModule, HSigmoid, HSwish
from mmcv.utils import TORCH_VERSION, digit_version
@CONV_LAYERS.register_module()
class ExampleConv(... | 7,703 | 29.571429 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_non_local.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
import torch.nn as nn
from mmcv.cnn import NonLocal1d, NonLocal2d, NonLocal3d
from mmcv.cnn.bricks.non_local import _NonLocalNd
def test_nonlocal():
with pytest.raises(ValueError):
# mode should be in ['embedded_gaussian', 'dot_pr... | 7,813 | 34.357466 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_cnn/test_transformer.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import pytest
import torch
from mmcv.cnn.bricks.drop import DropPath
from mmcv.cnn.bricks.transformer import (FFN, AdaptivePadding,
BaseTransformerLayer,
MultiheadAttention, Pa... | 20,447 | 28.982405 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_deform_conv.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmcv.utils import TORCH_VERSION, digit_version
try:
# If PyTorch version >= 1.6.0 and fp16 is enabled, torch.cuda.amp.autocast
# would be imported and used; we should test if our modules support it.
from tor... | 8,390 | 40.746269 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_focal_loss.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
_USING_PARROTS = True
try:
from parrots.autograd import gradcheck
except ImportError:
from torch.autograd import gradcheck
_USING_PARROTS = False
# torch.set_printoptions(precision=8, threshold=100)
inputs = [
([[1., 0], ... | 4,922 | 33.669014 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_modulated_deform_conv.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import numpy
import pytest
import torch
from mmcv.utils import TORCH_VERSION, digit_version
try:
# If PyTorch version >= 1.6.0 and fp16 is enabled, torch.cuda.amp.autocast
# would be imported and used; we should test if our modules support it.
fro... | 4,913 | 37.390625 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_masked_conv2d.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
class TestMaskedConv2d(object):
def test_masked_conv2d(self):
if not torch.cuda.is_available():
return
from mmcv.ops import MaskedConv2d
input = torch.randn(1, 3, 16, 16, requires_grad=True, device='cuda')
ma... | 496 | 30.0625 | 76 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_correlation.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.ops import Correlation
_input1 = [[[[1., 2., 3.], [0., 1., 2.], [3., 5., 2.]]]]
_input2 = [[[[1., 2., 3.], [3., 1., 2.], [8., 5., 2.]]]]
gt_out_shape = (1, 1, 1, 3, 3)
_gt_out = [[[[[1., 4., 9.], [0., 1., 4.], [24., 25., 4.]]]]]
gt_... | 1,498 | 30.893617 | 70 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_roi_align_rotated.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
_USING_PARROTS = True
try:
from parrots.autograd import gradcheck
except ImportError:
from torch.autograd import gradcheck
_USING_PARROTS = False
# yapf:disable
inputs = [([[[[1., 2.], [3., 4.]]]],
[[0... | 5,105 | 36.270073 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_upfirdn2d.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
_USING_PARROTS = True
try:
from parrots.autograd import gradcheck
except ImportError:
from torch.autograd import gradcheck, gradgradcheck
_USING_PARROTS = False
class TestUpFirDn2d(object):
"""Unit test for UpFirDn2d.
Her... | 1,884 | 30.949153 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_convex_iou.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmcv.ops import convex_giou, convex_iou
np_pointsets = np.asarray([[
1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0, 1.0, 1.0, 3.0, 3.0, 1.0, 2.0, 3.0, 3.0,
2.0, 1.5, 1.5
],
[
... | 2,233 | 38.192982 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_min_area_polygons.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmcv.ops import min_area_polygons
np_pointsets = np.asarray([[
1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0, 1.0, 1.0, 3.0, 3.0, 1.0, 2.0, 3.0, 3.0,
2.0, 1.5, 1.5
],
[
... | 950 | 29.677419 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_cc_attention.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
import torch.nn as nn
class Loss(nn.Module):
def __init__(self):
super().__init__()
def forward(self, input, target):
input = input.view(-1)
target = target.view(-1)
return torch.mean(input - targ... | 1,567 | 26.508772 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_active_rotated_filter.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmcv.ops import active_rotated_filter
np_feature = np.array([[[[[-1.4934e-01, 1.1341e+00, -1.6241e-01],
[-1.0986e+00, -1.1463e+00, -1.3176e+00],
[1.4808e+00, 7.6572e-0... | 16,836 | 64.007722 | 77 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_group_points.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.ops import grouping_operation
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_grouping_points():
idx = torch.tensor([[[0, 0, 0], [3, 3, 3], [8, 8, 8], [0, 0, 0], [0, 0, 0],
... | 4,184 | 52.653846 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_tin_shift.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import numpy as np
import pytest
import torch
_USING_PARROTS = True
try:
from parrots.autograd import gradcheck
except ImportError:
from torch.autograd import gradcheck
_USING_PARROTS = False
cur_dir = os.path.dirname(os.path.abspath(__file__))
... | 9,490 | 45.297561 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_points_in_polygons.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmcv.ops import points_in_polygons
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_points_in_polygons():
points = np.array([[300., 300.], [400., 400.], [100., 100], ... | 1,004 | 40.875 | 75 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_bilinear_grid_sample.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
import torch.nn.functional as F
class TestBilinearGridSample(object):
def _test_bilinear_grid_sample(self,
dtype=torch.float,
align_corners=False,
... | 1,854 | 43.166667 | 77 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_roipoint_pool3d.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.ops import RoIPointPool3d
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_gather_points():
feats = torch.tensor(
[[1, 2, 3.3], [1.2, 2.5, 3.0], [0.8, 2.1, 3.5], [1.6, 2.6,... | 1,716 | 45.405405 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_merge_cells.py | # Copyright (c) OpenMMLab. All rights reserved.
"""
CommandLine:
pytest tests/test_merge_cells.py
"""
import torch
import torch.nn.functional as F
from mmcv.ops.merge_cells import (BaseMergeCell, ConcatCell, GlobalPoolingCell,
SumCell)
def test_sum_cell():
inputs_x = torch.r... | 2,550 | 37.074627 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_syncbn.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import platform
import numpy as np
import pytest
import torch
import torch.distributed as dist
import torch.nn as nn
if platform.system() == 'Windows':
import regex as re
else:
import re
class TestSyncBN(object):
def dist_init(self):
ran... | 9,700 | 31.773649 | 77 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_fused_bias_leakyrelu.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
_USING_PARROTS = True
try:
from parrots.autograd import gradcheck
except ImportError:
from torch.autograd import gradcheck, gradgradcheck
_USING_PARROTS = False
class TestFusedBiasLeakyReLU(object):
@classmethod
def setup... | 1,391 | 26.84 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_assign_score_withk.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.ops import assign_score_withk
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_paconv_assign_scores():
scores = torch.tensor([[[[0.06947571, 0.6065746], [0.28462553, 0.8378516],
... | 11,671 | 60.756614 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_three_nn.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.ops import three_nn
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_three_nn():
known = torch.tensor([[[-1.8373, 3.5605,
-0.7867], [0.7615, 2.9420, 0.2... | 3,721 | 49.986301 | 77 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_nms.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
class Testnms(object):
def test_nms_allclose(self):
if not torch.cuda.is_available():
return
from mmcv.ops import nms
np_boxes = np.array([[6.0, 3.0, 8.0, 7.0], [3.0, 6.0, 9.0, 11.0],... | 7,465 | 36.898477 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_gather_points.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.ops import gather_points
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_gather_points():
features = torch.tensor([[[
-1.6095, -0.1029, -0.8876, -1.2447, -2.4031, 0.3708, ... | 2,054 | 41.8125 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_spconv.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from torch import nn
from mmcv.cnn import build_conv_layer, build_norm_layer
from mmcv.ops import (SparseConvTensor, SparseInverseConv3d, SparseSequential,
SubMConv3d)
def make_sparse_convmodule(in_channels,
... | 4,855 | 36.353846 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_box_iou_rotated.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
class TestBoxIoURotated(object):
def test_box_iou_rotated_cpu(self):
from mmcv.ops import box_iou_rotated
np_boxes1 = np.asarray(
[[1.0, 1.0, 3.0, 4.0, 0.5], [2.0, 2.0, 3.0, 4.0, 0.6],
... | 6,655 | 39.585366 | 77 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_riroi_align_rotated.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from torch.autograd import gradcheck
from mmcv.ops import RiRoIAlignRotated
np_feature = np.array([[[[1, 2], [3, 4]], [[1, 2], [4, 3]], [[4, 3], [2, 1]],
[[1, 2], [5, 6]], [[3, 4], [7, 8]], [[9, 10], ... | 3,452 | 45.04 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_roiaware_pool3d.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmcv.ops import (RoIAwarePool3d, points_in_boxes_all, points_in_boxes_cpu,
points_in_boxes_part)
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_Ro... | 6,209 | 44.661765 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_tensorrt.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
from functools import partial
from typing import Callable
import numpy as np
import onnx
import pytest
import torch
import torch.nn as nn
import torch.nn.functional as F
try:
from mmcv.tensorrt import (TRTWrapper, is_tensorrt_plugin_loaded, onnx2trt,
... | 25,082 | 30.004944 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_pixel_group.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
def test_pixel_group():
from mmcv.ops import pixel_group
np_score = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
... | 3,777 | 46.822785 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_nms_rotated.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
@pytest.mark.skipif(
not torch.cuda.is_available(),
reason='GPU is required to test NMSRotated op')
class TestNmsRotated:
def test_ml_nms_rotated(self):
from mmcv.ops import nms_rotated
np_boxes ... | 3,260 | 36.918605 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_scatter_points.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from torch.autograd import gradcheck
from mmcv.ops import DynamicScatter
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_dynamic_scatter():
feats = torch.rand(
size=(200000, 3), dty... | 5,487 | 41.215385 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_ms_deformable_attn.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.ops.multi_scale_deform_attn import (
MultiScaleDeformableAttention, MultiScaleDeformableAttnFunction,
multi_scale_deformable_attn_pytorch)
_USING_PARROTS = True
try:
from parrots.autograd import gradcheck
except ImportErr... | 6,657 | 35.382514 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_three_interpolate.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.ops import three_interpolate
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_three_interpolate():
features = torch.tensor([[[2.4350, 4.7516, 4.4995, 2.4350, 2.4350, 2.4350],
... | 3,916 | 50.539474 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_tensorrt_preprocess.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
from functools import wraps
import onnx
import torch
from mmcv.ops import nms
from mmcv.tensorrt.preprocess import preprocess_onnx
def remove_tmp_file(func):
@wraps(func)
def wrapper(*args, **kwargs):
onnx_file = 'tmp.onnx'
kwargs['o... | 2,106 | 26.363636 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_onnx.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import warnings
from functools import partial
import numpy as np
import onnx
import onnxruntime as rt
import pytest
import torch
import torch.nn as nn
import torch.nn.functional as F
from packaging import version
onnx_file = 'tmp.onnx'
@pytest.fixture(autous... | 29,253 | 34.80661 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_saconv.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.ops import SAConv2d
def test_sacconv():
# test with normal cast
x = torch.rand(1, 3, 256, 256)
saconv = SAConv2d(3, 5, kernel_size=3, padding=1)
sac_out = saconv(x)
refer_conv = nn.Conv2d(3, 5, kernel_si... | 1,724 | 34.9375 | 77 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_info.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
class TestInfo(object):
def test_info(self):
if not torch.cuda.is_available():
return
from mmcv.ops import get_compiler_version, get_compiling_cuda_version
cv = get_compiler_version()
ccv = get_compiling_cuda... | 392 | 25.2 | 77 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_knn.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.ops import knn
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_knn():
new_xyz = torch.tensor([[[-0.0740, 1.3147, -1.3625],
[-2.2769, 2.7817, -0.2334],... | 2,570 | 44.910714 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_border_align.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import numpy as np
import pytest
import torch
# [1,4c,h,w]
input_arr = [[[[1., 2., 3., 4.], [5., 6., 7., 8.], [9., 10., 11., 12.]],
[[6, 7, 5, 8], [2, 1, 3, 4], [12, 9, 11, 10]],
[[-2, -3, 2, 0], [-4, -5, 1, -1], [-1, -1, -1, -1]]... | 3,601 | 38.152174 | 74 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_ball_query.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.ops import ball_query
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_ball_query():
new_xyz = torch.tensor([[[-0.0740, 1.3147, -1.3625],
[-2.2769, 2.7... | 2,745 | 48.035714 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_bbox.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
class TestBBox(object):
def _test_bbox_overlaps(self, dtype=torch.float):
from mmcv.ops import bbox_overlaps
b1 = ... | 1,930 | 42.886364 | 77 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_roi_align.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
_USING_PARROTS = True
try:
from parrots.autograd import gradcheck
except ImportError:
from torch.autograd import gradcheck
_USING_PARROTS = False
# yapf:disable
inputs = [([[[[1., 2.], [3., 4.]]]],
[[0... | 3,649 | 33.761905 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_deform_roi_pool.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import numpy as np
import torch
_USING_PARROTS = True
try:
from parrots.autograd import gradcheck
except ImportError:
from torch.autograd import gradcheck
_USING_PARROTS = False
cur_dir = os.path.dirname(os.path.abspath(__file__))
inputs = [([[[[... | 3,641 | 36.9375 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_contour_expand.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
def test_contour_expand():
from mmcv.ops import contour_expand
np_internal_kernel_label = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
... | 2,642 | 51.86 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_furthest_point_sample.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.ops import furthest_point_sample, furthest_point_sample_with_dist
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_fps():
xyz = torch.tensor([[[-0.2748, 1.0020, -1.1674], [0.1015, ... | 2,218 | 40.867925 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_carafe.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch.autograd import gradcheck
class TestCarafe(object):
def test_carafe_naive_gradcheck(self):
if not torch.cuda.is_available():
return
from mmcv.ops import CARAFENaive
feat = torch.randn(
2, 64, 3... | 986 | 33.034483 | 74 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_corner_pool.py | # Copyright (c) OpenMMLab. All rights reserved.
"""
CommandLine:
pytest tests/test_corner_pool.py
"""
import pytest
import torch
from mmcv.ops import CornerPool
def test_corner_pool_device_and_dtypes_cpu():
"""
CommandLine:
xdoctest -m tests/test_corner_pool.py \
test_corner_pool_devi... | 2,348 | 38.15 | 69 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_psa_mask.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
import torch.nn as nn
class Loss(nn.Module):
def __init__(self):
super().__init__()
def forward(self, input, target):
input = input.view(-1)
target = target.view(-1)
return torch.mean(input - targ... | 3,159 | 30.6 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_iou3d.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmcv.ops import boxes_iou_bev, nms_bev, nms_normal_bev
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_boxes_iou_bev():
np_boxes1 = np.asarray(
[[1.0, 1.0, 3... | 2,126 | 33.306452 | 69 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_rotated_feature_align.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.ops import rotated_feature_align
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
def test_rotated_feature_align():
feature = torch.tensor([[[[1.2924, -0.2172, -0.5222, 0.1172],
... | 8,231 | 61.839695 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_voxelization.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
from mmcv.ops import Voxelization
def _get_voxel_points_indices(points, coors, voxel):
result_form = np.equal(coors, voxel)
return result_form[:, 0] & result_form[:, 1] & result_form[:, 2]
@pytest.mark.parametrize... | 5,211 | 36.228571 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/tests/test_ops/test_roi_pool.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import numpy as np
import torch
_USING_PARROTS = True
try:
from parrots.autograd import gradcheck
except ImportError:
from torch.autograd import gradcheck
_USING_PARROTS = False
cur_dir = os.path.dirname(os.path.abspath(__file__))
inputs = [([[[... | 3,037 | 35.166667 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/docs/en/conf.py | #
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or ... | 6,269 | 30.039604 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/docs/zh_cn/conf.py | #
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or ... | 6,347 | 30.117647 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/mmcv/image/misc.py | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import mmcv
try:
import torch
except ImportError:
torch = None
def tensor2imgs(tensor, mean=None, std=None, to_rgb=True):
"""Convert tensor to 3-channel images or 1-channel gray images.
Args:
tensor (torch.Tensor): Tensor th... | 1,934 | 34.833333 | 78 | py |
DDQ | DDQ-main/mmcv-1.4.7/mmcv/cnn/resnet.py | # Copyright (c) OpenMMLab. All rights reserved.
import logging
import torch.nn as nn
import torch.utils.checkpoint as cp
from .utils import constant_init, kaiming_init
def conv3x3(in_planes, out_planes, stride=1, dilation=1):
"""3x3 convolution with padding."""
return nn.Conv2d(
in_planes,
o... | 9,955 | 30.40694 | 79 | py |
DDQ | DDQ-main/mmcv-1.4.7/mmcv/cnn/vgg.py | # Copyright (c) OpenMMLab. All rights reserved.
import logging
import torch.nn as nn
from .utils import constant_init, kaiming_init, normal_init
def conv3x3(in_planes, out_planes, dilation=1):
"""3x3 convolution with padding."""
return nn.Conv2d(
in_planes,
out_planes,
kernel_size=3,... | 6,053 | 33.397727 | 77 | py |
DDQ | DDQ-main/mmcv-1.4.7/mmcv/cnn/__init__.py | # Copyright (c) OpenMMLab. All rights reserved.
from .alexnet import AlexNet
# yapf: disable
from .bricks import (ACTIVATION_LAYERS, CONV_LAYERS, NORM_LAYERS,
PADDING_LAYERS, PLUGIN_LAYERS, UPSAMPLE_LAYERS,
ContextBlock, Conv2d, Conv3d, ConvAWS2d, ConvModule,
... | 2,438 | 57.071429 | 79 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.