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_FUSION_GROUPNORM_FUSION_H_ 18 #define MINDSPORE_CORE_OPS_FUSION_GROUPNORM_FUSION_H_ 19 #include "mindapi/base/types.h" 20 #include "ops/base_operator.h" 21 22 namespace mindspore { 23 namespace ops { 24 constexpr auto kNameGroupNormFusion = "GroupNormFusion"; 25 /// \brief GroupNormFusion defined GroupNormFusion operator prototype of lite. 26 class MIND_API GroupNormFusion : public BaseOperator { 27 public: 28 MIND_API_BASE_MEMBER(GroupNormFusion); 29 /// \brief Constructor. GroupNormFusion()30 GroupNormFusion() : BaseOperator(kNameGroupNormFusion) { InitIOName({"x"}, {"y"}); } 31 /// \brief Method to init the op's attributes. 32 /// 33 /// \param[in] num_groups Define group number. 34 /// \param[in] eps Define epsilon. 35 void Init(const int64_t num_groups, const float eps = 1e-5, bool affine = true); 36 37 /// \brief Method to set epsilon attribute. 38 /// 39 /// \param[in] epsilon Define epsilon for numerical stability. 40 void set_epsilon(const float epsilon); 41 42 /// \brief Method to set num_groups attribute. 43 /// 44 /// \param[in] num_groups Define number of groups to separate the channels into. 45 void set_num_groups(const int64_t num_groups); 46 47 /// \brief Method to set affine attribute. 48 /// 49 /// \param[in] affine Define whether this ops has learnable parameters. 50 void set_affine(const bool affine); 51 52 /// \brief Method to get epsilon attribute. 53 /// 54 /// \return epsilon attribute. 55 float get_epsilon() const; 56 57 /// \brief Method to get num_groups attribute. 58 /// 59 /// \return num_groups attribute. 60 int64_t get_num_groups() const; 61 62 /// \brief Method to get affine attribute. 63 /// 64 /// \return affine attribute. 65 bool get_affine() const; 66 }; 67 } // namespace ops 68 } // namespace mindspore 69 70 #endif // MINDSPORE_CORE_OPS_FUSION_GROUPNORM_FUSION_H_ 71