1 /** 2 * Copyright 2020 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_H_ 18 #define MINDSPORE_CORE_OPS_CONV2D_TRANSPOSE_H_ 19 #include <map> 20 #include <vector> 21 #include <string> 22 #include <memory> 23 24 #include "ops/op_utils.h" 25 #include "ops/primitive_c.h" 26 #include "abstract/abstract_value.h" 27 #include "utils/check_convert_utils.h" 28 namespace mindspore { 29 namespace ops { 30 constexpr auto kNameConv2DTranspose = "Conv2DTranspose"; 31 /// \brief 2D transposed convolution layer. Refer to Python API @ref mindspore.nn.Conv2dTranspose for more details. 32 class MS_CORE_API Conv2DTranspose : public PrimitiveC { 33 public: 34 /// \brief Constructor. Conv2DTranspose()35 Conv2DTranspose() : PrimitiveC(kNameConv2DTranspose) { 36 InitIOName({"out_backprop", "filter", "input_sizes"}, {"output"}); 37 } Conv2DTranspose(const std::string k_name)38 explicit Conv2DTranspose(const std::string k_name) : PrimitiveC(k_name) { 39 InitIOName({"out_backprop", "filter", "input_sizes"}, {"output"}); 40 } 41 /// \brief Destructor. 42 ~Conv2DTranspose() = default; 43 MS_DECLARE_PARENT(Conv2DTranspose, PrimitiveC); 44 /// \brief Init. Refer to the parameters of Python API @ref mindspore.nn.Conv2dTranspose for the inputs. 45 void Init(int64_t in_channel, int64_t out_channel, const std::vector<int64_t> &kernel_size, int64_t mode = 1, 46 const PadMode &pad_mode = VALID, const std::vector<int64_t> &pad = {0, 0, 0, 0}, 47 const std::vector<int64_t> &stride = {1, 1}, const std::vector<int64_t> &dilation = {1, 1}, 48 int64_t group = 1, const Format &format = NCHW, const std::vector<int64_t> &pad_list = {0, 0, 0, 0}); 49 /// \brief Set in_channel. 50 void set_in_channel(int64_t in_channel); 51 /// \brief Set out_channel. 52 void set_out_channel(int64_t out_channel); 53 /// \brief Set kernel_size. 54 virtual void set_kernel_size(const std::vector<int64_t> &kernel_size); 55 /// \brief Set stride. 56 void set_stride(const std::vector<int64_t> &stride); 57 /// \brief Set dilation. 58 virtual void set_dilation(const std::vector<int64_t> &dilation); 59 /// \brief Set pad_mode. 60 void set_pad_mode(const PadMode &pad_mode); 61 /// \brief Set pad. 62 void set_pad(const std::vector<int64_t> &pad); 63 /// \brief Set mode. 64 void set_mode(int64_t mode); 65 /// \brief Set group. 66 void set_group(int64_t group); 67 /// \brief Set format. 68 void set_format(const Format &format); 69 /// \brief Set pad_list. 70 void set_pad_list(const std::vector<int64_t> &pad_list); 71 72 /// \brief Get in_channel. 73 /// 74 /// \return in_channel. 75 int64_t get_in_channel() const; 76 /// \brief Get out_channel. 77 /// 78 /// \return out_channel. 79 int64_t get_out_channel() const; 80 /// \brief Get kernel_size. 81 /// 82 /// \return kernel_size. 83 std::vector<int64_t> get_kernel_size() const; 84 /// \brief Get stride. 85 /// 86 /// \return stride. 87 std::vector<int64_t> get_stride() const; 88 /// \brief Get dilation. 89 /// 90 /// \return dilation. 91 std::vector<int64_t> get_dilation() const; 92 /// \brief Get pad_mode. 93 /// 94 /// \return pad_mode. 95 PadMode get_pad_mode() const; 96 /// \brief Get pad. 97 /// 98 /// \return pad. 99 std::vector<int64_t> get_pad() const; 100 /// \brief Get mode. 101 /// 102 /// \return mode. 103 int64_t get_mode() const; 104 /// \brief Get group. 105 /// 106 /// \return group. 107 int64_t get_group() const; 108 /// \brief Get format. 109 /// 110 /// \return format. 111 Format get_format() const; 112 /// \brief Get pad_list. 113 /// 114 /// \return pad_list. 115 std::vector<int64_t> get_pad_list() const; 116 }; 117 AbstractBasePtr Conv2DTransposeInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, 118 const std::vector<AbstractBasePtr> &input_args); 119 using PrimConv2DTransposePtr = std::shared_ptr<Conv2DTranspose>; 120 } // namespace ops 121 } // namespace mindspore 122 #endif // MINDSPORE_CORE_OPS_CONV2D_TRANSPOSE_H_ 123