• 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_MAX_POOL_FUSION_H_
18 #define MINDSPORE_CORE_OPS_MAX_POOL_FUSION_H_
19 #include <memory>
20 #include <vector>
21 
22 #include "mindapi/base/types.h"
23 #include "ops/max_pool.h"
24 
25 namespace mindspore {
26 namespace ops {
27 constexpr auto kNameMaxPoolFusion = "MaxPoolFusion";
28 /// \brief MaxPoolFusion defined MaxPool operator prototype of lite.
29 class MIND_API MaxPoolFusion : public MaxPool {
30  public:
31   MIND_API_BASE_MEMBER(MaxPoolFusion);
32   /// \brief Constructor.
MaxPoolFusion()33   MaxPoolFusion() : MaxPool(kNameMaxPoolFusion) { InitIOName({"x"}, {"output"}); }
34 
35   /// \brief Method to init the op's attributes.
36   ///
37   /// \param[in] kernel_size Define the size of the kernel.
38   /// \param[in] stride Define the moving size of the kernel.
39   /// \param[in] pad_mode Define the padding method.
40   /// \param[in] format Define the format of input tensor.
41   /// \param[in] pad Define the concrete padding value on each dimension
42   /// \param[in] round_mode Define numerical operation mode of the output tensor.
43   /// \param[in] global Define a boolean value to indicate whether to do global pooling. If true, kernel_size will be
44   ///            useless.
45   /// \param[in] activation_type Define the activation type.
46   void Init(const std::vector<int64_t> &kernel_size = {1}, const std::vector<int64_t> &stride = {1},
47             const PadMode &pad_mode = VALID, const Format &format = NCHW,
48             const std::vector<int64_t> &pad = {0, 0, 0, 0}, const RoundMode &round_mode = RoundMode::FLOOR,
49             const bool global = false, const ActivationType activation_type = NO_ACTIVATION);
50 
51   /// \brief Method to set global attribute.
52   ///
53   /// \param[in] global Define a boolean value to indicate whether to do global pooling. If true, kernel_size will be
54   ///            useless.
55   void set_global(const bool global);
56 
57   /// \brief Method to set activation type.
58   ///
59   /// \param[in] activation_type Define the activation type.
60   void set_activation_type(const ActivationType activation_type);
61 
62   /// \brief Method to get global attribute.
63   ///
64   /// \return a boolean value to indicate whether to do global pooling. If true, kernel_size will be useless.
65   bool get_global() const;
66 
67   /// \brief Method to get activation type.
68   ///
69   /// \return activation type.
70   ActivationType get_activation_type() const;
71 };
72 
73 abstract::AbstractBasePtr MaxPoolFusionInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive,
74                                              const std::vector<abstract::AbstractBasePtr> &input_args);
75 }  // namespace ops
76 }  // namespace mindspore
77 
78 #endif  // MINDSPORE_CORE_OPS_MAX_POOL_FUSION_H_
79