• 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_POOL_GRAD_H_
18 #define MINDSPORE_CORE_OPS_POOL_GRAD_H_
19 #include <map>
20 #include <vector>
21 #include <string>
22 #include <memory>
23 #include "ops/primitive_c.h"
24 #include "abstract/abstract_value.h"
25 #include "utils/check_convert_utils.h"
26 
27 namespace mindspore {
28 namespace ops {
29 constexpr auto kNamePoolGrad = "PoolGrad";
30 class MS_CORE_API PoolGrad : public PrimitiveC {
31  public:
PoolGrad()32   PoolGrad() : PrimitiveC(kNamePoolGrad) { InitIOName({"x_origin", "out_origin", "grad"}, {"output"}); }
PoolGrad(const std::string k_name)33   explicit PoolGrad(const std::string k_name) : PrimitiveC(k_name) {
34     InitIOName({"x_origin", "out_origin", "grad"}, {"output"});
35   }
36   ~PoolGrad() = default;
37   MS_DECLARE_PARENT(PoolGrad, PrimitiveC);
38   virtual void Init(const std::vector<int64_t> &kernel_size = {1}, const std::vector<int64_t> &strides = {1},
39                     const PadMode &pad_mode = VALID, const Format &format = NCHW);
40   virtual void set_kernel_size(const std::vector<int64_t> &kernel_size);
41   virtual void set_strides(const std::vector<int64_t> &strides);
42   void set_pad_mode(const PadMode &pad_mode);
43   void set_format(const Format &format);
44 
45   std::vector<int64_t> get_kernel_size() const;
46   std::vector<int64_t> get_strides() const;
47   PadMode get_pad_mode() const;
48   Format get_format() const;
49   std::vector<int64_t> _grad_check_vector(const std::string &arg_name, const std::vector<int64_t> arg_val,
50                                           const std::string &op_name);
51 };
52 }  // namespace ops
53 }  // namespace mindspore
54 
55 #endif  // MINDSPORE_CORE_OPS_POOL_GRAD_H_
56