Download tools/pnnx/src/pass_ncnn.cpp from camenduru/ncnn: direct link, hf CLI and curl.
- Browser
- Download file 4.89 kB
-
https://huggingface.co/camenduru/ncnn/resolve/main/tools/pnnx/src/pass_ncnn.cpp
- Command line
-
hf download hf://camenduru/ncnn/tools/pnnx/src/pass_ncnn.cpp
-
curl -L -o pass_ncnn.cpp https://huggingface.co/camenduru/ncnn/resolve/main/tools/pnnx/src/pass_ncnn.cpp
4.89 kB
| // Tencent is pleased to support the open source community by making ncnn available. | |
| // | |
| // Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. | |
| // | |
| // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except | |
| // in compliance with the License. You may obtain a copy of the License at | |
| // | |
| // https://opensource.org/licenses/BSD-3-Clause | |
| // | |
| // Unless required by applicable law or agreed to in writing, software distributed | |
| // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | |
| // CONDITIONS OF ANY KIND, either express or implied. See the License for the | |
| // specific language governing permissions and limitations under the License. | |
| namespace pnnx { | |
| static std::map<int, std::vector<const GraphRewriterPass*> > g_global_pnnx_ncnn_graph_rewriter_passes; | |
| NcnnGraphRewriterPassRegister::NcnnGraphRewriterPassRegister(const GraphRewriterPass* _pass, int priority) | |
| : pass(_pass) | |
| { | |
| if (g_global_pnnx_ncnn_graph_rewriter_passes.find(priority) == g_global_pnnx_ncnn_graph_rewriter_passes.end()) | |
| { | |
| g_global_pnnx_ncnn_graph_rewriter_passes[priority] = std::vector<const GraphRewriterPass*>(); | |
| } | |
| g_global_pnnx_ncnn_graph_rewriter_passes[priority].push_back(pass); | |
| } | |
| NcnnGraphRewriterPassRegister::~NcnnGraphRewriterPassRegister() | |
| { | |
| delete pass; | |
| } | |
| void pass_ncnn(Graph& g, const std::vector<std::string>& module_operators) | |
| { | |
| unroll_rnn_op(g); | |
| eliminate_maxpool_indices(g); | |
| ncnn::expand_expression(g); | |
| ncnn::chain_multi_output(g); | |
| ncnn::solve_batch_index(g); | |
| ncnn::convert_half_to_float(g); | |
| ncnn::insert_reshape_numpy_binaryop_broadcast(g); | |
| ncnn::insert_reshape_pooling(g); | |
| ncnn::insert_reshape_linear(g); | |
| ncnn::insert_reshape_global_pooling(g); | |
| ncnn::fuse_convert_shufflechannel_slice(g); | |
| ncnn::convert_torch_cat(g); | |
| ncnn::convert_torch_chunk(g); | |
| ncnn::convert_torch_stack(g); | |
| ncnn::convert_torch_split(g); | |
| ncnn::convert_torch_unbind(g); | |
| ncnn::convert_torch_tensor_split(g); | |
| ncnn::convert_torch_einsum(g); | |
| ncnn::convert_Tensor_select(g); | |
| int opindex = 0; | |
| for (auto x : g_global_pnnx_ncnn_graph_rewriter_passes) | |
| { | |
| for (auto rewriter : x.second) | |
| { | |
| pnnx_graph_rewrite(g, rewriter, opindex); | |
| } | |
| } | |
| ncnn::insert_split(g); | |
| ncnn::eliminate_noop(g); | |
| ncnn::fuse_transpose_matmul(g); | |
| ncnn::fuse_binaryop_eltwise(g); | |
| ncnn::fuse_convolution_activation(g); | |
| ncnn::fuse_convolution1d_activation(g); | |
| ncnn::fuse_convolutiondepthwise_activation(g); | |
| ncnn::fuse_convolutiondepthwise1d_activation(g); | |
| ncnn::fuse_deconvolution_activation(g); | |
| ncnn::fuse_deconvolutiondepthwise_activation(g); | |
| ncnn::fuse_innerproduct_activation(g); | |
| ncnn::eliminate_tail_reshape_permute(g); | |
| dead_code_elimination(g); | |
| canonicalize(g); | |
| ncnn::convert_custom_op(g); | |
| ncnn::convert_module_op(g, module_operators); | |
| ncnn::convert_attribute(g); | |
| ncnn::convert_input(g); | |
| ncnn::eliminate_output(g); | |
| } | |
| } // namespace pnnx | |