Skip to content

Commit

Permalink
[Fix] Fix ci (#3196)
Browse files Browse the repository at this point in the history
* [Fix] Fix pre-commit-hook for python3.12

* [Fix] clang lint

* use ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION

* Add todo
  • Loading branch information
HAOCHENYE authored Nov 4, 2024
1 parent c46684c commit 1393257
Show file tree
Hide file tree
Showing 46 changed files with 224 additions and 211 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
- name: Set up Python 3.10.15
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: '3.10.15'
- name: Install pre-commit hook
run: |
pip install pre-commit
pre-commit install
- name: Linting
run: pre-commit run --all-files
- name: Format c/cuda codes with clang-format
uses: DoozyX/clang-format-lint-action@v0.11
uses: DoozyX/clang-format-lint-action@v0.18
with:
source: mmcv/ops/csrc
extensions: h,c,cpp,hpp,cu,cuh
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pr_stage_test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: pr_stage_test

env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

on:
pull_request:
paths-ignore:
Expand Down
16 changes: 11 additions & 5 deletions .pre-commit-config-zh-cn.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
exclude: ^tests/data/
repos:
- repo: https://gitee.com/openmmlab/mirrors-flake8
rev: 5.0.4
- repo: https://github.com/pre-commit/pre-commit
rev: v4.0.0
hooks:
- id: validate_manifest
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
- repo: https://gitee.com/openmmlab/mirrors-isort
Expand All @@ -13,7 +17,7 @@ repos:
hooks:
- id: yapf
- repo: https://gitee.com/openmmlab/mirrors-pre-commit-hooks
rev: v4.3.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-yaml
Expand All @@ -39,6 +43,7 @@ repos:
- mdformat_frontmatter
- linkify-it-py
- repo: https://gitee.com/openmmlab/mirrors-docformatter
# TODO:https://github.com/PyCQA/docformatter/issues/289
rev: v1.3.1
hooks:
- id: docformatter
Expand All @@ -53,15 +58,16 @@ repos:
hooks:
- id: check-copyright
args: ["mmcv", "tests", "--excludes", "mmcv/ops"]
- repo: https://gitee.com/openmmlab/mirrors-mypy
rev: v0.812
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0
hooks:
- id: mypy
exclude: |-
(?x)(
^test
| ^docs
)
additional_dependencies: ["types-setuptools", "types-requests"]
# - repo: local
# hooks:
# - id: clang-format
Expand Down
13 changes: 9 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
exclude: ^tests/data/
repos:
- repo: https://github.com/pre-commit/pre-commit
rev: v4.0.0
hooks:
- id: validate_manifest
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
rev: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/PyCQA/isort
Expand All @@ -13,7 +17,7 @@ repos:
hooks:
- id: yapf
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-yaml
Expand All @@ -39,7 +43,7 @@ repos:
- mdformat_frontmatter
- linkify-it-py
- repo: https://github.com/myint/docformatter
rev: v1.3.1
rev: 06907d0
hooks:
- id: docformatter
args: ["--in-place", "--wrap-descriptions", "79"]
Expand All @@ -54,14 +58,15 @@ repos:
- id: check-copyright
args: ["mmcv", "tests", "--excludes", "mmcv/ops"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.812
rev: v1.2.0
hooks:
- id: mypy
exclude: |-
(?x)(
^test
| ^docs
)
additional_dependencies: ["types-setuptools", "types-requests"]
# - repo: local
# hooks:
# - id: clang-format
Expand Down
3 changes: 2 additions & 1 deletion mmcv/cnn/bricks/drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def drop_path(x: torch.Tensor,
residual blocks).
We follow the implementation
https://github.com/rwightman/pytorch-image-models/blob/a2727c1bf78ba0d7b5727f5f95e37fb7f8866b1f/timm/models/layers/drop.py # noqa: E501
https://github.com/rwightman/pytorch-image-models/blob/a2727c1bf78ba0d7b5727f5f95e37fb7f8866b1f/timm/models/layers/drop.py
# noqa: E501
"""
if drop_prob == 0. or not training:
return x
Expand Down
8 changes: 4 additions & 4 deletions mmcv/cnn/rfsearch/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(self,
self.by_epoch = by_epoch

def init_model(self, model: nn.Module):
"""init model with search ability.
"""Init model with search ability.
Args:
model (nn.Module): pytorch model
Expand Down Expand Up @@ -132,7 +132,7 @@ def step(self, model: nn.Module, work_dir: str) -> None:
)

def estimate_and_expand(self, model: nn.Module) -> None:
"""estimate and search for RFConvOp.
"""Estimate and search for RFConvOp.
Args:
model (nn.Module): pytorch model
Expand All @@ -146,7 +146,7 @@ def wrap_model(self,
model: nn.Module,
search_op: str = 'Conv2d',
prefix: str = '') -> None:
"""wrap model to support searchable conv op.
"""Wrap model to support searchable conv op.
Args:
model (nn.Module): pytorch model
Expand Down Expand Up @@ -187,7 +187,7 @@ def set_model(self,
search_op: str = 'Conv2d',
init_rates: Optional[int] = None,
prefix: str = '') -> None:
"""set model based on config.
"""Set model based on config.
Args:
model (nn.Module): pytorch model
Expand Down
4 changes: 2 additions & 2 deletions mmcv/cnn/rfsearch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def write_to_json(config: dict, filename: str):
"""save config to json file.
"""Save config to json file.
Args:
config (dict): Config to be saved.
Expand All @@ -16,7 +16,7 @@ def write_to_json(config: dict, filename: str):


def expand_rates(dilation: tuple, config: dict) -> list:
"""expand dilation rate according to config.
"""Expand dilation rate according to config.
Args:
dilation (int): _description_
Expand Down
6 changes: 3 additions & 3 deletions mmcv/ops/active_rotated_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class ActiveRotatedFilterFunction(Function):
"""Encoding the orientation information and generating orientation-
sensitive features.
The details are described in the paper `Align Deep Features for Oriented
Object Detection <https://arxiv.org/abs/2008.09397>_`.
"""
The details are described in the paper
`Align Deep Features for Oriented Object Detection <https://arxiv.org/abs/2008.09397>_`.
""" # noqa: E501

@staticmethod
def forward(ctx, input: torch.Tensor,
Expand Down
2 changes: 1 addition & 1 deletion mmcv/ops/cc_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, in_channels: int) -> None:
self.in_channels = in_channels

def forward(self, x: torch.Tensor) -> torch.Tensor:
"""forward function of Criss-Cross Attention.
"""Forward function of Criss-Cross Attention.
Args:
x (torch.Tensor): Input feature with the shape of
Expand Down
3 changes: 2 additions & 1 deletion mmcv/ops/chamfer_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class ChamferDistanceFunction(Function):
"""This is an implementation of the 2D Chamfer Distance.
It has been used in the paper `Oriented RepPoints for Aerial Object
Detection (CVPR 2022) <https://arxiv.org/abs/2105.11111>_`.
Detection (CVPR 2022)
<https://arxiv.org/abs/2105.11111>_`.
"""

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion mmcv/ops/correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _output_size(ctx, input1):


class Correlation(nn.Module):
r"""Correlation operator
r"""Correlation operator.
This correlation operator works for optical flow correlation computation.
Expand Down
6 changes: 3 additions & 3 deletions mmcv/ops/csrc/common/cuda/bezier_align_cuda_kernel.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ __global__ void bezier_align_backward_cuda_kernel(
atomicAdd(offset_bottom_diff + y_high * width + x_high,
static_cast<T>(g4));
} // if
} // ix
} // iy
} // CUDA_1D_KERNEL_LOOP
} // ix
} // iy
} // CUDA_1D_KERNEL_LOOP
} // BezierAlignBackward

#endif // BEZIER_ALIGN_CUDA_KERNEL_CUH
6 changes: 3 additions & 3 deletions mmcv/ops/csrc/common/cuda/riroi_align_rotated_cuda_kernel.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ __global__ void riroi_align_rotated_backward_cuda_kernel(
g4 * l_var);

} // if
} // ix
} // iy
} // CUDA_1D_KERNEL_LOOP
} // ix
} // iy
} // CUDA_1D_KERNEL_LOOP
} // RiRoIAlignBackward

#endif // RIROI_ALIGN_ROTATED_CUDA_KERNEL_CUH
6 changes: 3 additions & 3 deletions mmcv/ops/csrc/common/cuda/roi_align_rotated_cuda_kernel.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ __global__ void roi_align_rotated_backward_cuda_kernel(
atomicAdd(offset_bottom_diff + y_high * width + x_low, g3);
atomicAdd(offset_bottom_diff + y_high * width + x_high, g4);
} // if
} // ix
} // iy
} // CUDA_1D_KERNEL_LOOP
} // ix
} // iy
} // CUDA_1D_KERNEL_LOOP
} // RoIAlignBackward

#endif // ROI_ALIGN_ROTATED_CUDA_KERNEL_CUH
2 changes: 1 addition & 1 deletion mmcv/ops/csrc/common/mlu/common_mlu_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#define PAD_DOWN(x, y) (((x) / (y)) * (y))
#endif

#define CEIL_ALIGN(x, y) (((x) + (y)-1) / (y) * (y))
#define CEIL_ALIGN(x, y) (((x) + (y) - 1) / (y) * (y))

template <typename scalar_t>
__mlu_func__ inline scalar_t min(scalar_t a, scalar_t b) {
Expand Down
4 changes: 2 additions & 2 deletions mmcv/ops/csrc/common/pytorch_mlu_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

#define PAD_DOWN(x, y) (((x) / (y)) * (y))

#define CEIL_DIV(x, y) (((x) + (y)-1) / (y))
#define CEIL_DIV(x, y) (((x) + (y) - 1) / (y))

#define CEIL_ALIGN(x, y) (((x) + (y)-1) / (y) * (y))
#define CEIL_ALIGN(x, y) (((x) + (y) - 1) / (y) * (y))

inline int32_t getJobLimitCapability() {
CNcontext drv_ctx;
Expand Down
4 changes: 2 additions & 2 deletions mmcv/ops/csrc/common/pytorch_npu_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ void ReleaseConvertTypes(Tuple &t) {
}

template <typename... Ts>
constexpr auto ConvertTypes(Ts &... args) {
constexpr auto ConvertTypes(Ts &...args) {
return std::make_tuple(ConvertType(args)...);
}

Expand Down Expand Up @@ -506,7 +506,7 @@ void AddParamToBuf(const string &);
void AddParamToBuf();

template <typename T, typename... Args>
void AddParamToBuf(const T &arg, Args &... args) {
void AddParamToBuf(const T &arg, Args &...args) {
AddParamToBuf(arg);
AddParamToBuf(args...);
}
Expand Down
2 changes: 1 addition & 1 deletion mmcv/ops/csrc/common/utils/spconv/paramsgrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void assigner(TT &src, std::vector<int> counter, std::vector<scalar_t> &arg) {

template <int Idx, class TT, class scalar_t, class... TArgs>
void assigner(TT &src, std::vector<int> counter, std::vector<scalar_t> &arg,
std::vector<TArgs> &... args) {
std::vector<TArgs> &...args) {
std::get<Idx>(src) = arg[counter[Idx]];
assigner<Idx + 1>(src, counter, args...);
}
Expand Down
4 changes: 2 additions & 2 deletions mmcv/ops/csrc/common/utils/spconv/tensorview/tensorview.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ struct CPU {};
template <typename scalar_t, size_t MaxDim = TV_MAX_DIM>
struct SimpleVector {
public:
TV_HOST_DEVICE_INLINE SimpleVector(){};
TV_HOST_DEVICE_INLINE SimpleVector() {};
TV_HOST_DEVICE_INLINE SimpleVector(std::initializer_list<scalar_t> q) {
TV_ASSERT(q.size() <= MaxDim);
mSize = 0;
Expand Down Expand Up @@ -315,7 +315,7 @@ struct Slice {

template <size_t MaxDim = TV_MAX_DIM>
struct ShapeBase : public SimpleVector<int, MaxDim> {
TV_HOST_DEVICE_INLINE ShapeBase() : SimpleVector<int, MaxDim>(){};
TV_HOST_DEVICE_INLINE ShapeBase() : SimpleVector<int, MaxDim>() {};
TV_HOST_DEVICE_INLINE ShapeBase(std::initializer_list<int> shape)
: SimpleVector<int, MaxDim>(shape) {}

Expand Down
12 changes: 6 additions & 6 deletions mmcv/ops/csrc/pytorch/cpu/bezier_align.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ void BezierAlignForward(const int nthreads, const T *input, const T *rois,

output[index] = output_val;
} // for pw
} // for ph
} // for c
} // for n
} // for ph
} // for c
} // for n
}

template <typename T>
Expand Down Expand Up @@ -381,9 +381,9 @@ void BezierAlignBackward(const int nthreads, const T *grad_output,
add(offset_grad_input + y_high * width + x_low, static_cast<T>(g3));
add(offset_grad_input + y_high * width + x_high, static_cast<T>(g4));
} // if
} // ix
} // iy
} // for
} // ix
} // iy
} // for
} // BezierAlignBackward

void BezierAlignForwardCPULauncher(Tensor input, Tensor rois, Tensor output,
Expand Down
Loading

0 comments on commit 1393257

Please sign in to comment.