From f56a30025a19c1ac5ef31552a04c53e8697b0c85 Mon Sep 17 00:00:00 2001 From: "q.yao" Date: Sat, 9 Oct 2021 11:34:14 +0800 Subject: [PATCH] [Enhance] Add spell hook (#116) * add spell hook * fix code spell --- .pre-commit-config.yaml | 5 ++++- .../onnxruntime/grid_sample/grid_sample.cpp | 4 ++-- .../tensorrt/batched_nms/allClassNMS.cu | 2 +- .../tensorrt/batched_nms/trt_batched_nms.cpp | 10 ++++----- .../tensorrt/batched_nms/trt_batched_nms.hpp | 2 +- .../grid_sampler/trt_grid_sampler.cpp | 10 ++++----- .../grid_sampler/trt_grid_sampler.hpp | 2 +- .../grid_sampler/trt_grid_sampler_kernel.cu | 8 +++---- .../instance_norm/trt_instance_norm.cpp | 10 ++++----- .../instance_norm/trt_instance_norm.hpp | 2 +- .../trt_modulated_deform_conv.cpp | 10 ++++----- .../trt_modulated_deform_conv.hpp | 2 +- .../trt_multi_level_roi_align.cpp | 6 ++--- .../trt_multi_level_roi_align.hpp | 2 +- .../tensorrt/roi_align/trt_roi_align.cpp | 6 ++--- .../tensorrt/roi_align/trt_roi_align.hpp | 2 +- .../tensorrt/scatternd/trt_scatternd.cpp | 22 +++++++++---------- .../tensorrt/scatternd/trt_scatternd.hpp | 2 +- mmdeploy/apis/pytorch2onnx.py | 2 +- mmdeploy/core/rewriters/function_rewriter.py | 2 +- mmdeploy/core/rewriters/module_rewriter.py | 2 +- mmdeploy/core/rewriters/symbolic_register.py | 4 ++-- mmdeploy/mmcv/ops/roi_align.py | 2 +- mmdeploy/mmdet/export/prepare_input.py | 6 ++--- mmdeploy/mmedit/apis/inference.py | 6 ++--- mmdeploy/mmedit/export/prepare_input.py | 2 +- mmdeploy/mmocr/export/prepare_input.py | 10 ++++----- mmdeploy/mmseg/export/prepare_input.py | 6 ++--- mmdeploy/utils/config_utils.py | 6 ++--- mmdeploy/utils/timer.py | 2 +- tests/test_core/test_register.py | 2 +- 31 files changed, 81 insertions(+), 78 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 695ed1922..557543a8d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,3 @@ -exclude: ^tests/data/ repos: - repo: https://gitlab.com/pycqa/flake8.git rev: 3.8.3 @@ -40,6 +39,10 @@ repos: "-t", "allow_different_nesting", ] + - repo: https://github.com/codespell-project/codespell + rev: v2.1.0 + hooks: + - id: codespell - repo: https://github.com/myint/docformatter rev: v1.3.1 hooks: diff --git a/backend_ops/onnxruntime/grid_sample/grid_sample.cpp b/backend_ops/onnxruntime/grid_sample/grid_sample.cpp index ac538e403..df03cbea1 100644 --- a/backend_ops/onnxruntime/grid_sample/grid_sample.cpp +++ b/backend_ops/onnxruntime/grid_sample/grid_sample.cpp @@ -250,7 +250,7 @@ void GridSampleKernel::Compute(OrtKernelContext *context) { int64_t ix_nearest = static_cast(std::nearbyint(ix)); int64_t iy_nearest = static_cast(std::nearbyint(iy)); - // assign nearest neighor pixel value to output pixel + // assign nearest neighbor pixel value to output pixel float *out_ptr_NCHW = out_ptr + n * out_sN + h * out_sH + w * out_sW; const float *inp_ptr_NC = inp_ptr_N; for (int64_t c = 0; c < C; @@ -285,7 +285,7 @@ void GridSampleKernel::Compute(OrtKernelContext *context) { ++c, out_ptr_NCHW += out_sC, inp_ptr_NC += inp_sC) { float coefficients[4]; - // Interpolate 4 values in the x directon + // Interpolate 4 values in the x direction for (int64_t i = 0; i < 4; ++i) { coefficients[i] = cubic_interp1d( get_value_bounded(inp_ptr_NC, ix_nw - 1, iy_nw - 1 + i, diff --git a/backend_ops/tensorrt/batched_nms/allClassNMS.cu b/backend_ops/tensorrt/batched_nms/allClassNMS.cu index a05d14659..895192399 100644 --- a/backend_ops/tensorrt/batched_nms/allClassNMS.cu +++ b/backend_ops/tensorrt/batched_nms/allClassNMS.cu @@ -69,7 +69,7 @@ template __device__ void emptyBboxInfo(BboxInfo *bbox_info) { bbox_info->conf_score = T_BBOX(0); bbox_info->label = - -2; // -1 is used for all labels when shared_location is ture + -2; // -1 is used for all labels when shared_location is true bbox_info->bbox_idx = -1; bbox_info->kept = false; } diff --git a/backend_ops/tensorrt/batched_nms/trt_batched_nms.cpp b/backend_ops/tensorrt/batched_nms/trt_batched_nms.cpp index d00d23797..7de320b62 100644 --- a/backend_ops/tensorrt/batched_nms/trt_batched_nms.cpp +++ b/backend_ops/tensorrt/batched_nms/trt_batched_nms.cpp @@ -124,14 +124,14 @@ void TRTBatchedNMS::configurePlugin( } bool TRTBatchedNMS::supportsFormatCombination( - int pos, const nvinfer1::PluginTensorDesc* inOut, int nbInputs, + int pos, const nvinfer1::PluginTensorDesc* ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT { if (pos == 3) { - return inOut[pos].type == nvinfer1::DataType::kINT32 && - inOut[pos].format == nvinfer1::TensorFormat::kLINEAR; + return ioDesc[pos].type == nvinfer1::DataType::kINT32 && + ioDesc[pos].format == nvinfer1::TensorFormat::kLINEAR; } - return inOut[pos].type == nvinfer1::DataType::kFLOAT && - inOut[pos].format == nvinfer1::TensorFormat::kLINEAR; + return ioDesc[pos].type == nvinfer1::DataType::kFLOAT && + ioDesc[pos].format == nvinfer1::TensorFormat::kLINEAR; } const char* TRTBatchedNMS::getPluginType() const TRT_NOEXCEPT { diff --git a/backend_ops/tensorrt/batched_nms/trt_batched_nms.hpp b/backend_ops/tensorrt/batched_nms/trt_batched_nms.hpp index b8eb5ff07..25298ebff 100644 --- a/backend_ops/tensorrt/batched_nms/trt_batched_nms.hpp +++ b/backend_ops/tensorrt/batched_nms/trt_batched_nms.hpp @@ -42,7 +42,7 @@ class TRTBatchedNMS : public TRTPluginBase { int nbOutputs) TRT_NOEXCEPT override; bool supportsFormatCombination(int pos, - const nvinfer1::PluginTensorDesc* inOut, + const nvinfer1::PluginTensorDesc* ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT override; diff --git a/backend_ops/tensorrt/grid_sampler/trt_grid_sampler.cpp b/backend_ops/tensorrt/grid_sampler/trt_grid_sampler.cpp index a97ef8031..95f3bc67d 100644 --- a/backend_ops/tensorrt/grid_sampler/trt_grid_sampler.cpp +++ b/backend_ops/tensorrt/grid_sampler/trt_grid_sampler.cpp @@ -51,14 +51,14 @@ nvinfer1::DimsExprs TRTGridSampler::getOutputDimensions( } bool TRTGridSampler::supportsFormatCombination( - int pos, const nvinfer1::PluginTensorDesc *inOut, int nbInputs, + int pos, const nvinfer1::PluginTensorDesc *ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT { if (pos == 0) { - return (inOut[pos].type == nvinfer1::DataType::kFLOAT && - inOut[pos].format == nvinfer1::TensorFormat::kLINEAR); + return (ioDesc[pos].type == nvinfer1::DataType::kFLOAT && + ioDesc[pos].format == nvinfer1::TensorFormat::kLINEAR); } else { - return inOut[pos].type == inOut[0].type && - inOut[pos].format == inOut[0].format; + return ioDesc[pos].type == ioDesc[0].type && + ioDesc[pos].format == ioDesc[0].format; } } diff --git a/backend_ops/tensorrt/grid_sampler/trt_grid_sampler.hpp b/backend_ops/tensorrt/grid_sampler/trt_grid_sampler.hpp index 7f8af3d81..5de36509c 100644 --- a/backend_ops/tensorrt/grid_sampler/trt_grid_sampler.hpp +++ b/backend_ops/tensorrt/grid_sampler/trt_grid_sampler.hpp @@ -29,7 +29,7 @@ class TRTGridSampler : public TRTPluginBase { nvinfer1::IExprBuilder &exprBuilder) TRT_NOEXCEPT override; bool supportsFormatCombination(int pos, - const nvinfer1::PluginTensorDesc *inOut, + const nvinfer1::PluginTensorDesc *ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT override; diff --git a/backend_ops/tensorrt/grid_sampler/trt_grid_sampler_kernel.cu b/backend_ops/tensorrt/grid_sampler/trt_grid_sampler_kernel.cu index 09a6b5494..b3ae8a0fe 100644 --- a/backend_ops/tensorrt/grid_sampler/trt_grid_sampler_kernel.cu +++ b/backend_ops/tensorrt/grid_sampler/trt_grid_sampler_kernel.cu @@ -144,7 +144,7 @@ __global__ void grid_sampler_2d_kernel( const int n = index / (out_H * out_W); const int grid_offset = n * grid_sN + h * grid_sH + w * grid_sW; - // get the corresponding input x, y co-ordinates from grid + // get the corresponding input x, y coordinates from grid scalar_t ix = grid[grid_offset]; scalar_t iy = grid[grid_offset + grid_sCoor]; @@ -193,7 +193,7 @@ __global__ void grid_sampler_2d_kernel( int ix_nearest = static_cast(::round(ix)); int iy_nearest = static_cast(::round(iy)); - // assign nearest neighor pixel value to output pixel + // assign nearest neighbor pixel value to output pixel auto inp_ptr_NC = input + n * inp_sN; auto out_ptr_NCHW = output + n * out_sN + h * out_sH + w * out_sW; for (int c = 0; c < C; @@ -245,7 +245,7 @@ __global__ void grid_sampler_3d_kernel( const int grid_offset = n * grid_sN + d * grid_sD + h * grid_sH + w * grid_sW; - // get the corresponding input x, y, z co-ordinates from grid + // get the corresponding input x, y, z coordinates from grid scalar_t ix = grid[grid_offset]; scalar_t iy = grid[grid_offset + grid_sCoor]; scalar_t iz = grid[grid_offset + 2 * grid_sCoor]; @@ -363,7 +363,7 @@ __global__ void grid_sampler_3d_kernel( int iy_nearest = static_cast(::round(iy)); int iz_nearest = static_cast(::round(iz)); - // assign nearest neighor pixel value to output pixel + // assign nearest neighbor pixel value to output pixel auto inp_ptr_NC = input + n * inp_sN; auto out_ptr_NCDHW = output + n * out_sN + d * out_sD + h * out_sH + w * out_sW; diff --git a/backend_ops/tensorrt/instance_norm/trt_instance_norm.cpp b/backend_ops/tensorrt/instance_norm/trt_instance_norm.cpp index 226967f2b..fdb0c40d1 100644 --- a/backend_ops/tensorrt/instance_norm/trt_instance_norm.cpp +++ b/backend_ops/tensorrt/instance_norm/trt_instance_norm.cpp @@ -107,12 +107,12 @@ void TRTInstanceNormalization::serialize(void* buffer) const TRT_NOEXCEPT { } bool TRTInstanceNormalization::supportsFormatCombination( - int pos, const nvinfer1::PluginTensorDesc* inOut, int nbInputs, + int pos, const nvinfer1::PluginTensorDesc* ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT { - return ((inOut[pos].type == nvinfer1::DataType::kFLOAT || - inOut[pos].type == nvinfer1::DataType::kHALF) && - inOut[pos].format == nvinfer1::PluginFormat::kLINEAR && - inOut[pos].type == inOut[0].type); + return ((ioDesc[pos].type == nvinfer1::DataType::kFLOAT || + ioDesc[pos].type == nvinfer1::DataType::kHALF) && + ioDesc[pos].format == nvinfer1::PluginFormat::kLINEAR && + ioDesc[pos].type == ioDesc[0].type); } const char* TRTInstanceNormalization::getPluginType() const TRT_NOEXCEPT { diff --git a/backend_ops/tensorrt/instance_norm/trt_instance_norm.hpp b/backend_ops/tensorrt/instance_norm/trt_instance_norm.hpp index 2689c47dd..62d149222 100644 --- a/backend_ops/tensorrt/instance_norm/trt_instance_norm.hpp +++ b/backend_ops/tensorrt/instance_norm/trt_instance_norm.hpp @@ -48,7 +48,7 @@ class TRTInstanceNormalization final : public TRTPluginBase { // DynamicExt plugin supportsFormat update. bool supportsFormatCombination(int pos, - const nvinfer1::PluginTensorDesc* inOut, + const nvinfer1::PluginTensorDesc* ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT override; diff --git a/backend_ops/tensorrt/modulated_deform_conv/trt_modulated_deform_conv.cpp b/backend_ops/tensorrt/modulated_deform_conv/trt_modulated_deform_conv.cpp index 4d13e5f06..8a955c469 100644 --- a/backend_ops/tensorrt/modulated_deform_conv/trt_modulated_deform_conv.cpp +++ b/backend_ops/tensorrt/modulated_deform_conv/trt_modulated_deform_conv.cpp @@ -73,15 +73,15 @@ nvinfer1::DimsExprs ModulatedDeformableConvPluginDynamic::getOutputDimensions( } bool ModulatedDeformableConvPluginDynamic::supportsFormatCombination( - int pos, const nvinfer1::PluginTensorDesc *inOut, int nbInputs, + int pos, const nvinfer1::PluginTensorDesc *ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT { if (pos == 0) { - return (inOut[pos].type == nvinfer1::DataType::kFLOAT && - inOut[pos].format == nvinfer1::TensorFormat::kLINEAR); + return (ioDesc[pos].type == nvinfer1::DataType::kFLOAT && + ioDesc[pos].format == nvinfer1::TensorFormat::kLINEAR); } else { - return inOut[pos].type == inOut[0].type && - inOut[pos].format == inOut[0].format; + return ioDesc[pos].type == ioDesc[0].type && + ioDesc[pos].format == ioDesc[0].format; } } diff --git a/backend_ops/tensorrt/modulated_deform_conv/trt_modulated_deform_conv.hpp b/backend_ops/tensorrt/modulated_deform_conv/trt_modulated_deform_conv.hpp index 3b17a0208..af00b0dfb 100644 --- a/backend_ops/tensorrt/modulated_deform_conv/trt_modulated_deform_conv.hpp +++ b/backend_ops/tensorrt/modulated_deform_conv/trt_modulated_deform_conv.hpp @@ -31,7 +31,7 @@ class ModulatedDeformableConvPluginDynamic : public TRTPluginBase { int outputIndex, const nvinfer1::DimsExprs *inputs, int nbInputs, nvinfer1::IExprBuilder &exprBuilder) TRT_NOEXCEPT override; bool supportsFormatCombination(int pos, - const nvinfer1::PluginTensorDesc *inOut, + const nvinfer1::PluginTensorDesc *ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT override; void configurePlugin(const nvinfer1::DynamicPluginTensorDesc *in, diff --git a/backend_ops/tensorrt/multi_level_roi_align/trt_multi_level_roi_align.cpp b/backend_ops/tensorrt/multi_level_roi_align/trt_multi_level_roi_align.cpp index bbaa989c0..f9b1b5a09 100644 --- a/backend_ops/tensorrt/multi_level_roi_align/trt_multi_level_roi_align.cpp +++ b/backend_ops/tensorrt/multi_level_roi_align/trt_multi_level_roi_align.cpp @@ -65,10 +65,10 @@ nvinfer1::DimsExprs TRTMultiLevelRoiAlign::getOutputDimensions( } bool TRTMultiLevelRoiAlign::supportsFormatCombination( - int pos, const nvinfer1::PluginTensorDesc *inOut, int nbInputs, + int pos, const nvinfer1::PluginTensorDesc *ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT { - return inOut[pos].type == nvinfer1::DataType::kFLOAT && - inOut[pos].format == nvinfer1::TensorFormat::kLINEAR; + return ioDesc[pos].type == nvinfer1::DataType::kFLOAT && + ioDesc[pos].format == nvinfer1::TensorFormat::kLINEAR; } void TRTMultiLevelRoiAlign::configurePlugin( diff --git a/backend_ops/tensorrt/multi_level_roi_align/trt_multi_level_roi_align.hpp b/backend_ops/tensorrt/multi_level_roi_align/trt_multi_level_roi_align.hpp index 23a60da77..c4763dfde 100644 --- a/backend_ops/tensorrt/multi_level_roi_align/trt_multi_level_roi_align.hpp +++ b/backend_ops/tensorrt/multi_level_roi_align/trt_multi_level_roi_align.hpp @@ -29,7 +29,7 @@ class TRTMultiLevelRoiAlign : public TRTPluginBase { int outputIndex, const nvinfer1::DimsExprs *inputs, int nbInputs, nvinfer1::IExprBuilder &exprBuilder) TRT_NOEXCEPT override; bool supportsFormatCombination(int pos, - const nvinfer1::PluginTensorDesc *inOut, + const nvinfer1::PluginTensorDesc *ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT override; void configurePlugin(const nvinfer1::DynamicPluginTensorDesc *in, diff --git a/backend_ops/tensorrt/roi_align/trt_roi_align.cpp b/backend_ops/tensorrt/roi_align/trt_roi_align.cpp index 4bec0ce86..286f770fb 100644 --- a/backend_ops/tensorrt/roi_align/trt_roi_align.cpp +++ b/backend_ops/tensorrt/roi_align/trt_roi_align.cpp @@ -59,10 +59,10 @@ nvinfer1::DimsExprs TRTRoIAlign::getOutputDimensions( } bool TRTRoIAlign::supportsFormatCombination( - int pos, const nvinfer1::PluginTensorDesc *inOut, int nbInputs, + int pos, const nvinfer1::PluginTensorDesc *ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT { - return inOut[pos].type == nvinfer1::DataType::kFLOAT && - inOut[pos].format == nvinfer1::TensorFormat::kLINEAR; + return ioDesc[pos].type == nvinfer1::DataType::kFLOAT && + ioDesc[pos].format == nvinfer1::TensorFormat::kLINEAR; } void TRTRoIAlign::configurePlugin( diff --git a/backend_ops/tensorrt/roi_align/trt_roi_align.hpp b/backend_ops/tensorrt/roi_align/trt_roi_align.hpp index d11b88bea..2ef526015 100644 --- a/backend_ops/tensorrt/roi_align/trt_roi_align.hpp +++ b/backend_ops/tensorrt/roi_align/trt_roi_align.hpp @@ -23,7 +23,7 @@ class TRTRoIAlign : public TRTPluginBase { int outputIndex, const nvinfer1::DimsExprs *inputs, int nbInputs, nvinfer1::IExprBuilder &exprBuilder) TRT_NOEXCEPT override; bool supportsFormatCombination(int pos, - const nvinfer1::PluginTensorDesc *inOut, + const nvinfer1::PluginTensorDesc *ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT override; void configurePlugin(const nvinfer1::DynamicPluginTensorDesc *in, diff --git a/backend_ops/tensorrt/scatternd/trt_scatternd.cpp b/backend_ops/tensorrt/scatternd/trt_scatternd.cpp index 1d2599c90..ca8eac51c 100644 --- a/backend_ops/tensorrt/scatternd/trt_scatternd.cpp +++ b/backend_ops/tensorrt/scatternd/trt_scatternd.cpp @@ -34,24 +34,24 @@ nvinfer1::DimsExprs TRTScatterND::getOutputDimensions( } bool TRTScatterND::supportsFormatCombination( - int pos, const nvinfer1::PluginTensorDesc *inOut, int nbInputs, + int pos, const nvinfer1::PluginTensorDesc *ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT { if (pos < nbInputs) { switch (pos) { case 0: // data - return (inOut[pos].type == nvinfer1::DataType::kFLOAT && - inOut[pos].format == nvinfer1::TensorFormat::kLINEAR) || - (inOut[pos].type == nvinfer1::DataType::kINT32 && - inOut[pos].format == nvinfer1::TensorFormat::kLINEAR); + return (ioDesc[pos].type == nvinfer1::DataType::kFLOAT && + ioDesc[pos].format == nvinfer1::TensorFormat::kLINEAR) || + (ioDesc[pos].type == nvinfer1::DataType::kINT32 && + ioDesc[pos].format == nvinfer1::TensorFormat::kLINEAR); case 1: // indices - return inOut[pos].type == nvinfer1::DataType::kINT32 && - inOut[pos].format == nvinfer1::TensorFormat::kLINEAR; + return ioDesc[pos].type == nvinfer1::DataType::kINT32 && + ioDesc[pos].format == nvinfer1::TensorFormat::kLINEAR; case 2: // updates - return inOut[pos].type == inOut[0].type && - inOut[pos].format == inOut[0].format; + return ioDesc[pos].type == ioDesc[0].type && + ioDesc[pos].format == ioDesc[0].format; default: return true; } @@ -59,8 +59,8 @@ bool TRTScatterND::supportsFormatCombination( switch (pos - nbInputs) { case 0: // output - return inOut[pos].type == inOut[0].type && - inOut[pos].format == inOut[0].format; + return ioDesc[pos].type == ioDesc[0].type && + ioDesc[pos].format == ioDesc[0].format; default: return true; } diff --git a/backend_ops/tensorrt/scatternd/trt_scatternd.hpp b/backend_ops/tensorrt/scatternd/trt_scatternd.hpp index 0f451547e..c922d0421 100644 --- a/backend_ops/tensorrt/scatternd/trt_scatternd.hpp +++ b/backend_ops/tensorrt/scatternd/trt_scatternd.hpp @@ -23,7 +23,7 @@ class TRTScatterND : public TRTPluginBase { int outputIndex, const nvinfer1::DimsExprs *inputs, int nbInputs, nvinfer1::IExprBuilder &exprBuilder) TRT_NOEXCEPT override; bool supportsFormatCombination(int pos, - const nvinfer1::PluginTensorDesc *inOut, + const nvinfer1::PluginTensorDesc *ioDesc, int nbInputs, int nbOutputs) TRT_NOEXCEPT override; void configurePlugin(const nvinfer1::DynamicPluginTensorDesc *in, diff --git a/mmdeploy/apis/pytorch2onnx.py b/mmdeploy/apis/pytorch2onnx.py index 350e018a3..c3fb98a2e 100644 --- a/mmdeploy/apis/pytorch2onnx.py +++ b/mmdeploy/apis/pytorch2onnx.py @@ -29,7 +29,7 @@ def torch2onnx_impl(model: torch.nn.Module, input: torch.Tensor, backend = get_backend(deploy_cfg).value opset_version = pytorch2onnx_cfg.get('opset_version', 11) - # load registed symbolic + # load registered symbolic register_extra_symbolics(deploy_cfg, backend=backend, opset=opset_version) # patch model diff --git a/mmdeploy/core/rewriters/function_rewriter.py b/mmdeploy/core/rewriters/function_rewriter.py index 6b34b86b2..e139011b4 100644 --- a/mmdeploy/core/rewriters/function_rewriter.py +++ b/mmdeploy/core/rewriters/function_rewriter.py @@ -163,7 +163,7 @@ class RewriterContext(object): Examples: >>> from mmdeploy.core import RewriterContext >>> with RewriterContext(cfg, backend='onnxruntime'): - >>> # the rewrite has been actived inside the context + >>> # the rewrite has been activated inside the context >>> torch.onnx.export(model, inputs, onnx_file) """ diff --git a/mmdeploy/core/rewriters/module_rewriter.py b/mmdeploy/core/rewriters/module_rewriter.py index a830c2fc9..3870d4bae 100644 --- a/mmdeploy/core/rewriters/module_rewriter.py +++ b/mmdeploy/core/rewriters/module_rewriter.py @@ -97,7 +97,7 @@ def patch_model(model: nn.Module, backend: str = 'default', recursive: bool = True, **kwargs) -> nn.Module: - """Patch the model, replace the modules that can be rewrited. + """Patch the model, replace the modules that can be rewritten. Args: model (torch.nn.Module): The model to patch. diff --git a/mmdeploy/core/rewriters/symbolic_register.py b/mmdeploy/core/rewriters/symbolic_register.py index 382e933e5..2328e4926 100644 --- a/mmdeploy/core/rewriters/symbolic_register.py +++ b/mmdeploy/core/rewriters/symbolic_register.py @@ -60,7 +60,7 @@ SYMBOLIC_REGISTER = Registry('symbolics', build_func=set_symbolic, scope=None) class SymbolicWrapper: """The wrapper of the symbolic function. - The wrapper is used to pass context and enviroment to the symbolic. + The wrapper is used to pass context and environment to the symbolic. Args: cfg (Dict): Config dictionary of deployment. @@ -86,7 +86,7 @@ def register_symbolic(func_name: str, """The decorator of the custom symbolic. Args: - func_name (str): The function name/path to overide the symbolic. + func_name (str): The function name/path to override the symbolic. backend (str): The inference engine name. is_pytorch (bool): Enable this flag if func_name is the name of \ a pytorch builtin function. diff --git a/mmdeploy/mmcv/ops/roi_align.py b/mmdeploy/mmcv/ops/roi_align.py index d6a4a5bc2..b12221261 100644 --- a/mmdeploy/mmcv/ops/roi_align.py +++ b/mmdeploy/mmcv/ops/roi_align.py @@ -3,7 +3,7 @@ from mmdeploy.core import SYMBOLIC_REGISTER # Here using mmcv.ops.roi_align.__self__ to find # mmcv.ops.roi_align.RoIAlignFunction, because RoIAlignFunction is not -# visiable in mmcv. +# visible in mmcv. @SYMBOLIC_REGISTER.register_symbolic( 'mmcv.ops.roi_align.__self__', backend='default') def roi_align_default(ctx, g, input, rois, output_size, spatial_scale, diff --git a/mmdeploy/mmdet/export/prepare_input.py b/mmdeploy/mmdet/export/prepare_input.py index 5091de6a9..3bd8a276b 100644 --- a/mmdeploy/mmdet/export/prepare_input.py +++ b/mmdeploy/mmdet/export/prepare_input.py @@ -54,7 +54,7 @@ def create_input(task: Task, cfg.data.test.pipeline = replace_ImageToTensor(cfg.data.test.pipeline) test_pipeline = Compose(cfg.data.test.pipeline) - datas = [] + data_list = [] for img in imgs: # prepare data if isinstance(img, np.ndarray): @@ -65,9 +65,9 @@ def create_input(task: Task, data = dict(img_info=dict(filename=img), img_prefix=None) # build the data pipeline data = test_pipeline(data) - datas.append(data) + data_list.append(data) - data = collate(datas, samples_per_gpu=len(imgs)) + data = collate(data_list, samples_per_gpu=len(imgs)) data['img_metas'] = [img_metas.data[0] for img_metas in data['img_metas']] data['img'] = [img.data[0] for img in data['img']] diff --git a/mmdeploy/mmedit/apis/inference.py b/mmdeploy/mmedit/apis/inference.py index f92631d6a..77e26e469 100644 --- a/mmdeploy/mmedit/apis/inference.py +++ b/mmdeploy/mmedit/apis/inference.py @@ -35,8 +35,8 @@ class DeployBaseRestorer(BaseModel): def forward(self, lq: torch.Tensor, test_mode: bool = False, **kwargs): """Run test inference for restorer. - We want forward() to output an image or a evalution result. - When test_mode is set, the output is evalution result. Otherwise + We want forward() to output an image or a evaluation result. + When test_mode is set, the output is evaluation result. Otherwise it is an image. Args: @@ -104,7 +104,7 @@ class DeployBaseRestorer(BaseModel): outputs: torch.Tensor, lq: torch.Tensor, gt: Optional[torch.Tensor] = None): - """Get evalution results by post-processing model outputs. + """Get evaluation results by post-processing model outputs. Args: output (torch.Tensor) : The output high resolution image. diff --git a/mmdeploy/mmedit/export/prepare_input.py b/mmdeploy/mmedit/export/prepare_input.py index fbc38b760..99dfff9dc 100644 --- a/mmdeploy/mmedit/export/prepare_input.py +++ b/mmdeploy/mmedit/export/prepare_input.py @@ -18,7 +18,7 @@ def _preprocess_cfg(config: Union[str, mmcv.Config]): model_cfg (str | mmcv.Config): The input model config. """ - # TODO: Differentiate the editting tasks (e.g. restorers and mattors + # TODO: Differentiate the editing tasks (e.g. restorers and mattors # preprocess the data in differenet ways) keys_to_remove = ['gt', 'gt_path'] diff --git a/mmdeploy/mmocr/export/prepare_input.py b/mmdeploy/mmocr/export/prepare_input.py index 80529802c..eaac13163 100644 --- a/mmdeploy/mmocr/export/prepare_input.py +++ b/mmdeploy/mmocr/export/prepare_input.py @@ -71,7 +71,7 @@ def create_input(task: Task, from mmocr.datasets import build_dataset # noqa: F401 test_pipeline = Compose(model_cfg.data.test.pipeline) - datas = [] + data_list = [] for img in imgs: # prepare data if is_ndarray: @@ -84,14 +84,14 @@ def create_input(task: Task, # build the data pipeline data = test_pipeline(data) # get tensor from list to stack for batch mode (text detection) - datas.append(data) + data_list.append(data) - if isinstance(datas[0]['img'], list) and len(datas) > 1: + if isinstance(data_list[0]['img'], list) and len(data_list) > 1: raise Exception('aug test does not support ' f'inference with batch size ' - f'{len(datas)}') + f'{len(data_list)}') - data = collate(datas, samples_per_gpu=len(imgs)) + data = collate(data_list, samples_per_gpu=len(imgs)) # process img_metas if isinstance(data['img_metas'], list): diff --git a/mmdeploy/mmseg/export/prepare_input.py b/mmdeploy/mmseg/export/prepare_input.py index a14e4c160..8f9426721 100644 --- a/mmdeploy/mmseg/export/prepare_input.py +++ b/mmdeploy/mmseg/export/prepare_input.py @@ -47,15 +47,15 @@ def create_input(task: Task, cfg.data.test.pipeline = [LoadImage()] + cfg.data.test.pipeline[1:] test_pipeline = Compose(cfg.data.test.pipeline) - datas = [] + data_list = [] for img in imgs: # prepare data data = dict(img=img) # build the data pipeline data = test_pipeline(data) - datas.append(data) + data_list.append(data) - data = collate(datas, samples_per_gpu=len(imgs)) + data = collate(data_list, samples_per_gpu=len(imgs)) data['img_metas'] = [img_metas.data[0] for img_metas in data['img_metas']] data['img'] = [img.data[0][None, :] for img in data['img']] diff --git a/mmdeploy/utils/config_utils.py b/mmdeploy/utils/config_utils.py index cc3f436c4..82cc8ce39 100644 --- a/mmdeploy/utils/config_utils.py +++ b/mmdeploy/utils/config_utils.py @@ -34,7 +34,7 @@ def get_task_type(deploy_cfg: Union[str, mmcv.Config], default=None) -> Task: Args: deploy_cfg (str | mmcv.Config): The path or content of config. - default (str): If the "task" field of config is emtpy, then return + default (str): If the "task" field of config is empty, then return default task type. Returns: @@ -56,7 +56,7 @@ def get_codebase(deploy_cfg: Union[str, mmcv.Config], Args: deploy_cfg (str | mmcv.Config): The path or content of config. - default (str): If the "codebase" field of config is emtpy, then return + default (str): If the "codebase" field of config is empty, then return default codebase type. Returns: @@ -77,7 +77,7 @@ def get_backend(deploy_cfg: Union[str, mmcv.Config], default=None) -> Backend: Args: deploy_cfg (str | mmcv.Config): The path or content of config. - default (str): If the "backend" field of config is emtpy, then return + default (str): If the "backend" field of config is empty, then return default backend type. Returns: diff --git a/mmdeploy/utils/timer.py b/mmdeploy/utils/timer.py index 602992a5f..1d198448f 100644 --- a/mmdeploy/utils/timer.py +++ b/mmdeploy/utils/timer.py @@ -88,7 +88,7 @@ class TimeCounter: registried function will be activated. warmup (int): the warm up steps, default 1. log_interval (int): interval between each log, default 1. - with_sync (bool): wheather use cuda synchronize for time counting, + with_sync (bool): whether use cuda synchronize for time counting, default False. """ assert warmup >= 1 diff --git a/tests/test_core/test_register.py b/tests/test_core/test_register.py index 271d31da4..e460774d7 100644 --- a/tests/test_core/test_register.py +++ b/tests/test_core/test_register.py @@ -97,7 +97,7 @@ def test_module_rewriter(): rewrited_result = rewrited_bottle_nect(x) torch.testing.assert_allclose(rewrited_result, result * 2) - # wrong backend should not be rewrited + # wrong backend should not be rewritten rewrited_model = patch_model(model, cfg=cfg) rewrited_bottle_nect = rewrited_model.layer1[0]