Elffuss BraidHub

kikocis/ncnn public

d7a5f98c0f60 · 3.4 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//
5// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6// in compliance with the License. You may obtain a copy of the License at
7//
8// https://opensource.org/licenses/BSD-3-Clause
9//
10// Unless required by applicable law or agreed to in writing, software distributed
11// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12// CONDITIONS OF ANY KIND, either express or implied. See the License for the
13// specific language governing permissions and limitations under the License.
14
15#include "pass_level2.h"
16
17namespace pnnx {
18
19class torch_split : public GraphRewriterPass
20{
21public:
22 const char* match_pattern_graph() const
23 {
24 return R"PNNXIR(7767517
255 4
26pnnx.Input input_0 0 1 tensor
27pnnx.Input input_1 0 1 split_size_or_sections
28pnnx.Input input_2 0 1 dim
29aten::split op_0 3 1 tensor split_size_or_sections dim out
30pnnx.Output output 1 0 out
31)PNNXIR";
32 }
33
34 const char* type_str() const
35 {
36 return "torch.split";
37 }
38};
39
40REGISTER_GLOBAL_PNNX_GRAPH_REWRITER_PASS(torch_split, 20)
41
42class torch_split_01 : public GraphRewriterPass
43{
44public:
45 const char* match_pattern_graph() const
46 {
47 return R"PNNXIR(7767517
484 3
49pnnx.Input input_0 0 1 tensor
50pnnx.Input input_1 0 1 split_size_or_sections
51aten::split op_0 2 1 tensor split_size_or_sections out dim=%dim
52pnnx.Output output 1 0 out
53)PNNXIR";
54 }
55
56 const char* type_str() const
57 {
58 return "torch.split";
59 }
60};
61
62REGISTER_GLOBAL_PNNX_GRAPH_REWRITER_PASS(torch_split_01, 20)
63
64class torch_split_1 : public GraphRewriterPass
65{
66public:
67 const char* match_pattern_graph() const
68 {
69 return R"PNNXIR(7767517
705 4
71pnnx.Input input_0 0 1 tensor
72pnnx.Input input_1 0 1 split_size_or_sections
73pnnx.Input input_2 0 1 dim
74aten::split_with_sizes op_0 3 1 tensor split_size_or_sections dim out
75pnnx.Output output 1 0 out
76)PNNXIR";
77 }
78
79 const char* type_str() const
80 {
81 return "torch.split";
82 }
83};
84
85REGISTER_GLOBAL_PNNX_GRAPH_REWRITER_PASS(torch_split_1, 20)
86
87class torch_split_onnx : public GraphRewriterPass
88{
89public:
90 const char* match_pattern_graph() const
91 {
92 return R"PNNXIR(7767517
933 2
94pnnx.Input input 0 1 tensor
95aten::split op_0 1 1 tensor out dim=%dim indices=%split_size_or_sections
96pnnx.Output output 1 0 out
97)PNNXIR";
98 }
99
100 const char* type_str() const
101 {
102 return "torch.split";
103 }
104};
105
106REGISTER_GLOBAL_PNNX_GRAPH_REWRITER_PASS(torch_split_onnx, 20)
107
108class torch_split_onnx_1 : public torch_split_onnx
109{
110public:
111 const char* match_pattern_graph() const
112 {
113 return R"PNNXIR(7767517
1144 3
115pnnx.Input input_0 0 1 tensor
116pnnx.Input input_1 0 1 split_size_or_sections
117aten::split op_0 2 1 tensor split_size_or_sections out dim=%dim indices=None
118pnnx.Output output 1 0 out
119)PNNXIR";
120 }
121};
122
123REGISTER_GLOBAL_PNNX_GRAPH_REWRITER_PASS(torch_split_onnx_1, 20)
124
125} // namespace pnnx