From ef581f569248c94d1d7adb5938e8779ead2cc788 Mon Sep 17 00:00:00 2001 From: xulei Date: Mon, 10 Oct 2022 20:10:49 +0800 Subject: [PATCH] update backprop of conv2d op register --- .../op_declare/nn_calculation_ops_declare.cc | 36 +++++++------------ .../op_declare/nn_calculation_ops_declare.h | 13 +++---- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/mindspore/ccsrc/transform/graph_ir/op_declare/nn_calculation_ops_declare.cc b/mindspore/ccsrc/transform/graph_ir/op_declare/nn_calculation_ops_declare.cc index 96a35211987..4f651a07fcf 100644 --- a/mindspore/ccsrc/transform/graph_ir/op_declare/nn_calculation_ops_declare.cc +++ b/mindspore/ccsrc/transform/graph_ir/op_declare/nn_calculation_ops_declare.cc @@ -37,30 +37,20 @@ ATTR_MAP(Conv2D) = { OUTPUT_MAP(Conv2D) = {{0, OUTPUT_DESC(y)}}; REG_ADPT_DESC(Conv2D, prim::kPrimConv2D->name(), ADPT_DESC(Conv2D)) -// Conv2DBackpropInputD -INPUT_MAP(Conv2DBackpropInputD) = {{1, INPUT_DESC(out_backprop)}, {2, INPUT_DESC(filter)}}; -INPUT_ATTR_MAP(Conv2DBackpropInputD) = { - {3, ATTR_DESC(input_size, AnyTraits>(), AnyTraits>())}}; -ATTR_MAP(Conv2DBackpropInputD) = { +// Conv2DBackpropInput +INPUT_MAP(Conv2DBackpropInput) = {{1, INPUT_DESC(out_backprop)}, {2, INPUT_DESC(filter)}, {3, INPUT_DESC(input_size)}}; +ATTR_MAP(Conv2DBackpropInput) = { {"pad_list", ATTR_DESC(pads, AnyTraits>(), AnyTraits>())}, {"stride", ATTR_DESC(strides, AnyTraits>())}, {"dilation", ATTR_DESC(dilations, AnyTraits>(), AnyTraits>())}, {"format", ATTR_DESC(data_format, AnyTraits())}, {"group", ATTR_DESC(groups, AnyTraits())}, }; -OUTPUT_MAP(Conv2DBackpropInputD) = {{0, OUTPUT_DESC(y)}}; -REG_ADPT_DESC(Conv2DBackpropInputD, prim::kPrimConv2DBackpropInput->name(), ADPT_DESC(Conv2DBackpropInputD)) +OUTPUT_MAP(Conv2DBackpropInput) = {{0, OUTPUT_DESC(y)}}; +REG_ADPT_DESC(Conv2DBackpropInput, prim::kPrimConv2DBackpropInput->name(), ADPT_DESC(Conv2DBackpropInput)) // Conv2DBackpropInput for tf inference -INPUT_MAP(Conv2DBackpropInput) = {{1, INPUT_DESC(input_size)}, {2, INPUT_DESC(filter)}, {3, INPUT_DESC(out_backprop)}}; -ATTR_MAP(Conv2DBackpropInput) = { - {"stride", ATTR_DESC(strides, AnyTraits>())}, - {"dilation", ATTR_DESC(dilations, AnyTraits>(), AnyTraits>())}, - {"pad_list", ATTR_DESC(pads, AnyTraits>(), AnyTraits>())}, - {"data_format", ATTR_DESC(data_format, AnyTraits())}, -}; -OUTPUT_MAP(Conv2DBackpropInput) = {{0, OUTPUT_DESC(y)}}; -REG_ADPT_DESC(Conv2DBackpropInput, kNameConv2DBackpropInputV2, ADPT_DESC(Conv2DBackpropInput)) +REG_ADPT_DESC(Conv2DBackpropInputV2, kNameConv2DBackpropInputV2, ADPT_DESC(Conv2DBackpropInput)) // Deconvolution for caffe inference INPUT_MAP(Deconvolution) = { @@ -74,7 +64,7 @@ ATTR_MAP(Deconvolution) = { {"offset", ATTR_DESC(offset_x, AnyTraits())}}; OUTPUT_MAP(Deconvolution) = {{0, OUTPUT_DESC(y)}}; REG_ADPT_DESC(Deconvolution, kNameDeconvolution, ADPT_DESC(Deconvolution)) -REG_ADPT_DESC(Conv2DTranspose, kConv2DTransposeOpName, ADPT_DESC(Conv2DBackpropInputD)) +REG_ADPT_DESC(Conv2DTranspose, kConv2DTransposeOpName, ADPT_DESC(Conv2DBackpropInput)) // Conv2DTransposeD for tf onnx inference INPUT_MAP(Conv2DTransposeD) = { @@ -91,19 +81,17 @@ ATTR_MAP(Conv2DTransposeD) = { OUTPUT_MAP(Conv2DTransposeD) = {{0, OUTPUT_DESC(y)}}; REG_ADPT_DESC(Conv2DTransposeD, kNameConv2DTransposeD, ADPT_DESC(Conv2DTransposeD)) -// Conv2DBackpropFilterD -INPUT_MAP(Conv2DBackpropFilterD) = {{1, INPUT_DESC(out_backprop)}, {2, INPUT_DESC(x)}}; -INPUT_ATTR_MAP(Conv2DBackpropFilterD) = { - {3, ATTR_DESC(filter_size, AnyTraits>(), AnyTraits>())}}; -ATTR_MAP(Conv2DBackpropFilterD) = { +// Conv2DBackpropFilter +INPUT_MAP(Conv2DBackpropFilter) = {{1, INPUT_DESC(out_backprop)}, {2, INPUT_DESC(x)}, {3, INPUT_DESC(filter_size)}}; +ATTR_MAP(Conv2DBackpropFilter) = { {"pad_list", ATTR_DESC(pads, AnyTraits>(), AnyTraits>())}, {"stride", ATTR_DESC(strides, AnyTraits>(), AnyTraits>())}, {"dilation", ATTR_DESC(dilations, AnyTraits>(), AnyTraits>())}, {"format", ATTR_DESC(data_format, AnyTraits())}, {"group", ATTR_DESC(groups, AnyTraits())}, }; -OUTPUT_MAP(Conv2DBackpropFilterD) = {{0, OUTPUT_DESC(y)}}; -REG_ADPT_DESC(Conv2DBackpropFilterD, prim::kPrimConv2DBackpropFilter->name(), ADPT_DESC(Conv2DBackpropFilterD)) +OUTPUT_MAP(Conv2DBackpropFilter) = {{0, OUTPUT_DESC(y)}}; +REG_ADPT_DESC(Conv2DBackpropFilter, prim::kPrimConv2DBackpropFilter->name(), ADPT_DESC(Conv2DBackpropFilter)) // Conv3DTransposeD INPUT_MAP(Conv3DTransposeD) = { diff --git a/mindspore/ccsrc/transform/graph_ir/op_declare/nn_calculation_ops_declare.h b/mindspore/ccsrc/transform/graph_ir/op_declare/nn_calculation_ops_declare.h index ab2d2e78bce..3f4a25b154a 100644 --- a/mindspore/ccsrc/transform/graph_ir/op_declare/nn_calculation_ops_declare.h +++ b/mindspore/ccsrc/transform/graph_ir/op_declare/nn_calculation_ops_declare.h @@ -29,18 +29,13 @@ DECLARE_OP_ADAPTER(Conv2D) DECLARE_OP_USE_ENUM(Conv2D) DECLARE_OP_USE_OUTPUT(Conv2D) -DECLARE_OP_ADAPTER(Conv2DBackpropInputD) -DECLARE_OP_USE_ENUM(Conv2DBackpropInputD) -DECLARE_OP_USE_INPUT_ATTR(Conv2DBackpropInputD) -DECLARE_OP_USE_OUTPUT(Conv2DBackpropInputD) - DECLARE_OP_ADAPTER(Conv2DBackpropInput) +DECLARE_OP_USE_ENUM(Conv2DBackpropInput) DECLARE_OP_USE_OUTPUT(Conv2DBackpropInput) -DECLARE_OP_ADAPTER(Conv2DBackpropFilterD) -DECLARE_OP_USE_ENUM(Conv2DBackpropFilterD) -DECLARE_OP_USE_INPUT_ATTR(Conv2DBackpropFilterD) -DECLARE_OP_USE_OUTPUT(Conv2DBackpropFilterD) +DECLARE_OP_ADAPTER(Conv2DBackpropFilter) +DECLARE_OP_USE_ENUM(Conv2DBackpropFilter) +DECLARE_OP_USE_OUTPUT(Conv2DBackpropFilter) DECLARE_OP_ADAPTER(Conv3DTransposeD) DECLARE_OP_USE_ENUM(Conv3DTransposeD)