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_H_ 18 #define MINDSPORE_CORE_OPS_CONV2D_H_ 19 #include <map> 20 #include <memory> 21 #include <string> 22 #include <vector> 23 24 #include "mindapi/base/format.h" 25 #include "mindapi/base/types.h" 26 #include "ops/base_operator.h" 27 28 namespace mindspore { 29 namespace ops { 30 constexpr auto kNameConv2D = "Conv2D"; 31 /// \brief 2D convolution layer. Refer to Python API @ref mindspore.ops.Conv2D for more details. 32 class MIND_API Conv2D : public BaseOperator { 33 public: 34 MIND_API_BASE_MEMBER(Conv2D); 35 /// \brief Constructor. Conv2D()36 Conv2D() : BaseOperator(kNameConv2D) { InitIOName({"x", "w"}, {"output"}); } Conv2D(const std::string k_name)37 explicit Conv2D(const std::string k_name) : BaseOperator(k_name) { InitIOName({"x", "w"}, {"output"}); } 38 /// \brief Init. Refer to the parameters of Python API @ref mindspore.ops.Conv2D for the inputs. 39 void Init(int64_t out_channel, const std::vector<int64_t> &kernel_size, int64_t mode = 1, 40 const PadMode &pad_mode = VALID, const std::vector<int64_t> &pad = {0, 0, 0, 0}, 41 const std::vector<int64_t> &stride = {1, 1, 1, 1}, const std::vector<int64_t> &dilation = {1, 1, 1, 1}, 42 int64_t group = 1, const Format &format = NCHW); 43 /// \brief Set kernel_size. 44 void set_kernel_size(const std::vector<int64_t> &kernel_size); 45 /// \brief Set stride. 46 void set_stride(const std::vector<int64_t> &stride); 47 /// \brief Set dilation. 48 void set_dilation(const std::vector<int64_t> &dilation); 49 /// \brief Set pad_mode. 50 void set_pad_mode(const PadMode &pad_mode); 51 /// \brief Set pad. 52 void set_pad(const std::vector<int64_t> &pad); 53 /// \brief Set mode. 54 void set_mode(int64_t mode); 55 /// \brief Set group. 56 void set_group(int64_t group); 57 /// \brief Set out_channel. 58 void set_out_channel(int64_t out_channel); 59 /// \brief Set format. 60 void set_format(const Format &format); 61 /// \brief Get kernel_size. 62 /// 63 /// \return kernel_size. 64 std::vector<int64_t> get_kernel_size() const; 65 /// \brief Get stride. 66 /// 67 /// \return stride. 68 std::vector<int64_t> get_stride() const; 69 /// \brief Get dilation. 70 /// 71 /// \return dilation. 72 std::vector<int64_t> get_dilation() const; 73 /// \brief Get pad_mode. 74 /// 75 /// \return pad_mode. 76 PadMode get_pad_mode() const; 77 /// \brief Get pad. 78 /// 79 /// \return pad. 80 std::vector<int64_t> get_pad() const; 81 /// \brief Get mode. 82 /// 83 /// \return mode. 84 int64_t get_mode() const; 85 /// \brief Get group. 86 /// 87 /// \return group. 88 int64_t get_group() const; 89 /// \brief Get out_channel. 90 /// 91 /// \return out_channel. 92 int64_t get_out_channel() const; 93 /// \brief Get format. 94 /// 95 /// \return format. 96 Format get_format() const; 97 }; 98 MIND_API abstract::AbstractBasePtr Conv2dInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, 99 const std::vector<abstract::AbstractBasePtr> &input_args); 100 } // namespace ops 101 } // namespace mindspore 102 #endif // MINDSPORE_CORE_OPS_CONV2D_H_ 103