Repository Analysis

Tencent/ncnn

ncnn is a high-performance neural network inference framework optimized for the mobile platform

1.2 Likely human-written View on GitHub
1.2
Adjusted Score
1.2
Raw Score
100%
Time Factor
2026-05-30
Last Push
23,315
Stars
C++
Language
1,112,392
Lines of Code
3583
Files
1347
Pattern Hits
2026-05-31
Scan Date

Score History

Severity Breakdown

CRITICAL 0HIGH 5MEDIUM 1LOW 1341

Pattern Findings

1347 matches across 8 categories. Click a row to expand file-level details.

Over-Commented Block668 hits · 662 pts
SeverityFileLineSnippet
LOWbenchmark/benchncnn.cpp1// Copyright 2018 Tencent
LOWbenchmark/benchncnn_llm.cpp1// Copyright 2026 Tencent
LOWbenchmark/RankCards/Rcards.h1// Copyright 2017 Tencent
LOWbenchmark/RankCards/Rcards.h21#include <sys/stat.h>
LOWbenchmark/RankCards/main.cpp1// Copyright 2017 Tencent
LOWtools/modelwriter.h1// Copyright 2019 Tencent
LOWtools/modelwriter.h21#include "layer/batchnorm.h"
LOWtools/modelwriter.h41#include "layer/deconvolutiondepthwise3d.h"
LOWtools/modelwriter.h61#include "layer/hardswish.h"
LOWtools/modelwriter.h81#include "layer/power.h"
LOWtools/modelwriter.h101#include "layer/softmax.h"
LOWtools/ncnnoptimize.cpp1// Copyright 2019 Tencent
LOWtools/quantize/ncnn2int8.cpp1// Copyright 2019 BUG1989
LOWtools/quantize/npy.hpp21*/
LOWtools/quantize/imreadwrite.cpp1// Copyright 2021 Tencent
LOWtools/quantize/imreadwrite.cpp81
LOWtools/quantize/ncnn2table.cpp1// Copyright 2019 BUG1989 (https://github.com/BUG1989/) Long-term support.
LOWtools/quantize/ncnn2table.cpp21#include "imreadwrite.h"
LOWtools/onnx/onnx2ncnn.cpp1// Copyright 2017 Tencent
LOWtools/mlir/tf_types.h21#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
LOWtools/mlir/tf_types.h341// - the types are statically equal
LOWtools/mlir/tf_types.h361// If `ty` is a tensor type and its element type has subtypes, then returns a
LOWtools/mlir/tf_dialect.h1// Copyright 2020 Tencent
LOWtools/mlir/tf_dialect.cpp1// Copyright 2020 Tencent
LOWtools/mlir/tf_dialect.cpp21#include <mlir/IR/Value.h>
LOWtools/mlir/tf_dialect.cpp61#define GET_OP_LIST
LOWtools/mlir/mlir2ncnn.cpp1// Copyright 2020 Tencent
LOWtools/mlir/tf_attributes.h61
LOWtools/caffe/caffe2ncnn.cpp1// Copyright 2017 Tencent
LOWtools/pnnx/src/utils.cpp1// Copyright 2021 Tencent
LOWtools/pnnx/src/pass_level3.cpp1// Copyright 2021 Tencent
LOWtools/pnnx/src/ir.cpp1// Copyright 2021 Tencent
LOWtools/pnnx/src/pass_level2.cpp1// Copyright 2021 Tencent
LOWtools/pnnx/src/ir.h1// Copyright 2021 Tencent
LOWtools/pnnx/src/pass_level1.cpp381 // auto fun_type = function_constant->output()->type()->expect<torch::jit::FunctionType>();
LOWtools/pnnx/src/storezip.cpp1// Copyright 2021 Tencent
LOWtools/pnnx/src/pass_level5.cpp1// Copyright 2021 Tencent
LOWtools/pnnx/src/pass_level5.cpp21#include "pass_level5/eval_expression.h"
LOWtools/pnnx/src/pass_level5.cpp41#include "pass_level5/fuse_silu.h"
LOWtools/pnnx/src/load_tnn.cpp1// Copyright 2025 Tencent
LOWtools/pnnx/src/load_onnx.cpp1// Copyright 2024 Tencent
LOWtools/pnnx/src/model_stat.cpp1// Copyright 2026 Tencent
LOWtools/pnnx/src/load_torchscript.cpp1// Copyright 2024 Tencent
LOWtools/pnnx/src/pass_ncnn.cpp1// Copyright 2021 Tencent
LOWtools/pnnx/src/pass_ncnn.cpp21#include "pass_ncnn/convert_Tensor_slice.h"
LOWtools/pnnx/src/pass_ncnn.cpp41#include "pass_ncnn/fuse_transpose_matmul.h"
LOWtools/pnnx/src/save_ncnn.cpp301 // if (oprand->params.find("__batch_index") == oprand->params.end())
LOWtools/pnnx/src/main.cpp1// Copyright 2021 Tencent
LOWtools/pnnx/src/main.cpp21#include "pass_level5.h"
LOWtools/pnnx/src/pass_level1/nn_quantized_Linear.cpp41 // for (const auto& n : graph->nodes())
LOWtools/pnnx/src/pass_level1/nn_quantized_Linear.cpp101 graph.dump();
LOWtools/pnnx/src/pass_level1/nn_quantized_DeQuantize.cpp21 // void write(Operator* op, const TorchGraphProxy& graph, const TorchModuleProxy& mod) const
LOWtools/pnnx/src/pass_level1/nn_quantized_Conv2d.cpp41 // if (n->kind() == c10::prim::GetAttr && n->s(torch::jit::attr::name) == "_packed_params")
LOWtools/pnnx/src/pass_level1/nn_quantized_Conv2d.cpp121
LOWtools/pnnx/src/pass_level0/shape_inference.cpp1// Copyright 2021 Tencent
LOWtools/pnnx/src/pass_onnx/shape_inference.cpp481 // ort_status = ort_api->SetIntraOpNumThreads(ort_session_opt, 4);
LOWtools/pnnx/src/pass_onnx/canonicalize.cpp321 node->set_output(k, function_input_output_remap[output]);
LOW…nx/src/pass_ncnn/fuse_convert_shufflechannel_slice.cpp1// Copyright 2022 Tencent
LOWtools/pnnx/src/pass_level2/functionize.cpp21
LOWtools/pnnx/src/pass_level5/eval_expression.cpp1// Copyright 2021 Tencent
608 more matches not shown…
Unused Imports641 hits · 641 pts
SeverityFileLineSnippet
LOWtools/pnnx/python/setup.py5
LOWtools/pnnx/python/setup.py10
LOWtools/pnnx/python/tests/test_naiveinput_export.py4
LOWtools/pnnx/python/tests/test_naiveinput_export.py10
LOWtools/pnnx/python/tests/test_naiveinput_convert.py4
LOWtools/pnnx/python/tests/test_naiveinput_convert.py10
LOWtools/pnnx/python/tests/test_convert.py4
LOWtools/pnnx/python/tests/test_convert.py10
LOWtools/pnnx/python/tests/test_dynamicinput_export.py4
LOWtools/pnnx/python/tests/test_dynamicinput_export.py10
LOWtools/pnnx/python/tests/test_dynamicinput_convert.py4
LOWtools/pnnx/python/tests/test_dynamicinput_convert.py10
LOWtools/pnnx/python/tests/test_export.py4
LOWtools/pnnx/python/tests/test_export.py10
LOWtools/pnnx/python/pnnx/__init__.py17
LOWtools/pnnx/python/pnnx/__init__.py18
LOWtools/pnnx/python/pnnx/utils/__init__.py4
LOWtools/pnnx/python/pnnx/utils/__init__.py5
LOWtools/pnnx/python/pnnx/utils/export.py5
LOWtools/pnnx/tests/test_nn_LSTM.py6
LOWtools/pnnx/tests/test_torch_matmul.py6
LOWtools/pnnx/tests/test_transformers_electra_attention.py6
LOWtools/pnnx/tests/test_nn_PixelShuffle.py6
LOWtools/pnnx/tests/test_torch_gather.py6
LOWtools/pnnx/tests/test_torch_zeros_like.py6
LOWtools/pnnx/tests/test_nn_LPPool1d.py6
LOWtools/pnnx/tests/test_pnnx_fuse_multiheadattention.py10
LOWtools/pnnx/tests/test_pnnx_fuse_multiheadattention.py10
LOWtools/pnnx/tests/test_torch_imag.py6
LOWtools/pnnx/tests/test_torch_index_select.py6
LOWtools/pnnx/tests/test_nn_Softmax.py6
LOWtools/pnnx/tests/test_torch_rsqrt.py6
LOWtools/pnnx/tests/test_nn_ConvTranspose1d.py6
LOWtools/pnnx/tests/test_transformers_albert_attention.py6
LOWtools/pnnx/tests/test_torch_min.py6
LOWtools/pnnx/tests/test_torch_fft_ihfft.py6
LOWtools/pnnx/tests/test_nn_UpsamplingBilinear2d.py6
LOWtools/pnnx/tests/test_Tensor_new_empty.py6
LOWtools/pnnx/tests/test_transformers_qwen3_attention.py6
LOWtools/pnnx/tests/test_pnnx_eliminate_noop_math.py6
LOWtools/pnnx/tests/test_nn_LPPool2d.py6
LOWtools/pnnx/tests/test_nn_ConvTranspose3d.py6
LOWtools/pnnx/tests/test_torch_stft.py6
LOWtools/pnnx/tests/test_nn_LocalResponseNorm.py6
LOWtools/pnnx/tests/test_torch_full.py6
LOWtools/pnnx/tests/test_torch_bitwise_right_shift.py6
LOWtools/pnnx/tests/test_nn_Hardsigmoid.py6
LOWtools/pnnx/tests/test_Tensor_to.py6
LOWtools/pnnx/tests/test_Tensor_reshape.py6
LOWtools/pnnx/tests/test_torch_mean.py6
LOWtools/pnnx/tests/test_nn_ConvTranspose2d.py6
LOWtools/pnnx/tests/test_torch_istft.py6
LOWtools/pnnx/tests/test_Tensor_new_full.py6
LOWtools/pnnx/tests/test_Tensor_unflatten.py6
LOWtools/pnnx/tests/test_torch_zeros.py6
LOWtools/pnnx/tests/test_Tensor_expand.py6
LOWtools/pnnx/tests/test_torch_fft_ifftn.py6
LOW…ols/pnnx/tests/test_transformers_flaubert_attention.py6
LOWtools/pnnx/tests/test_nn_AlphaDropout.py6
LOWtools/pnnx/tests/test_torch_tensor_split.py6
581 more matches not shown…
Cross-File Repetition5 hits · 25 pts
SeverityFileLineSnippet
HIGHpython/ncnn/model_zoo/peleenetssd.py0#method 2, use ncnn.mat->numpy.array to get the result, no memory copy too out = np.array(mat_out) for i in range(len(ou
HIGHpython/ncnn/model_zoo/yolov2.py0#method 2, use ncnn.mat->numpy.array to get the result, no memory copy too out = np.array(mat_out) for i in range(len(ou
HIGHpython/ncnn/model_zoo/squeezenetssd.py0#method 2, use ncnn.mat->numpy.array to get the result, no memory copy too out = np.array(mat_out) for i in range(len(ou
HIGHpython/ncnn/model_zoo/mobilenetv2ssdlite.py0#method 2, use ncnn.mat->numpy.array to get the result, no memory copy too out = np.array(mat_out) for i in range(len(ou
HIGHpython/ncnn/model_zoo/mobilenetssd.py0#method 2, use ncnn.mat->numpy.array to get the result, no memory copy too out = np.array(mat_out) for i in range(len(ou
Deep Nesting12 hits · 12 pts
SeverityFileLineSnippet
LOWtools/pnnx/python/pnnx/utils/convert.py10
LOWpython/examples/peleenetssd.py10
LOWpython/ncnn/utils/download.py38
LOWpython/ncnn/model_zoo/yolov7.py23
LOWpython/ncnn/model_zoo/yolov7.py59
LOWpython/ncnn/model_zoo/yolov7.py191
LOWpython/ncnn/model_zoo/retinaface.py190
LOWpython/ncnn/model_zoo/yolact.py186
LOWpython/ncnn/model_zoo/yolov8.py214
LOWpython/ncnn/model_zoo/simplepose.py38
LOWpython/ncnn/model_zoo/model_store.py92
LOWpython/ncnn/model_zoo/yolov5.py263
Verbosity Indicators6 hits · 11 pts
SeverityFileLineSnippet
LOWsrc/layer/loongarch/loongarch_usability.h886 // Step 1: 32-bit word interleave
LOWsrc/layer/loongarch/loongarch_usability.h900 // Step 2: 64-bit doubleword interleave
LOWsrc/layer/loongarch/loongarch_usability.h914 // Step 3: cross-lane 128-bit permute
LOWsrc/layer/loongarch/loongarch_usability.h966 // Step 1: lane-wise word interleave
LOWsrc/layer/loongarch/loongarch_usability.h972 // Step 2: lane-wise doubleword interleave
LOWsrc/layer/loongarch/loongarch_usability.h978 // Step 3: cross-lane 128-bit permute
Hyper-Verbose Identifiers11 hits · 11 pts
SeverityFileLineSnippet
LOWtools/pnnx/README.md345 def load_pnnx_bin_as_parameter(self, archive, key, shape, dtype):
LOWtools/pnnx/tests/test_pnnx_fuse_multiheadattention.py348 def reshape_heads_to_batch_dim(self, tensor, merge_head_and_batch=True):
LOWtools/pnnx/tests/test_pnnx_fuse_multiheadattention.py357 def reshape_batch_dim_to_heads(self, tensor, unmerge_head_and_batch=True):
LOWtools/pnnx/src/ir.cpp1773 fprintf(pyfp, " def load_pnnx_bin_as_parameter(self, archive, key, shape, dtype, requires_grad=True):\n");
LOWpython/tests/test_vulkan_allocator.py63def test_vk_staging_allocator():
LOWpython/tests/test_vulkan_allocator.py90def test_vk_weight_staging_allocator():
LOWpython/tests/test_allocator.py19def test_unlocked_pool_allocator():
LOWpython/tests/test_mat.py724def test_from_pixels_roi_resize():
LOWpython/tests/test_mat.py748def test_substract_mean_normalize():
LOWpython/examples/peleenetssd.py10def draw_detection_objects_seg(image, class_names, objects, mat_map):
LOWdocs/developer-guide/kvcache.md96def add_kv_cache_to_ncnn_param(filename):
Redundant / Tautological Comments2 hits · 3 pts
SeverityFileLineSnippet
LOWsetup.py161 # Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level
LOWtools/pnnx/python/setup.py105 # Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level
Excessive Try-Catch Wrapping2 hits · 3 pts
SeverityFileLineSnippet
LOWtools/pnnx/python/pnnx/__init__.py23except Exception:
MEDIUMdocs/developer-guide/kvcache.md105 print(f"Error: The file '{filename}' was not found.")