Skip to content

Commit a25f360

Browse files
q.yaohanrui1sensetimetehkillerbeeRunningLeonVVsssssk
authored
Merge Master, update optimizer (#151)
* [Feature] add yolox ncnn (#29) * add yolox ncnn * add ncnn android performance of yolox * add ut * fix lint * fix None bugs for ncnn * test codecov * test codecov * add device * fix yapf * remove if-else for img shape * use channelshuffle optimize * change benchmark after channelshuffle * fix yapf * fix yapf * fuse continuous reshape * fix static shape deploy * fix code * drop pad * only static shape * fix static * fix docstring * Added mask overlay to output image, changed fprintf info messages to … (#55) * Added mask overlay to output image, changed fprintf info messages to stdout * Improved box filtering (filter area/score), make sure roi coordinates stay within bounds * clang-format * Support UNet in mmseg (#77) * Repeatdataset in train has no CLASSES & PALETTE * update result for unet * update docstring for mmdet * remove ppl for unet in docs * fix ort wrap about input type (#81) * Fix memleak (#86) * delete [] * fix build error when enble MMDEPLOY_ACTIVE_LEVEL * fix lint * [Doc] Nano benchmark and tutorial (#71) * add cls benchmark * add nano zh-cn benchmark and en tutorial * add device row * add doc path to index.rst * fix typo * [Fix] fix missing deploy_core (#80) * fix missing deploy_core * mv flag to demo * target link * [Docs] Fix links in Chinese doc (#84) * Fix docs in Chinese link * Fix links * Delete symbolic link and add links to html * delete files * Fix link * [Feature] Add docker files (#67) * add gpu and cpu dockerfile * fix lint * fix cpu docker and remove redundant * use pip instead * add build arg and readme * fix grammar * update readme * add chinese doc for dockerfile and add docker build to build.md * grammar * refine dockerfiles * add FAQs * update Dpplcv_DIR for SDK building * remove mmcls * add sdk demos * fix typo and lint * update FAQs * [Fix]fix check_env (#101) * fix check_env * update * Replace convert_syncbatchnorm in mmseg (#93) * replace convert_syncbatchnorm with revert_sync_batchnorm from mmcv * change logger * [Doc] Update FAQ for TensorRT (#96) * update FAQ * comment * [Docs]: Update doc for openvino installation (#102) * fix docs * fix docs * fix docs * fix mmcv version * fix docs * rm blank line * simplify non batch nms (#99) * [Enhacement] Allow test.py to save evaluation results (#108) * Add log file * Delete debug code * Rename logger * resolve comments * [Enhancement] Support mmocr v0.4+ (#115) * support mmocr v0.4+ * 0.4.0 -> 0.4.1 * fix onnxruntime wrapper for gpu inference (#123) * fix ncnn wrapper for ort-gpu * resolve comment * fix lint * Fix typo (#132) * lock mmcls version (#131) * [Enhancement] upgrade isort in pre-commit config (#141) * [Enhancement] upgrade isort in pre-commit config by refering to mmflow pr #87 * fix lint * remove .isort.cfg and put its known_third_party to setup.cfg * Fix ci for mmocr (#144) * fix mmocr unittests * remove useless * lock mmdet maximum version to 2.20 * pip install -U numpy * Fix capture_output (#125) Co-authored-by: hanrui1sensetime <[email protected]> Co-authored-by: Johannes L <[email protected]> Co-authored-by: RunningLeon <[email protected]> Co-authored-by: VVsssssk <[email protected]> Co-authored-by: lvhan028 <[email protected]> Co-authored-by: AllentDan <[email protected]> Co-authored-by: Yifan Zhou <[email protected]> Co-authored-by: 杨培文 (Yang Peiwen) <[email protected]> Co-authored-by: Semyon Bevzyuk <[email protected]>
1 parent 5ae4609 commit a25f360

File tree

88 files changed

+1490
-394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1490
-394
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
- name: Install unittest dependencies
4545
run: |
4646
pip install -r requirements.txt
47+
pip install -U numpy
4748
- name: Build and install
4849
run: rm -rf .eggs && pip install -e .
4950
- name: Run unittests and generate coverage report
@@ -85,6 +86,7 @@ jobs:
8586
python -V
8687
python -m pip install mmcv-full==${{matrix.mmcv}} -f https://download.openmmlab.com/mmcv/dist/cu102/${{matrix.torch_version}}/index.html
8788
python -m pip install -r requirements.txt
89+
python -m pip install -U numpy
8890
- name: Build and install
8991
run: |
9092
rm -rf .eggs && python -m pip install -e .
@@ -128,6 +130,7 @@ jobs:
128130
python -V
129131
python -m pip install mmcv-full==${{matrix.mmcv}} -f https://download.openmmlab.com/mmcv/dist/cu111/${{matrix.torch_version}}/index.html
130132
python -m pip install -r requirements.txt
133+
python -m pip install -U numpy
131134
- name: Build and install
132135
run: |
133136
rm -rf .eggs && python -m pip install -e .

.isort.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ repos:
33
rev: 4.0.1
44
hooks:
55
- id: flake8
6-
- repo: https://github.com/asottile/seed-isort-config
7-
rev: v2.2.0
8-
hooks:
9-
- id: seed-isort-config
10-
- repo: https://github.com/timothycrosley/isort
11-
rev: 4.3.21
6+
- repo: https://github.com/PyCQA/isort
7+
rev: 5.10.1
128
hooks:
139
- id: isort
1410
- repo: https://github.com/pre-commit/mirrors-yapf
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
_base_ = ['../_base_/base_static.py', '../../_base_/backends/ncnn.py']
2+
3+
codebase_config = dict(model_type='ncnn_end2end')
4+
onnx_config = dict(output_names=['detection_output'], input_shape=[416, 416])
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
_base_ = ['./segmentation_static.py', '../_base_/backends/pplnn.py']
2+
3+
onnx_config = dict(input_shape=[1024, 512])
4+
5+
backend_config = dict(model_inputs=dict(opt_shape=[1, 3, 512, 1024]))

csrc/apis/c/detector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ MM_SDK_API void mmdeploy_detector_release_result(mm_detect_t* results, const int
155155
for (int i = 0; i < count; ++i) {
156156
for (int j = 0; j < result_count[i]; ++j, ++result_ptr) {
157157
if (result_ptr->mask) {
158-
delete result_ptr->mask->data;
158+
delete[] result_ptr->mask->data;
159159
delete result_ptr->mask;
160160
}
161161
}

csrc/backend_ops/torchscript/bind.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright (c) OpenMMLab. All rights reserved.
12
#include "torch/script.h"
23

34
TORCH_LIBRARY(mmdeploy, m) {

csrc/backend_ops/torchscript/ops/modulated_deform_conv/modulated_deform_conv_cpu.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright (c) OpenMMLab. All rights reserved.
12
#include "modulated_deform_conv/modulated_deform_conv_cpu.h"
23

34
#include "torch/script.h"

csrc/backend_ops/torchscript/ops/modulated_deform_conv/modulated_deform_conv_cuda.cu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright (c) OpenMMLab. All rights reserved.
12
#include "c10/cuda/CUDAStream.h"
23
#include "modulated_deform_conv/modulated_deform_conv_cuda.cuh"
34
#include "torch/script.h"

csrc/backend_ops/torchscript/optimizer/optimizer.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
// Copyright (c) OpenMMLab. All rights reserved.
12
#include "optimizer.h"
23

4+
#include <torch/csrc/jit/passes/canonicalize_graph_fuser_ops.h>
5+
#include <torch/csrc/jit/passes/common_subexpression_elimination.h>
6+
#include <torch/csrc/jit/passes/constant_pooling.h>
7+
#include <torch/csrc/jit/passes/constant_propagation.h>
8+
#include <torch/csrc/jit/passes/dead_code_elimination.h>
39
#include <torch/csrc/jit/passes/freeze_module.h>
410
#include <torch/csrc/jit/passes/frozen_graph_optimizations.h>
11+
#include <torch/csrc/jit/passes/peephole.h>
12+
#include <torch/csrc/jit/passes/remove_expands.h>
513

614
#if TORCH_VERSION_MINOR >= 9
715
#include <torch/csrc/jit/passes/frozen_conv_add_relu_fusion.h>
@@ -10,6 +18,15 @@
1018
#endif
1119

1220
namespace mmdeploy {
21+
22+
using torch::jit::Graph;
23+
const std::shared_ptr<Graph>& required_passes(const std::shared_ptr<Graph>& graph) {
24+
RemoveExpands(graph);
25+
CanonicalizeOps(graph);
26+
EliminateDeadCode(graph);
27+
return graph;
28+
}
29+
1330
Module optimize_for_torchscript(const Module& model) {
1431
auto frozen_model = freeze_module(model);
1532
auto graph = frozen_model.get_method("forward").graph();
@@ -21,6 +38,12 @@ Module optimize_for_torchscript(const Module& model) {
2138
FrozenLinearTranspose(graph);
2239
#endif
2340

41+
graph = required_passes(graph);
42+
EliminateCommonSubexpression(graph);
43+
PeepholeOptimize(graph);
44+
ConstantPropagation(graph);
45+
ConstantPooling(graph);
46+
2447
// TODO: add more custom passes
2548

2649
return frozen_model;

0 commit comments

Comments
 (0)