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_REDUCE_FUSION_H_ 18 #define MINDSPORE_CORE_OPS_REDUCE_FUSION_H_ 19 #include <map> 20 #include <memory> 21 #include <string> 22 #include "mindapi/base/types.h" 23 #include "ops/reduce.h" 24 25 namespace mindspore { 26 namespace ops { 27 constexpr auto kNameReduceFusion = "ReduceFusion"; 28 /// \brief ReduceFusion defined Reduce operator prototype of lite. 29 class MIND_API ReduceFusion : public Reduce { 30 public: 31 MIND_API_BASE_MEMBER(ReduceFusion); 32 /// \brief Constructor. ReduceFusion()33 ReduceFusion() : Reduce(kNameReduceFusion) {} 34 35 /// \brief Method to init the op's attributes. 36 /// 37 /// \param[in] keep_dims Define a boolean value to indicate whether output dimension is kept or not. 38 /// \param[in] mode Define the concrete reduction mode. 39 /// \param[in] reduce_to_end Define a boolean value to indicate whether the operation need to do from the given axis 40 /// to the last. 41 /// \param[in] coeff Define a size factor applied to output. 42 void Init(const bool keep_dims = false, const ReduceMode mode = ReduceMode::Reduce_Mean, 43 const bool reduce_to_end = false, const float coeff = 1.0); 44 45 /// \brief Method to set keep_dims attribute. 46 /// 47 /// \param[in] keep_dims Define a boolean value to indicate whether output dimension is kept or not. 48 void set_keep_dims(const bool keep_dims); 49 50 /// \brief Method to set mode attribute. 51 /// 52 /// \param[in] mode Define the concrete reduction mode. 53 void set_mode(const ReduceMode mode); 54 55 /// \brief Method to set reduce_to_end attribute. 56 /// 57 /// \param[in] reduce_to_end Define a boolean value to indicate whether the operation need to do from the given axis 58 /// to the last. 59 void set_reduce_to_end(const bool reduce_to_end); 60 61 /// \brief Method to set coeff attribute. 62 /// 63 /// \param[in] coeff Define a size factor applied to output. 64 void set_coeff(const float coeff); 65 66 /// \brief Method to get keep_dims attribute. 67 /// 68 /// \return a boolean value. 69 bool get_keep_dims() const; 70 71 /// \brief Method to get mode attribute. 72 /// 73 /// \return reduction mode. 74 ReduceMode get_mode() const; 75 76 /// \brief Method to get reduce_to_end attribute. 77 /// 78 /// \return a boolean value. 79 bool get_reduce_to_end() const; 80 81 /// \brief Method to get coeff attribute. 82 /// 83 /// \return a size factor applied to output. 84 float get_coeff() const; 85 }; 86 } // namespace ops 87 } // namespace mindspore 88 89 #endif // MINDSPORE_CORE_OPS_REDUCE_FUSION_H_ 90