Elffuss BraidHub

kikocis/ncnn public

master · 1.6 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// 2023 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_ncnn.h"
17
18namespace pnnx {
19
20namespace ncnn {
21
22class torch_cumsum : public GraphRewriterPass
23{
24public:
25 const char* match_pattern_graph() const
26 {
27 return R"PNNXIR(7767517
283 2
29pnnx.Input input 0 1 input
30torch.cumsum op_0 1 1 input out dim=%dim
31pnnx.Output output 1 0 out
32)PNNXIR";
33 }
34
35 const char* type_str() const
36 {
37 return "CumulativeSum";
38 }
39
40 const char* name_str() const
41 {
42 return "cumsum";
43 }
44
45 void write(Operator* op, const std::map<std::string, Parameter>& captured_params) const
46 {
47 const int dim = captured_params.at("dim").i;
48
49 op->params["0"] = dim;
50 }
51};
52
53REGISTER_GLOBAL_PNNX_NCNN_GRAPH_REWRITER_PASS(torch_cumsum, 20)
54
55} // namespace ncnn
56
57} // namespace pnnx