• 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_REDUCE_H_
18 #define MINDSPORE_CORE_OPS_REDUCE_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 kNameReduce = "Reduce";
30 /// \brief Reduce defined Reduce operator prototype of lite.
31 class MS_CORE_API Reduce : public PrimitiveC {
32  public:
33   /// \brief Constructor.
Reduce()34   Reduce() : PrimitiveC(kNameReduce) { InitIOName({"input_x", "axis"}, {"y"}); }
35 
36   /// \brief Constructor.
Reduce(const std::string k_name)37   explicit Reduce(const std::string k_name) : PrimitiveC(k_name) { InitIOName({"input_x", "axis"}, {"y"}); }
38 
39   /// \brief Destructor.
40   ~Reduce() = default;
41 
42   MS_DECLARE_PARENT(Reduce, PrimitiveC);
43 
44   /// \brief Method to init the op's attributes.
45   ///
46   /// \param[in] keep_dims Define whether keep the dims reduced, default false.
47   void Init(const bool keep_dims = false);
48 
49   /// \brief Method to set keep_dims attribute.
50   ///
51   /// \param[in] keep_dims Define whether keep the dims reduced, default false.
52   void set_keep_dims(const bool keep_dims);
53 
54   /// \brief Method to get keep_dims attribute.
55   ///
56   /// \return keep_dims attribute.
57   bool get_keep_dims() const;
58 };
59 AbstractBasePtr ReduceInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive,
60                             const std::vector<AbstractBasePtr> &input_args);
61 using PrimReducePtr = std::shared_ptr<Reduce>;
62 }  // namespace ops
63 }  // namespace mindspore
64 
65 #endif  // MINDSPORE_CORE_OPS_REDUCE_H_
66