• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-2021 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINDSPORE_CORE_OPS_CONV2D_TRANSPOSE_FUSION_H_
18 #define MINDSPORE_CORE_OPS_CONV2D_TRANSPOSE_FUSION_H_
19 #include <vector>
20 
21 #include "ops/conv2d_transpose.h"
22 #include "abstract/abstract_value.h"
23 #include "utils/check_convert_utils.h"
24 
25 namespace mindspore {
26 namespace ops {
27 constexpr auto kNameConv2dTransposeFusion = "Conv2dTransposeFusion";
28 /// \brief Conv2dTransposeFusion defined Conv2dTranspose operator prototype of lite.
29 class MS_CORE_API Conv2dTransposeFusion : public Conv2DTranspose {
30  public:
31   /// \brief Constructor.
Conv2dTransposeFusion()32   Conv2dTransposeFusion() : Conv2DTranspose(kNameConv2dTransposeFusion) {
33     InitIOName({"out_backprop", "filter", "input_sizes"}, {"output"});
34   }
35 
36   /// \brief Destructor.
37   ~Conv2dTransposeFusion() = default;
38 
39   MS_DECLARE_PARENT(Conv2dTransposeFusion, Conv2DTranspose);
40 
41   /// \brief Method to init the op's attributes.
42   ///
43   /// \param[in] in_channel Define the number of input channel.
44   /// \param[in] out_channel Define the number of output channel.
45   /// \param[in] kernel_size Define the size of the filter kernel.
46   /// \param[in] mode Define the category of conv, which is useless on lite.
47   /// \param[in] pad_mode Define the padding method.
48   /// \param[in] pad Define the concrete padding value on H and W dimension, which is replaced with pad_list.
49   /// \param[in] stride Define the moving size of the filter kernel.
50   /// \param[in] dilation Define the coefficient of expansion of the filter kernel, which is useful for dilated
51   ///            convolution-transpose.
52   /// \param[in] group Define the number of group.
53   /// \param[in] format Define the format of input tensor.
54   /// \param[in] pad_list Define the concrete padding value on H and W dimension.
55   /// \param[in] output_paddings Define the additional elements added to the side with higher coordinate indices in the
56   ///            output, which is used to control the selection-range of the output tensor.
57   /// \param[in] activation_type Define the activation type.
58   void Init(int64_t in_channel, int64_t out_channel, const std::vector<int64_t> &kernel_size, int64_t mode = 1,
59             const PadMode &pad_mode = VALID, const std::vector<int64_t> &pad = {0, 0, 0, 0},
60             const std::vector<int64_t> &stride = {1, 1}, const std::vector<int64_t> &dilation = {1, 1},
61             int64_t group = 1, const Format &format = NCHW, const std::vector<int64_t> &pad_list = {0, 0, 0, 0},
62             const std::vector<int64_t> &output_paddings = {0}, ActivationType activation_type = NO_ACTIVATION);
63 
64   /// \brief Method to set kernel_size attribute.
65   ///
66   /// \param[in] kernel_size Define the size of the filter kernel.
67   void set_kernel_size(const std::vector<int64_t> &kernel_size) override;
68 
69   /// \brief Method to set dilation attribute.
70   ///
71   /// \param[in] dilation Define the coefficient of expansion of the filter kernel, which is useful for dilated
72   ///            convolution-transpose.
73   void set_dilation(const std::vector<int64_t> &dilation) override;
74 
75   /// \brief Method to set output_paddings attribute.
76   ///
77   /// \param[in] output_paddings Define the additional elements added to the side with higher coordinate indices in the
78   ///            output, which is used to control the selection-range of the output tensor.
79   void set_output_paddings(const std::vector<int64_t> &output_paddings);
80 
81   /// \brief Method to set activation type.
82   ///
83   /// \param[in] activation_type Define the activation type.
84   void set_activation_type(ActivationType activation_type);
85 
86   /// \brief Method to get output_paddings attribute.
87   ///
88   /// \return output_paddings value.
89   std::vector<int64_t> get_output_paddings() const;
90 
91   /// \brief Method to get activation type.
92   ///
93   /// \return activation type.
94   ActivationType get_activation_type() const;
95 };
96 }  // namespace ops
97 }  // namespace mindspore
98 
99 #endif  // MINDSPORE_CORE_OPS_CONV2D_TRANSPOSE_FUSION_H_
100