Elffuss BraidHub

kikocis/ncnn public

master · 1.3 KiBRawPermalink
1// Tencent is pleased to support the open source community by making ncnn available.
2//
3// Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
4// 2022 Xiaomi Corp. (author: Fangjun Kuang)
5//
6// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
7// in compliance with the License. You may obtain a copy of the License at
8//
9// https://opensource.org/licenses/BSD-3-Clause
10//
11// Unless required by applicable law or agreed to in writing, software distributed
12// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13// CONDITIONS OF ANY KIND, either express or implied. See the License for the
14// specific language governing permissions and limitations under the License.
15
16#include "pass_level1.h"
17
18#include "../utils.h"
19
20namespace pnnx {
21
22class GLU : public FuseModulePass
23{
24public:
25 const char* match_type_str() const
26 {
27 return "__torch__.torch.nn.modules.activation.GLU";
28 }
29
30 const char* type_str() const
31 {
32 return "nn.GLU";
33 }
34
35 void write(Operator* op, const std::shared_ptr<torch::jit::Graph>& graph) const
36 {
37 const torch::jit::Node* glu = find_node_by_kind(graph, "aten::glu");
38
39 op->params["dim"] = glu->namedInput("dim");
40 }
41};
42
43REGISTER_GLOBAL_PNNX_FUSE_MODULE_PASS(GLU)
44
45} // namespace pnnx