From 5db17907b432d4adbad55737856e4a73ae85d60e Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Tue, 5 Jan 2021 18:58:11 +0800 Subject: [PATCH] chore(megbrain): fix megskull cnn/img opr compatiblity for add convolutionv2 param GitOrigin-RevId: 9d0cf55ef46448c8d26682a8d365612880eb1321 --- src/opr/impl/dnn/dnn.oprdecl | 12 ++++++----- src/opr/impl/dnn/dnn.sereg.h | 39 +++++++++++++++++++----------------- src/opr/impl/imgproc.oprdecl | 6 +++--- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/opr/impl/dnn/dnn.oprdecl b/src/opr/impl/dnn/dnn.oprdecl index 6c05cb70f..fe4fea933 100644 --- a/src/opr/impl/dnn/dnn.oprdecl +++ b/src/opr/impl/dnn/dnn.oprdecl @@ -65,7 +65,7 @@ decl_opr('MaskConvolution', params=[('param', 'Convolution')], desc=('batched mask conv on channeled 2D images, mask is correspoding ' 'to output'), - version=1) + version=2) decl_opr('MaskPropagate', inputs=[Doc('src', @@ -102,10 +102,11 @@ decl_opr('Local', 'convolution kernel in ' '(out row, out col, in channel, ' 'kern row, kern col, out channel) format')], - params='ConvolutionV0', + params='Convolution', desc='batched convolution on channeled 2D images, but kernels are ' - 'not shared across different output positions') + 'not shared across different output positions', version=2) +""" decl_opr('Local', pyname='local_v1', inputs=[Doc('src', @@ -118,6 +119,7 @@ decl_opr('Local', desc='batched convolution on channeled 2D images, but kernels are ' 'not shared across different output positions', version=1) +""" decl_opr('GroupLocal', inputs=[Doc('src', @@ -129,7 +131,7 @@ decl_opr('GroupLocal', params=[('param', 'Convolution')], desc='batched convolution on groupped channeled 2D images, but ' 'kernels are not shared across different output positions', - version=1) + version=2) decl_opr('LRN', inputs=['src'], @@ -280,7 +282,7 @@ decl_opr('DeformableConvForward', Doc('mask', 'deformable mask in (batch, deformable group * filter row * filter col, output row, output col) format')], params=[('param', 'Convolution'), ('execution_policy', 'ExecutionPolicy')], desc=Doc(None, r""" Apply a deformable convolution to input tensor and filter tensor. The offset tensor will adjust the position of each grid of a convolution filter. The mask tensor will be applied to the deformed input tensor. """), - has_out_dtype=True) + has_out_dtype=True, version=1) decl_opr('DeformablePSROIPoolingForward', pyname='deformable_psroi_pooling', diff --git a/src/opr/impl/dnn/dnn.sereg.h b/src/opr/impl/dnn/dnn.sereg.h index f9846d17c..9a90e6c94 100644 --- a/src/opr/impl/dnn/dnn.sereg.h +++ b/src/opr/impl/dnn/dnn.sereg.h @@ -514,19 +514,19 @@ MGB_SEREG_OPR(ConvolutionBackwardFilterV2, 0); MGB_SEREG_OPR(Images2Neibs, 1); MGB_SEREG_OPR(Images2NeibsBackward, 2); -using LocalV1 = Local; -using LocalBackwardDataV1 = LocalBackwardData; -using LocalBackwardFilterV1 = LocalBackwardFilter; -MGB_SEREG_OPR(LocalV1, 2); -MGB_SEREG_OPR(LocalBackwardDataV1, 3); -MGB_SEREG_OPR(LocalBackwardFilterV1, 3); - -using GroupLocalV1 = GroupLocal; -using GroupLocalBackwardDataV1 = GroupLocalBackwardData; -using GroupLocalBackwardFilterV1 = GroupLocalBackwardFilter; -MGB_SEREG_OPR(GroupLocalV1, 2); -MGB_SEREG_OPR(GroupLocalBackwardDataV1, 3); -MGB_SEREG_OPR(GroupLocalBackwardFilterV1, 3); +using LocalV2 = Local; +using LocalBackwardDataV2 = LocalBackwardData; +using LocalBackwardFilterV2 = LocalBackwardFilter; +MGB_SEREG_OPR(LocalV2, 2); +MGB_SEREG_OPR(LocalBackwardDataV2, 3); +MGB_SEREG_OPR(LocalBackwardFilterV2, 3); + +using GroupLocalV2 = GroupLocal; +using GroupLocalBackwardDataV2 = GroupLocalBackwardData; +using GroupLocalBackwardFilterV2 = GroupLocalBackwardFilter; +MGB_SEREG_OPR(GroupLocalV2, 2); +MGB_SEREG_OPR(GroupLocalBackwardDataV2, 3); +MGB_SEREG_OPR(GroupLocalBackwardFilterV2, 3); MGB_SEREG_OPR(LRN, 1); MGB_SEREG_OPR(LRNBackward, 3); @@ -542,8 +542,8 @@ MGB_SEREG_OPR(AdaptivePoolingBackwardV1, 4); MGB_SEREG_OPR(ROIPooling, 3); MGB_SEREG_OPR(ROIPoolingBackward, 4); -using MaskConvolutionV1 = MaskConvolution; -MGB_SEREG_OPR(MaskConvolutionV1, 3); +using MaskConvolutionV2 = MaskConvolution; +MGB_SEREG_OPR(MaskConvolutionV2, 3); MGB_SEREG_OPR(MaskPropagate, 1); MGB_SEREG_OPR(Convolution3D, 0); @@ -567,9 +567,12 @@ using ROIAlignV1 = ROIAlign; using ROIAlignBackwardV1 = ROIAlignBackward; MGB_SEREG_OPR(ROIAlignV1, 2); MGB_SEREG_OPR(ROIAlignBackwardV1, 4); -MGB_SEREG_OPR(DeformableConvForward, 0); -MGB_SEREG_OPR(DeformableConvBackwardData, 0); -MGB_SEREG_OPR(DeformableConvBackwardFilter, 0); +using DeformableConvForwardV1 = DeformableConvForward; +using DeformableConvBackwardDataV1 = DeformableConvBackwardData; +using DeformableConvBackwardFilterV1 = DeformableConvBackwardFilter; +MGB_SEREG_OPR(DeformableConvForwardV1, 0); +MGB_SEREG_OPR(DeformableConvBackwardDataV1, 0); +MGB_SEREG_OPR(DeformableConvBackwardFilterV1, 0); MGB_SEREG_OPR(DeformablePSROIPoolingForward, 3); MGB_SEREG_OPR(DeformablePSROIPoolingBackward, 5); diff --git a/src/opr/impl/imgproc.oprdecl b/src/opr/impl/imgproc.oprdecl index 4041b5d11..6e823d74c 100644 --- a/src/opr/impl/imgproc.oprdecl +++ b/src/opr/impl/imgproc.oprdecl @@ -24,8 +24,8 @@ decl_opr( params='WarpPerspective', desc='like :func:`warp_perspective`, but the **mat** param does not have ' 'to have the same batch size as **src**; instead, **mat_idx** specifies ' - 'the batch number of each matrix in **mat**' -) + 'the batch number of each matrix in **mat**', + version=2) decl_opr('Rotate', inputs=[ @@ -111,7 +111,7 @@ decl_raw_opr( 'assert not kwargs, "extra kwargs: {}".format(kwargs)', 'all_params = []', 'all_params.append(param.serialize())', - 'output = _mgb._create_opr("DctChannelSelect", all_inputs, all_params, config)', + 'output = _mgb._create_opr("DctChannelSelectV1", all_inputs, all_params, config)', ], has_out_dtype=True, desc='DctChannelSelect do DCT with channel select' -- GitLab