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 #include "ops/fusion/prelu_fusion.h"
18 #include <string>
19 #include <algorithm>
20 #include <memory>
21 #include <vector>
22 #include "ops/op_utils.h"
23
24 namespace mindspore {
25 namespace ops {
Init(const bool channel_shared,const std::vector<float> & slope)26 void PReLUFusion::Init(const bool channel_shared, const std::vector<float> &slope) {
27 this->set_channel_shared(channel_shared);
28 this->set_slope(slope);
29 }
30
set_channel_shared(const bool channel_shared)31 void PReLUFusion::set_channel_shared(const bool channel_shared) {
32 (void)this->AddAttr(kChannelShared, MakeValue(channel_shared));
33 }
34
set_slope(const std::vector<float> & slope)35 void PReLUFusion::set_slope(const std::vector<float> &slope) { (void)this->AddAttr(kSlope, MakeValue(slope)); }
36
get_channel_shared() const37 bool PReLUFusion::get_channel_shared() const {
38 auto value_ptr = GetAttr(kChannelShared);
39 MS_EXCEPTION_IF_NULL(value_ptr);
40 return GetValue<bool>(value_ptr);
41 }
get_slope() const42 std::vector<float> PReLUFusion::get_slope() const {
43 auto value_ptr = GetAttr(kSlope);
44 MS_EXCEPTION_IF_NULL(value_ptr);
45 return GetValue<std::vector<float>>(value_ptr);
46 }
47 REGISTER_PRIMITIVE_C(kNamePReLUFusion, PReLUFusion);
48 } // namespace ops
49 } // namespace mindspore
50