• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2022 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 <memory>
18 #include <vector>
19 #include "backend/common/graph_kernel/expanders/op_desc_registry.h"
20 
21 namespace mindspore::graphkernel::expanders {
22 class ReLU : public OpDesc {
23  public:
24   ReLU() = default;
25   ~ReLU() = default;
26 
Exec(const inner::GraphBuilder & gb,const NodePtrList & inputs)27   static NodePtr Exec(const inner::GraphBuilder &gb, const NodePtrList &inputs) {
28     auto const_zero = gb.Tensor(0.0, inputs[0]->type);
29     auto result = gb.Emit("Maximum", {inputs[0], const_zero});
30     return result;
31   }
32 
33  protected:
Expand(const NodePtrList & inputs)34   NodePtrList Expand(const NodePtrList &inputs) override { return {Exec(gb, inputs)}; }
35 };
36 EXPANDER_OP_DESC_REGISTER("ReLU", ReLU);
37 
ReluExpand(const inner::GraphBuilder & gb,const NodePtrList & inputs)38 NodePtr ReluExpand(const inner::GraphBuilder &gb, const NodePtrList &inputs) { return ReLU::Exec(gb, inputs); }
39 }  // namespace mindspore::graphkernel::expanders
40