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_BACKPROP_FILTER_FUSION_H_ 18 #define MINDSPORE_CORE_OPS_CONV2D_BACKPROP_FILTER_FUSION_H_ 19 #include <vector> 20 #include <memory> 21 22 #include "ops/grad/conv2d_backprop_filter.h" 23 #include "abstract/abstract_value.h" 24 #include "utils/check_convert_utils.h" 25 26 namespace mindspore { 27 namespace ops { 28 constexpr auto kNameConv2DBackpropFilterFusion = "Conv2DBackpropFilterFusion"; 29 /// \brief Conv2DBackpropFilterFusion defined Conv2DBackpropFilter operator prototype of lite. 30 class MS_CORE_API Conv2DBackpropFilterFusion : public Conv2DBackpropFilter { 31 public: 32 /// \brief Constructor. Conv2DBackpropFilterFusion()33 Conv2DBackpropFilterFusion() : Conv2DBackpropFilter(kNameConv2DBackpropFilterFusion) { 34 InitIOName({"out_backprop", "input", "filter_sizes"}, {"output"}); 35 } 36 37 /// \brief Destructor. 38 ~Conv2DBackpropFilterFusion() = default; 39 40 MS_DECLARE_PARENT(Conv2DBackpropFilterFusion, Conv2DBackpropFilter); 41 42 /// \brief Method to init the op's attributes. 43 /// 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] pad_mode Define the padding method. 47 /// \param[in] pad_list Define the concrete padding value on H and W dimension. 48 /// \param[in] mode Define the category of conv, which is useless on lite. 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. 52 /// \param[in] group Define the number of group. 53 /// \param[in] format Define the format of input tensor. 54 /// \param[in] activation_type Define the activation type. 55 void Init(const int64_t out_channel, const std::vector<int64_t> &kernel_size, const PadMode &pad_mode = VALID, 56 const std::vector<int64_t> &pad_list = {0, 0, 0, 0}, const int64_t mode = 1, 57 const std::vector<int64_t> &stride = {1, 1}, const std::vector<int64_t> &dilation = {1, 1, 1, 1}, 58 const int64_t group = 1, const Format &format = NCHW, const ActivationType activation_type = NO_ACTIVATION); 59 60 /// \brief Method to set activation type. 61 /// 62 /// \param[in] activation_type Define the activation type. 63 void set_activation_type(const ActivationType activation_type); 64 65 /// \brief Method to set in_channel attribute. 66 /// 67 /// \param[in] in_channel Define the number of input channel. 68 void set_in_channel(const int64_t in_channel); 69 70 /// \brief Method to get activation type. 71 /// 72 /// \return activation type. 73 ActivationType get_activation_type() const; 74 75 /// \brief Method to get in_channel attribute. 76 /// 77 /// \return the number of input channel. 78 int64_t get_in_channel() const; 79 }; 80 } // namespace ops 81 } // namespace mindspore 82 83 #endif // MINDSPORE_CORE_OPS_CONV2D_BACKPROP_FILTER_FUSION_H_ 84