• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_MAX_POOL_H_
18 #define MINDSPORE_CORE_OPS_MAX_POOL_H_
19 
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <vector>
24 
25 #include "mindapi/base/format.h"
26 #include "mindapi/base/types.h"
27 #include "ops/base_operator.h"
28 
29 namespace mindspore {
30 namespace ops {
31 constexpr auto kNameMaxPool = "MaxPool";
32 /// \brief Max pooling operation. Refer to Python API @ref mindspore.ops.MaxPool for more details.
33 class MIND_API MaxPool : public BaseOperator {
34  public:
35   MIND_API_BASE_MEMBER(MaxPool);
36   /// \brief Constructor.
MaxPool()37   MaxPool() : BaseOperator(kNameMaxPool) { InitIOName({"x"}, {"output"}); }
MaxPool(const std::string k_name)38   explicit MaxPool(const std::string k_name) : BaseOperator(k_name) { InitIOName({"x"}, {"output"}); }
39   /// \brief Init. Refer to the parameters of Python API @ref mindspore.ops.MaxPool for the inputs.
40   void Init(const std::vector<int64_t> &kernel_size = {1}, const std::vector<int64_t> &stride = {1},
41             const PadMode &pad_mode = VALID, const Format &format = NCHW,
42             const std::vector<int64_t> &pad = {0, 0, 0, 0}, const RoundMode &round_mode = RoundMode::FLOOR);
43   /// \brief Set pad_mode.
44   void set_pad_mode(const PadMode &pad_mode);
45   /// \brief Set kernel_size.
46   void set_kernel_size(const std::vector<int64_t> &kernel_size);
47   /// \brief Set strides.
48   void set_strides(const std::vector<int64_t> &strides);
49   /// \brief Set format.
50   void set_format(const Format &format);
51   /// \brief Set pad.
52   void set_pad(const std::vector<int64_t> &pad);
53   /// \brief Set round_mode.
54   void set_round_mode(const RoundMode &round_mode);
55 
56   /// \brief Get kernel_size.
57   ///
58   /// \return kernel_size.
59   std::vector<int64_t> get_kernel_size() const;
60   /// \brief Get strides.
61   ///
62   /// \return strides.
63   std::vector<int64_t> get_strides() const;
64   /// \brief Get pad_mode.
65   ///
66   /// \return pad_mode.
67   PadMode get_pad_mode() const;
68   /// \brief Get format.
69   ///
70   /// \return format.
71   Format get_format() const;
72   /// \brief Get pad.
73   ///
74   /// \return pad.
75   std::vector<int64_t> get_pad() const;
76   /// \brief Get round_mode.
77   ///
78   /// \return round_mode.
79   RoundMode get_round_mode() const;
80 };
81 
82 MIND_API abstract::AbstractBasePtr MaxPoolInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive,
83                                                 const std::vector<abstract::AbstractBasePtr> &input_args);
84 }  // namespace ops
85 }  // namespace mindspore
86 
87 #endif  // MINDSPORE_CORE_OPS_MAX_POOL_H_
88