├── fpn.pdf ├── model ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── _utils.cpython-37.pyc │ ├── anchor_utils.cpython-37.pyc │ ├── backbone_utils.cpython-37.pyc │ ├── faster_rcnn.cpython-37.pyc │ ├── feature_pyramid_network.cpython-37.pyc │ ├── generalized_rcnn.cpython-37.pyc │ ├── image_list.cpython-37.pyc │ ├── roi_heads.cpython-37.pyc │ ├── rpn.cpython-37.pyc │ └── transform.cpython-37.pyc ├── _utils.py ├── anchor_utils.py ├── backbone_utils.py ├── faster_rcnn.py ├── feature_pyramid_network.py ├── generalized_rcnn.py ├── image_list.py ├── ops │ ├── __pycache__ │ │ └── poolers.cpython-37.pyc │ └── poolers.py ├── roi_heads.py ├── rpn.py └── transform.py ├── readme.assets ├── image-20211216112059762.png ├── image-20211216112509835.png └── image-20211216112526108.png ├── readme.md ├── tensorrt_code ├── .gitignore ├── CMakeLists.txt ├── Makefile ├── README.md ├── README.zh-cn.md ├── TensorRT.sln ├── TensorRT.vcxproj ├── TensorRT.vcxproj.filters ├── TensorRT.vcxproj.user ├── YoloTRT_speed.xlsx ├── dll_export.def ├── onnx │ ├── make_pb.sh │ ├── onnx-ml.proto │ └── onnx-operators-ml.proto ├── onnx_parser │ ├── onnx_parser_7.x │ │ ├── ImporterContext.hpp │ │ ├── LoopHelpers.cpp │ │ ├── LoopHelpers.hpp │ │ ├── ModelImporter.cpp │ │ ├── ModelImporter.hpp │ │ ├── NvOnnxParser.cpp │ │ ├── NvOnnxParser.h │ │ ├── OnnxAttrs.cpp │ │ ├── OnnxAttrs.hpp │ │ ├── RNNHelpers.cpp │ │ ├── RNNHelpers.hpp │ │ ├── ShapeTensor.cpp │ │ ├── ShapeTensor.hpp │ │ ├── ShapedWeights.cpp │ │ ├── ShapedWeights.hpp │ │ ├── Status.hpp │ │ ├── TensorOrWeights.hpp │ │ ├── builtin_op_importers.cpp │ │ ├── builtin_op_importers.hpp │ │ ├── common.hpp │ │ ├── onnx2trt.hpp │ │ ├── onnx2trt_common.hpp │ │ ├── onnx2trt_runtime.hpp │ │ ├── onnx2trt_utils.cpp │ │ ├── onnx2trt_utils.hpp │ │ ├── onnx_utils.hpp │ │ ├── toposort.hpp │ │ ├── trt_utils.hpp │ │ └── utils.hpp │ ├── onnx_parser_8.x │ │ ├── ImporterContext.hpp │ │ ├── LoopHelpers.cpp │ │ ├── LoopHelpers.hpp │ │ ├── ModelImporter.cpp │ │ ├── ModelImporter.hpp │ │ ├── NvOnnxParser.cpp │ │ ├── NvOnnxParser.h │ │ ├── OnnxAttrs.cpp │ │ ├── OnnxAttrs.hpp │ │ ├── RNNHelpers.cpp │ │ ├── RNNHelpers.hpp │ │ ├── ShapeTensor.cpp │ │ ├── ShapeTensor.hpp │ │ ├── ShapedWeights.cpp │ │ ├── ShapedWeights.hpp │ │ ├── Status.hpp │ │ ├── TensorOrWeights.hpp │ │ ├── builtin_op_importers.cpp │ │ ├── builtin_op_importers.hpp │ │ ├── onnx2trt.hpp │ │ ├── onnx2trt_common.hpp │ │ ├── onnx2trt_runtime.hpp │ │ ├── onnx2trt_utils.cpp │ │ ├── onnx2trt_utils.hpp │ │ ├── onnxErrorRecorder.cpp │ │ ├── onnxErrorRecorder.hpp │ │ ├── onnx_utils.hpp │ │ ├── readme.md │ │ ├── toposort.hpp │ │ ├── trt_utils.hpp │ │ └── utils.hpp │ ├── readme.md │ ├── use_tensorrt_7.x.sh │ └── use_tensorrt_8.x.sh ├── python │ ├── copy_dll_to_trtpy.bat │ ├── setup.py │ ├── test_centernet.py │ ├── test_retinaface.py │ ├── test_scrfd.py │ ├── test_torch.py │ ├── test_yolov5.py │ ├── test_yolox.py │ └── trtpy │ │ └── __init__.py ├── src │ ├── application │ │ ├── app_alphapose.cpp │ │ ├── app_alphapose │ │ │ ├── alpha_pose.cpp │ │ │ └── alpha_pose.hpp │ │ ├── app_arcface.cpp │ │ ├── app_arcface │ │ │ ├── arcface.cpp │ │ │ └── arcface.hpp │ │ ├── app_cat.cpp │ │ ├── app_cat │ │ │ ├── yolo.cpp │ │ │ ├── yolo.hpp │ │ │ └── yolo_decode.cu │ │ ├── app_centernet.cpp │ │ ├── app_centernet │ │ │ ├── centernet.cpp │ │ │ ├── centernet.hpp │ │ │ └── centernet_decode.cu │ │ ├── app_dbface.cpp │ │ ├── app_dbface │ │ │ ├── dbface.cpp │ │ │ ├── dbface.hpp │ │ │ └── dbface_decode.cu │ │ ├── app_fall_gcn │ │ │ ├── fall_gcn.cpp │ │ │ └── fall_gcn.hpp │ │ ├── app_fall_recognize.cpp │ │ ├── app_fasterrcnn.cpp │ │ ├── app_fasterrcnn │ │ │ ├── fasterrcnn.cpp │ │ │ ├── fasterrcnn.hpp │ │ │ ├── fasterrcnn_decode.cu │ │ │ └── roialign.cu │ │ ├── app_high_performance.cpp │ │ ├── app_high_performance │ │ │ ├── alpha_pose_high_perf.cpp │ │ │ ├── alpha_pose_high_perf.hpp │ │ │ ├── high_performance.cpp │ │ │ ├── high_performance.hpp │ │ │ ├── yolo_high_perf.cpp │ │ │ └── yolo_high_perf.hpp │ │ ├── app_lesson.cpp │ │ ├── app_plugin.cpp │ │ ├── app_python │ │ │ └── interface.cpp │ │ ├── app_retinaface.cpp │ │ ├── app_retinaface │ │ │ ├── retinaface.cpp │ │ │ ├── retinaface.hpp │ │ │ └── retinaface_decode.cu │ │ ├── app_scrfd.cpp │ │ ├── app_scrfd │ │ │ ├── scrfd.cpp │ │ │ ├── scrfd.hpp │ │ │ └── scrfd_decode.cu │ │ ├── app_shufflenet │ │ │ ├── shufflenetv2.cpp │ │ │ └── shufflenetv2.hpp │ │ ├── app_shufflenetv2.cpp │ │ ├── app_yolo.cpp │ │ ├── app_yolo │ │ │ ├── yolo.cpp │ │ │ ├── yolo.hpp │ │ │ └── yolo_decode.cu │ │ ├── app_yolo_fast.cpp │ │ ├── app_yolo_fast │ │ │ ├── yolo_fast.cpp │ │ │ ├── yolo_fast.hpp │ │ │ ├── yolov5_decode.cu │ │ │ └── yolox_decode.cu │ │ ├── common │ │ │ ├── face_detector.hpp │ │ │ └── object_detector.hpp │ │ └── tools │ │ │ ├── Eigen │ │ │ ├── CMakeLists.txt │ │ │ ├── Cholesky │ │ │ ├── CholmodSupport │ │ │ ├── Core │ │ │ ├── Dense │ │ │ ├── Eigen │ │ │ ├── Eigenvalues │ │ │ ├── Geometry │ │ │ ├── Householder │ │ │ ├── IterativeLinearSolvers │ │ │ ├── Jacobi │ │ │ ├── LU │ │ │ ├── MetisSupport │ │ │ ├── OrderingMethods │ │ │ ├── PaStiXSupport │ │ │ ├── PardisoSupport │ │ │ ├── QR │ │ │ ├── QtAlignedMalloc │ │ │ ├── SPQRSupport │ │ │ ├── SVD │ │ │ ├── Sparse │ │ │ ├── SparseCholesky │ │ │ ├── SparseCore │ │ │ ├── SparseLU │ │ │ ├── SparseQR │ │ │ ├── StdDeque │ │ │ ├── StdList │ │ │ ├── StdVector │ │ │ ├── SuperLUSupport │ │ │ ├── UmfPackSupport │ │ │ └── src │ │ │ │ ├── Cholesky │ │ │ │ ├── LDLT.h │ │ │ │ ├── LLT.h │ │ │ │ └── LLT_LAPACKE.h │ │ │ │ ├── CholmodSupport │ │ │ │ └── CholmodSupport.h │ │ │ │ ├── Core │ │ │ │ ├── Array.h │ │ │ │ ├── ArrayBase.h │ │ │ │ ├── ArrayWrapper.h │ │ │ │ ├── Assign.h │ │ │ │ ├── AssignEvaluator.h │ │ │ │ ├── Assign_MKL.h │ │ │ │ ├── BandMatrix.h │ │ │ │ ├── Block.h │ │ │ │ ├── BooleanRedux.h │ │ │ │ ├── CommaInitializer.h │ │ │ │ ├── ConditionEstimator.h │ │ │ │ ├── CoreEvaluators.h │ │ │ │ ├── CoreIterators.h │ │ │ │ ├── CwiseBinaryOp.h │ │ │ │ ├── CwiseNullaryOp.h │ │ │ │ ├── CwiseTernaryOp.h │ │ │ │ ├── CwiseUnaryOp.h │ │ │ │ ├── CwiseUnaryView.h │ │ │ │ ├── DenseBase.h │ │ │ │ ├── DenseCoeffsBase.h │ │ │ │ ├── DenseStorage.h │ │ │ │ ├── Diagonal.h │ │ │ │ ├── DiagonalMatrix.h │ │ │ │ ├── DiagonalProduct.h │ │ │ │ ├── Dot.h │ │ │ │ ├── EigenBase.h │ │ │ │ ├── ForceAlignedAccess.h │ │ │ │ ├── Fuzzy.h │ │ │ │ ├── GeneralProduct.h │ │ │ │ ├── GenericPacketMath.h │ │ │ │ ├── GlobalFunctions.h │ │ │ │ ├── IO.h │ │ │ │ ├── Inverse.h │ │ │ │ ├── Map.h │ │ │ │ ├── MapBase.h │ │ │ │ ├── MathFunctions.h │ │ │ │ ├── MathFunctionsImpl.h │ │ │ │ ├── Matrix.h │ │ │ │ ├── MatrixBase.h │ │ │ │ ├── NestByValue.h │ │ │ │ ├── NoAlias.h │ │ │ │ ├── NumTraits.h │ │ │ │ ├── PermutationMatrix.h │ │ │ │ ├── PlainObjectBase.h │ │ │ │ ├── Product.h │ │ │ │ ├── ProductEvaluators.h │ │ │ │ ├── Random.h │ │ │ │ ├── Redux.h │ │ │ │ ├── Ref.h │ │ │ │ ├── Replicate.h │ │ │ │ ├── ReturnByValue.h │ │ │ │ ├── Reverse.h │ │ │ │ ├── Select.h │ │ │ │ ├── SelfAdjointView.h │ │ │ │ ├── SelfCwiseBinaryOp.h │ │ │ │ ├── Solve.h │ │ │ │ ├── SolveTriangular.h │ │ │ │ ├── SolverBase.h │ │ │ │ ├── StableNorm.h │ │ │ │ ├── Stride.h │ │ │ │ ├── Swap.h │ │ │ │ ├── Transpose.h │ │ │ │ ├── Transpositions.h │ │ │ │ ├── TriangularMatrix.h │ │ │ │ ├── VectorBlock.h │ │ │ │ ├── VectorwiseOp.h │ │ │ │ ├── Visitor.h │ │ │ │ ├── arch │ │ │ │ │ ├── AVX │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ │ └── TypeCasting.h │ │ │ │ │ ├── AVX512 │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ └── PacketMath.h │ │ │ │ │ ├── AltiVec │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ └── PacketMath.h │ │ │ │ │ ├── CUDA │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ ├── Half.h │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ │ ├── PacketMathHalf.h │ │ │ │ │ │ └── TypeCasting.h │ │ │ │ │ ├── Default │ │ │ │ │ │ └── Settings.h │ │ │ │ │ ├── NEON │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ └── PacketMath.h │ │ │ │ │ ├── SSE │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ │ └── TypeCasting.h │ │ │ │ │ └── ZVector │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ └── PacketMath.h │ │ │ │ ├── functors │ │ │ │ │ ├── AssignmentFunctors.h │ │ │ │ │ ├── BinaryFunctors.h │ │ │ │ │ ├── NullaryFunctors.h │ │ │ │ │ ├── StlFunctors.h │ │ │ │ │ ├── TernaryFunctors.h │ │ │ │ │ └── UnaryFunctors.h │ │ │ │ ├── products │ │ │ │ │ ├── GeneralBlockPanelKernel.h │ │ │ │ │ ├── GeneralMatrixMatrix.h │ │ │ │ │ ├── GeneralMatrixMatrixTriangular.h │ │ │ │ │ ├── GeneralMatrixMatrixTriangular_BLAS.h │ │ │ │ │ ├── GeneralMatrixMatrix_BLAS.h │ │ │ │ │ ├── GeneralMatrixVector.h │ │ │ │ │ ├── GeneralMatrixVector_BLAS.h │ │ │ │ │ ├── Parallelizer.h │ │ │ │ │ ├── SelfadjointMatrixMatrix.h │ │ │ │ │ ├── SelfadjointMatrixMatrix_BLAS.h │ │ │ │ │ ├── SelfadjointMatrixVector.h │ │ │ │ │ ├── SelfadjointMatrixVector_BLAS.h │ │ │ │ │ ├── SelfadjointProduct.h │ │ │ │ │ ├── SelfadjointRank2Update.h │ │ │ │ │ ├── TriangularMatrixMatrix.h │ │ │ │ │ ├── TriangularMatrixMatrix_BLAS.h │ │ │ │ │ ├── TriangularMatrixVector.h │ │ │ │ │ ├── TriangularMatrixVector_BLAS.h │ │ │ │ │ ├── TriangularSolverMatrix.h │ │ │ │ │ ├── TriangularSolverMatrix_BLAS.h │ │ │ │ │ └── TriangularSolverVector.h │ │ │ │ └── util │ │ │ │ │ ├── BlasUtil.h │ │ │ │ │ ├── Constants.h │ │ │ │ │ ├── DisableStupidWarnings.h │ │ │ │ │ ├── ForwardDeclarations.h │ │ │ │ │ ├── MKL_support.h │ │ │ │ │ ├── Macros.h │ │ │ │ │ ├── Memory.h │ │ │ │ │ ├── Meta.h │ │ │ │ │ ├── NonMPL2.h │ │ │ │ │ ├── ReenableStupidWarnings.h │ │ │ │ │ ├── StaticAssert.h │ │ │ │ │ └── XprHelper.h │ │ │ │ ├── Eigenvalues │ │ │ │ ├── ComplexEigenSolver.h │ │ │ │ ├── ComplexSchur.h │ │ │ │ ├── ComplexSchur_LAPACKE.h │ │ │ │ ├── EigenSolver.h │ │ │ │ ├── GeneralizedEigenSolver.h │ │ │ │ ├── GeneralizedSelfAdjointEigenSolver.h │ │ │ │ ├── HessenbergDecomposition.h │ │ │ │ ├── MatrixBaseEigenvalues.h │ │ │ │ ├── RealQZ.h │ │ │ │ ├── RealSchur.h │ │ │ │ ├── RealSchur_LAPACKE.h │ │ │ │ ├── SelfAdjointEigenSolver.h │ │ │ │ ├── SelfAdjointEigenSolver_LAPACKE.h │ │ │ │ └── Tridiagonalization.h │ │ │ │ ├── Geometry │ │ │ │ ├── AlignedBox.h │ │ │ │ ├── AngleAxis.h │ │ │ │ ├── EulerAngles.h │ │ │ │ ├── Homogeneous.h │ │ │ │ ├── Hyperplane.h │ │ │ │ ├── OrthoMethods.h │ │ │ │ ├── ParametrizedLine.h │ │ │ │ ├── Quaternion.h │ │ │ │ ├── Rotation2D.h │ │ │ │ ├── RotationBase.h │ │ │ │ ├── Scaling.h │ │ │ │ ├── Transform.h │ │ │ │ ├── Translation.h │ │ │ │ ├── Umeyama.h │ │ │ │ └── arch │ │ │ │ │ └── Geometry_SSE.h │ │ │ │ ├── Householder │ │ │ │ ├── BlockHouseholder.h │ │ │ │ ├── Householder.h │ │ │ │ └── HouseholderSequence.h │ │ │ │ ├── IterativeLinearSolvers │ │ │ │ ├── BasicPreconditioners.h │ │ │ │ ├── BiCGSTAB.h │ │ │ │ ├── ConjugateGradient.h │ │ │ │ ├── IncompleteCholesky.h │ │ │ │ ├── IncompleteLUT.h │ │ │ │ ├── IterativeSolverBase.h │ │ │ │ ├── LeastSquareConjugateGradient.h │ │ │ │ └── SolveWithGuess.h │ │ │ │ ├── Jacobi │ │ │ │ └── Jacobi.h │ │ │ │ ├── LU │ │ │ │ ├── Determinant.h │ │ │ │ ├── FullPivLU.h │ │ │ │ ├── InverseImpl.h │ │ │ │ ├── PartialPivLU.h │ │ │ │ ├── PartialPivLU_LAPACKE.h │ │ │ │ └── arch │ │ │ │ │ └── Inverse_SSE.h │ │ │ │ ├── MetisSupport │ │ │ │ └── MetisSupport.h │ │ │ │ ├── OrderingMethods │ │ │ │ ├── Amd.h │ │ │ │ ├── Eigen_Colamd.h │ │ │ │ └── Ordering.h │ │ │ │ ├── PaStiXSupport │ │ │ │ └── PaStiXSupport.h │ │ │ │ ├── PardisoSupport │ │ │ │ └── PardisoSupport.h │ │ │ │ ├── QR │ │ │ │ ├── ColPivHouseholderQR.h │ │ │ │ ├── ColPivHouseholderQR_LAPACKE.h │ │ │ │ ├── CompleteOrthogonalDecomposition.h │ │ │ │ ├── FullPivHouseholderQR.h │ │ │ │ ├── HouseholderQR.h │ │ │ │ └── HouseholderQR_LAPACKE.h │ │ │ │ ├── SPQRSupport │ │ │ │ └── SuiteSparseQRSupport.h │ │ │ │ ├── SVD │ │ │ │ ├── BDCSVD.h │ │ │ │ ├── JacobiSVD.h │ │ │ │ ├── JacobiSVD_LAPACKE.h │ │ │ │ ├── SVDBase.h │ │ │ │ └── UpperBidiagonalization.h │ │ │ │ ├── SparseCholesky │ │ │ │ ├── SimplicialCholesky.h │ │ │ │ └── SimplicialCholesky_impl.h │ │ │ │ ├── SparseCore │ │ │ │ ├── AmbiVector.h │ │ │ │ ├── CompressedStorage.h │ │ │ │ ├── ConservativeSparseSparseProduct.h │ │ │ │ ├── MappedSparseMatrix.h │ │ │ │ ├── SparseAssign.h │ │ │ │ ├── SparseBlock.h │ │ │ │ ├── SparseColEtree.h │ │ │ │ ├── SparseCompressedBase.h │ │ │ │ ├── SparseCwiseBinaryOp.h │ │ │ │ ├── SparseCwiseUnaryOp.h │ │ │ │ ├── SparseDenseProduct.h │ │ │ │ ├── SparseDiagonalProduct.h │ │ │ │ ├── SparseDot.h │ │ │ │ ├── SparseFuzzy.h │ │ │ │ ├── SparseMap.h │ │ │ │ ├── SparseMatrix.h │ │ │ │ ├── SparseMatrixBase.h │ │ │ │ ├── SparsePermutation.h │ │ │ │ ├── SparseProduct.h │ │ │ │ ├── SparseRedux.h │ │ │ │ ├── SparseRef.h │ │ │ │ ├── SparseSelfAdjointView.h │ │ │ │ ├── SparseSolverBase.h │ │ │ │ ├── SparseSparseProductWithPruning.h │ │ │ │ ├── SparseTranspose.h │ │ │ │ ├── SparseTriangularView.h │ │ │ │ ├── SparseUtil.h │ │ │ │ ├── SparseVector.h │ │ │ │ ├── SparseView.h │ │ │ │ └── TriangularSolver.h │ │ │ │ ├── SparseLU │ │ │ │ ├── SparseLU.h │ │ │ │ ├── SparseLUImpl.h │ │ │ │ ├── SparseLU_Memory.h │ │ │ │ ├── SparseLU_Structs.h │ │ │ │ ├── SparseLU_SupernodalMatrix.h │ │ │ │ ├── SparseLU_Utils.h │ │ │ │ ├── SparseLU_column_bmod.h │ │ │ │ ├── SparseLU_column_dfs.h │ │ │ │ ├── SparseLU_copy_to_ucol.h │ │ │ │ ├── SparseLU_gemm_kernel.h │ │ │ │ ├── SparseLU_heap_relax_snode.h │ │ │ │ ├── SparseLU_kernel_bmod.h │ │ │ │ ├── SparseLU_panel_bmod.h │ │ │ │ ├── SparseLU_panel_dfs.h │ │ │ │ ├── SparseLU_pivotL.h │ │ │ │ ├── SparseLU_pruneL.h │ │ │ │ └── SparseLU_relax_snode.h │ │ │ │ ├── SparseQR │ │ │ │ └── SparseQR.h │ │ │ │ ├── StlSupport │ │ │ │ ├── StdDeque.h │ │ │ │ ├── StdList.h │ │ │ │ ├── StdVector.h │ │ │ │ └── details.h │ │ │ │ ├── SuperLUSupport │ │ │ │ └── SuperLUSupport.h │ │ │ │ ├── UmfPackSupport │ │ │ │ └── UmfPackSupport.h │ │ │ │ ├── misc │ │ │ │ ├── Image.h │ │ │ │ ├── Kernel.h │ │ │ │ ├── RealSvd2x2.h │ │ │ │ ├── blas.h │ │ │ │ ├── lapack.h │ │ │ │ ├── lapacke.h │ │ │ │ └── lapacke_mangling.h │ │ │ │ └── plugins │ │ │ │ ├── ArrayCwiseBinaryOps.h │ │ │ │ ├── ArrayCwiseUnaryOps.h │ │ │ │ ├── BlockMethods.h │ │ │ │ ├── CommonCwiseBinaryOps.h │ │ │ │ ├── CommonCwiseUnaryOps.h │ │ │ │ ├── MatrixCwiseBinaryOps.h │ │ │ │ └── MatrixCwiseUnaryOps.h │ │ │ ├── auto_download.cpp │ │ │ ├── deepsort.cpp │ │ │ ├── deepsort.hpp │ │ │ ├── pybind11.hpp │ │ │ ├── zmq_remote_show.cpp │ │ │ ├── zmq_remote_show.hpp │ │ │ ├── zmq_u.cpp │ │ │ └── zmq_u.hpp │ ├── main.cpp │ └── tensorRT │ │ ├── builder │ │ ├── trt_builder.cpp │ │ └── trt_builder.hpp │ │ ├── common │ │ ├── cuda_tools.cpp │ │ ├── cuda_tools.hpp │ │ ├── ilogger.cpp │ │ ├── ilogger.hpp │ │ ├── infer_controller.hpp │ │ ├── json.cpp │ │ ├── json.hpp │ │ ├── monopoly_allocator.hpp │ │ ├── preprocess_kernel.cu │ │ ├── preprocess_kernel.cuh │ │ ├── trt_tensor.cpp │ │ └── trt_tensor.hpp │ │ ├── import_lib.cpp │ │ ├── infer │ │ ├── trt_infer.cpp │ │ └── trt_infer.hpp │ │ ├── onnx │ │ ├── onnx-ml.pb.cpp │ │ ├── onnx-ml.pb.h │ │ ├── onnx-operators-ml.pb.cpp │ │ ├── onnx-operators-ml.pb.h │ │ ├── onnx_pb.h │ │ ├── onnxifi.h │ │ └── readme.md │ │ ├── onnx_parser │ │ ├── ImporterContext.hpp │ │ ├── LoopHelpers.cpp │ │ ├── LoopHelpers.hpp │ │ ├── ModelImporter.cpp │ │ ├── ModelImporter.hpp │ │ ├── NvOnnxParser.cpp │ │ ├── NvOnnxParser.h │ │ ├── OnnxAttrs.cpp │ │ ├── OnnxAttrs.hpp │ │ ├── RNNHelpers.cpp │ │ ├── RNNHelpers.hpp │ │ ├── ShapeTensor.cpp │ │ ├── ShapeTensor.hpp │ │ ├── ShapedWeights.cpp │ │ ├── ShapedWeights.hpp │ │ ├── Status.hpp │ │ ├── TensorOrWeights.hpp │ │ ├── builtin_op_importers.cpp │ │ ├── builtin_op_importers.hpp │ │ ├── onnx2trt.hpp │ │ ├── onnx2trt_common.hpp │ │ ├── onnx2trt_runtime.hpp │ │ ├── onnx2trt_utils.cpp │ │ ├── onnx2trt_utils.hpp │ │ ├── onnxErrorRecorder.cpp │ │ ├── onnxErrorRecorder.hpp │ │ ├── onnx_utils.hpp │ │ ├── readme.md │ │ ├── toposort.hpp │ │ ├── trt_utils.hpp │ │ └── utils.hpp │ │ └── onnxplugin │ │ ├── onnxplugin.cpp │ │ ├── onnxplugin.hpp │ │ ├── plugin_binary_io.cpp │ │ ├── plugin_binary_io.hpp │ │ └── plugins │ │ ├── DCNv2.cu │ │ ├── HSigmoid.cu │ │ └── HSwish.cu ├── tools │ └── show.py ├── tutorial │ ├── 1.0framework │ │ ├── README.md │ │ ├── app_yolo.cpp │ │ ├── infer_controller.hpp │ │ ├── inference │ │ │ ├── car.jpg │ │ │ ├── f3_0.jpg │ │ │ ├── f3_2.jpg │ │ │ ├── f3_21.jpg │ │ │ ├── f3_210.jpg │ │ │ ├── f3_211.jpg │ │ │ ├── f3_212.jpg │ │ │ ├── f3_213.jpg │ │ │ ├── f3_214.jpg │ │ │ ├── f3_215.jpg │ │ │ ├── f3_216.jpg │ │ │ ├── f3_217.jpg │ │ │ ├── f3_218.jpg │ │ │ ├── f3_219.jpg │ │ │ ├── f3_22.jpg │ │ │ ├── f3_220.jpg │ │ │ ├── f3_221.jpg │ │ │ ├── f3_222.jpg │ │ │ ├── f3_223.jpg │ │ │ ├── f3_224.jpg │ │ │ ├── f3_225.jpg │ │ │ ├── f3_226.jpg │ │ │ ├── f3_227.jpg │ │ │ ├── f3_228.jpg │ │ │ ├── f3_229.jpg │ │ │ ├── f3_27.jpg │ │ │ ├── f3_270.jpg │ │ │ ├── f3_271.jpg │ │ │ ├── f3_272.jpg │ │ │ ├── f3_273.jpg │ │ │ ├── f3_274.jpg │ │ │ ├── f3_275.jpg │ │ │ ├── f3_276.jpg │ │ │ ├── f3_277.jpg │ │ │ ├── f3_278.jpg │ │ │ ├── f3_279.jpg │ │ │ ├── f3_29.jpg │ │ │ ├── f3_290.jpg │ │ │ ├── f3_291.jpg │ │ │ ├── f3_292.jpg │ │ │ ├── f3_293.jpg │ │ │ ├── f3_294.jpg │ │ │ ├── f3_295.jpg │ │ │ ├── f3_296.jpg │ │ │ ├── f3_297.jpg │ │ │ ├── f3_298.jpg │ │ │ ├── f3_299.jpg │ │ │ ├── gril.jpg │ │ │ ├── group.jpg │ │ │ ├── show.jpg │ │ │ ├── torch_affine.jpg │ │ │ ├── trt_affine.jpg │ │ │ ├── yq.jpg │ │ │ ├── zand.jpg │ │ │ ├── zand_copy.jpg │ │ │ └── zgjr.jpg │ │ ├── pipeline.goodnotes │ │ ├── pipeline.jpg │ │ ├── pipeline.pdf │ │ ├── yolo.cpp │ │ ├── yolo.hpp │ │ └── yolo_decode.cu │ └── 2.0CenterNet_from_torch_trt │ │ ├── 0_to_1_python_to_cuda │ │ ├── cpp_cuda_centernet │ │ │ ├── .vscode │ │ │ │ ├── c_cpp_properties.json │ │ │ │ ├── launch.json │ │ │ │ ├── settings.json │ │ │ │ └── tasks.json │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── src │ │ │ │ ├── app_centernet.cpp │ │ │ │ ├── centernet.cpp │ │ │ │ ├── centernet.hpp │ │ │ │ ├── centernet_decode.cu │ │ │ │ ├── comments.jpg │ │ │ │ ├── cpp_utils.hpp │ │ │ │ ├── cuda_nms.jpg │ │ │ │ ├── cuda_utils.cuh │ │ │ │ └── main.cpp │ │ │ └── workspace │ │ │ │ ├── affined_result_cpp.jpg │ │ │ │ ├── car.jpg │ │ │ │ ├── check_preprocessed.ipynb │ │ │ │ ├── final_result_cpp.jpg │ │ │ │ ├── final_result_cuda.jpg │ │ │ │ └── test.jpg │ │ ├── model_output │ │ ├── pre_post_processing.ipynb │ │ └── truck_and_person.jpg │ │ ├── 5_outputs.jpg │ │ ├── DCNmodule_res18.png │ │ ├── README.md │ │ ├── README.zh-cn.md │ │ ├── all_in_one_output.jpg │ │ ├── comments.jpg │ │ ├── cuda_nms.jpg │ │ ├── dcn_v2.py │ │ ├── demo.py │ │ ├── export2onnx.py │ │ └── resnet_dcn.py └── workspace │ ├── cvt_dbface.py │ ├── exp │ ├── face_tracker.mp4 │ └── fall_video.mp4 │ ├── face │ ├── library │ │ └── 2ys2.jpg │ └── recognize │ │ ├── 2ys1.jpg │ │ ├── 2ys3.jpg │ │ └── 2ys5.jpg │ ├── inference │ ├── car.jpg │ ├── cat.jpg │ ├── dog_cat.png │ ├── gril.jpg │ ├── group.jpg │ ├── yq.jpg │ ├── zand.jpg │ └── zgjr.jpg │ ├── inference_fasterrcnn │ ├── car.jpg │ ├── cat.jpg │ ├── dog_cat.png │ ├── gril.jpg │ ├── group.jpg │ ├── yq.jpg │ ├── zand.jpg │ └── zgjr.jpg │ ├── labels.imagenet.txt │ ├── lesson1.py │ ├── makesure_input.py │ ├── my-yoloxs-car.jpg │ ├── perf.result.std.log │ ├── pose.show.jpg │ ├── python_test.ipynb │ ├── test.jpg │ ├── test_dcnv2.py │ ├── test_hswish.py │ ├── wget.exe │ └── yq.jpg └── test ├── car.jpg ├── x01export_FasterRCNN_onnx.py ├── x02test_FasterRCNN_onnx.py ├── x03extract_RPN.py ├── x04testRPNonnx.py ├── x05extract_ROIHeader.py ├── x06reduceRpnOnnx.py ├── x07reduce_header_onnx.py └── x08test_header_onnx.py /fpn.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/fpn.pdf -------------------------------------------------------------------------------- /model/__init__.py: -------------------------------------------------------------------------------- 1 | from .faster_rcnn import * 2 | -------------------------------------------------------------------------------- /model/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/model/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /model/__pycache__/_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/model/__pycache__/_utils.cpython-37.pyc -------------------------------------------------------------------------------- /model/__pycache__/anchor_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/model/__pycache__/anchor_utils.cpython-37.pyc -------------------------------------------------------------------------------- /model/__pycache__/backbone_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/model/__pycache__/backbone_utils.cpython-37.pyc -------------------------------------------------------------------------------- /model/__pycache__/faster_rcnn.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/model/__pycache__/faster_rcnn.cpython-37.pyc -------------------------------------------------------------------------------- /model/__pycache__/feature_pyramid_network.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/model/__pycache__/feature_pyramid_network.cpython-37.pyc -------------------------------------------------------------------------------- /model/__pycache__/generalized_rcnn.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/model/__pycache__/generalized_rcnn.cpython-37.pyc -------------------------------------------------------------------------------- /model/__pycache__/image_list.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/model/__pycache__/image_list.cpython-37.pyc -------------------------------------------------------------------------------- /model/__pycache__/roi_heads.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/model/__pycache__/roi_heads.cpython-37.pyc -------------------------------------------------------------------------------- /model/__pycache__/rpn.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/model/__pycache__/rpn.cpython-37.pyc -------------------------------------------------------------------------------- /model/__pycache__/transform.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/model/__pycache__/transform.cpython-37.pyc -------------------------------------------------------------------------------- /model/image_list.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | import torch 3 | from torch.jit.annotations import List, Tuple 4 | from torch import Tensor 5 | 6 | 7 | class ImageList(object): 8 | """ 9 | Structure that holds a list of images (of possibly 10 | varying sizes) as a single tensor. 11 | This works by padding the images to the same size, 12 | and storing in a field the original sizes of each image 13 | """ 14 | 15 | def __init__(self, tensors, image_sizes): 16 | # type: (Tensor, List[Tuple[int, int]]) -> None 17 | """ 18 | Arguments: 19 | tensors (tensor) 20 | image_sizes (list[tuple[int, int]]) 21 | """ 22 | self.tensors = tensors 23 | self.image_sizes = image_sizes 24 | 25 | def to(self, device): 26 | # type: (Device) -> ImageList # noqa 27 | cast_tensor = self.tensors.to(device) 28 | return ImageList(cast_tensor, self.image_sizes) 29 | -------------------------------------------------------------------------------- /model/ops/__pycache__/poolers.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/model/ops/__pycache__/poolers.cpython-37.pyc -------------------------------------------------------------------------------- /readme.assets/image-20211216112059762.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/readme.assets/image-20211216112059762.png -------------------------------------------------------------------------------- /readme.assets/image-20211216112509835.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/readme.assets/image-20211216112509835.png -------------------------------------------------------------------------------- /readme.assets/image-20211216112526108.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/readme.assets/image-20211216112526108.png -------------------------------------------------------------------------------- /tensorrt_code/.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/src/tensorRT 3 | tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/objs 4 | tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/pro 5 | 6 | # compressed files 7 | *.tar.gz 8 | *.zip 9 | 10 | # temp tensor and data 11 | *.tensor 12 | *.data 13 | 14 | 15 | # Prerequisites 16 | *.d 17 | 18 | # Compiled Object files 19 | *.slo 20 | *.lo 21 | *.o 22 | *.obj 23 | 24 | # Precompiled Headers 25 | *.gch 26 | *.pch 27 | 28 | # Compiled Dynamic libraries 29 | *.so 30 | *.dylib 31 | *.dll 32 | 33 | # Fortran module files 34 | *.mod 35 | *.smod 36 | 37 | # Compiled Static libraries 38 | *.lai 39 | *.la 40 | *.a 41 | *.lib 42 | 43 | # Executables 44 | *.exe 45 | *.out 46 | *.app 47 | 48 | /objs 49 | 50 | *.trtmodel 51 | *.onnx 52 | /workspace/pro 53 | /build 54 | /workspace/*.avi 55 | /workspace/.ipynb_checkpoints 56 | /workspace/*_result 57 | /workspace/face/library_draw 58 | /workspace/face/result 59 | /workspace/face/library/laq.jpg 60 | __pycache__ 61 | /tools/process_so.sh 62 | /tools/proc2.sh 63 | /python/trtpy.egg-info 64 | /python/dist 65 | /python/build 66 | /workspace/formtest.ipynb 67 | /workspace/meta.json 68 | /.vs 69 | *.pyd 70 | *.zip 71 | *.pdb 72 | *.ilk 73 | *.lib 74 | *.exp 75 | 76 | /lean/cuda10.1 77 | /lean/cudnn8.2.2.26 78 | /lean/opencv3.4.6 79 | /lean/protobuf3.11.4 80 | /lean/TensorRT-8.0.1.6 81 | 82 | __pycache__ 83 | 84 | !/workspace/wget.exe 85 | /workspace/*.mp4 86 | /workspace/single_inference 87 | /workspace/exp/tracker.final.mp4 88 | /workspace/perf.result.log 89 | -------------------------------------------------------------------------------- /tensorrt_code/TensorRT.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.136 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TensorRT", "TensorRT.vcxproj", "{FBF775F5-DAB4-4BC1-97A9-D36301073438}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Python|x64 = Python|x64 12 | Release|x64 = Release|x64 13 | EndGlobalSection 14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 15 | {FBF775F5-DAB4-4BC1-97A9-D36301073438}.Debug|x64.ActiveCfg = Debug|x64 16 | {FBF775F5-DAB4-4BC1-97A9-D36301073438}.Debug|x64.Build.0 = Debug|x64 17 | {FBF775F5-DAB4-4BC1-97A9-D36301073438}.Python|x64.ActiveCfg = Python|x64 18 | {FBF775F5-DAB4-4BC1-97A9-D36301073438}.Python|x64.Build.0 = Python|x64 19 | {FBF775F5-DAB4-4BC1-97A9-D36301073438}.Release|x64.ActiveCfg = Release|x64 20 | {FBF775F5-DAB4-4BC1-97A9-D36301073438}.Release|x64.Build.0 = Release|x64 21 | EndGlobalSection 22 | GlobalSection(SolutionProperties) = preSolution 23 | HideSolutionNode = FALSE 24 | EndGlobalSection 25 | GlobalSection(ExtensibilityGlobals) = postSolution 26 | SolutionGuid = {679F35F0-20AA-4D18-8610-D369E2BE97E8} 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /tensorrt_code/TensorRT.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | workspace 5 | PATH=$(projectDir)lean/cuda10.1/bin;$(projectDir)lean/opencv3.4.6/lib;$(projectDir)lean/cudnn8.2.2.26;$(projectDir)lean/TensorRT-8.0.1.6/lib 6 | WindowsLocalDebugger 7 | true 8 | 9 | 10 | workspace 11 | PATH=$(projectDir)lean/cuda10.1/bin;$(projectDir)lean/opencv3.4.6/lib;$(projectDir)lean/cudnn8.2.2.26;$(projectDir)lean/TensorRT-8.0.1.6/lib 12 | WindowsLocalDebugger 13 | true 14 | 15 | 16 | WindowsLocalDebugger 17 | PATH=$(projectDir)lean/cuda10.1/bin;$(projectDir)lean/opencv3.4.6/lib;$(projectDir)lean/cudnn8.2.2.26;$(projectDir)lean/TensorRT-8.0.1.6/lib 18 | workspace 19 | 20 | -------------------------------------------------------------------------------- /tensorrt_code/YoloTRT_speed.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/YoloTRT_speed.xlsx -------------------------------------------------------------------------------- /tensorrt_code/dll_export.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | PyInit_libtrtpyc -------------------------------------------------------------------------------- /tensorrt_code/onnx/make_pb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 请修改protoc为你要使用的版本protoc 4 | protoc=/data/sxai/lean/protobuf3.11.4/bin/protoc 5 | #protoc=/data/sxai/temp/protobuf-build3.18.x/bin/protoc 6 | 7 | echo Create directory "pbout" 8 | rm -rf pbout 9 | mkdir -p pbout 10 | 11 | $protoc onnx-ml.proto --cpp_out=pbout 12 | $protoc onnx-operators-ml.proto --cpp_out=pbout 13 | 14 | echo Copy pbout/onnx-ml.pb.cc to ../src/tensorRT/onnx/onnx-ml.pb.cpp 15 | cp pbout/onnx-ml.pb.cc ../src/tensorRT/onnx/onnx-ml.pb.cpp 16 | 17 | echo Copy pbout/onnx-operators-ml.pb.cc to ../src/tensorRT/onnx/onnx-operators-ml.pb.cpp 18 | cp pbout/onnx-operators-ml.pb.cc ../src/tensorRT/onnx/onnx-operators-ml.pb.cpp 19 | 20 | echo Copy pbout/onnx-ml.pb.h to ../src/tensorRT/onnx/onnx-ml.pb.h 21 | cp pbout/onnx-ml.pb.h ../src/tensorRT/onnx/onnx-ml.pb.h 22 | 23 | echo Copy pbout/onnx-operators-ml.pb.h to ../src/tensorRT/onnx/onnx-operators-ml.pb.h 24 | cp pbout/onnx-operators-ml.pb.h ../src/tensorRT/onnx/onnx-operators-ml.pb.h 25 | 26 | echo Remove directory "pbout" 27 | rm -rf pbout -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_7.x/LoopHelpers.cpp: -------------------------------------------------------------------------------- 1 | #include "LoopHelpers.hpp" 2 | #include "onnx2trt_utils.hpp" 3 | 4 | namespace onnx2trt 5 | { 6 | 7 | nvinfer1::ITensor* addLoopCounter(IImporterContext* ctx, nvinfer1::ILoop* loop, int32_t initial) 8 | { 9 | nvinfer1::ITensor* initialTensor = addConstantScalar(ctx, initial, ::onnx::TensorProto::INT32, nvinfer1::Dims{1, 1})->getOutput(0); 10 | nvinfer1::ITensor* one = addConstantScalar(ctx, 1, ::onnx::TensorProto::INT32, nvinfer1::Dims{1, 1})->getOutput(0); 11 | 12 | auto counter = loop->addRecurrence(*initialTensor); 13 | nvinfer1::ITensor* addOne = ctx->network()->addElementWise(*counter->getOutput(0), *one, nvinfer1::ElementWiseOperation::kSUM)->getOutput(0); 14 | counter->setInput(1, *addOne); 15 | return counter->getOutput(0); 16 | } 17 | 18 | } // namespace onnx2trt 19 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_7.x/LoopHelpers.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "ImporterContext.hpp" 6 | 7 | namespace onnx2trt 8 | { 9 | 10 | nvinfer1::ITensor* addLoopCounter(IImporterContext* ctx, nvinfer1::ILoop* loop, int32_t initial = 0); 11 | 12 | } // namespace onnx2trt 13 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_7.x/NvOnnxParser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include "NvOnnxParser.h" 24 | #include "ModelImporter.hpp" 25 | 26 | extern "C" void* createNvOnnxParser_INTERNAL(void* network_, void* logger_, int version, const std::vector& input_dims) 27 | { 28 | auto network = static_cast(network_); 29 | auto logger = static_cast(logger_); 30 | return new onnx2trt::ModelImporter(network, logger, input_dims); 31 | } 32 | 33 | extern "C" int getNvOnnxParserVersion() 34 | { 35 | return NV_ONNX_PARSER_VERSION; 36 | } 37 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_7.x/RNNHelpers.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "TensorOrWeights.hpp" 8 | #include "ImporterContext.hpp" 9 | 10 | namespace onnx2trt 11 | { 12 | 13 | nvinfer1::ITensor* addRNNInput(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, std::vector& inputs, const std::string& direction); 14 | 15 | // Zeros out invalid timesteps in toMask. maxLen must be provided if reverse is true 16 | nvinfer1::ITensor* clearMissingSequenceElements(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, nvinfer1::ITensor* seqLens, nvinfer1::ITensor* toMask, nvinfer1::ITensor* maxLen, bool reverse = false, nvinfer1::ITensor* counter = nullptr); 17 | 18 | // Returns a bool tensor which is true during valid timesteps 19 | nvinfer1::ITensor* getRaggedMask(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, nvinfer1::ITensor* seqLens, nvinfer1::ITensor* maxLen = nullptr, bool reverse = false, nvinfer1::ITensor* counter = nullptr); 20 | 21 | // Selects between prevH and Ht to forward previous hidden state through invalid timesteps 22 | nvinfer1::ITensor* maskRNNHidden(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, nvinfer1::ITensor* seqLens, nvinfer1::ITensor* prevH, nvinfer1::ITensor* Ht, nvinfer1::ITensor* maxLen = nullptr, bool reverse = false, nvinfer1::ITensor* counter = nullptr); 23 | 24 | // Splits a bidirectional hidden state into forward and reverse passes, masks each using maskRNNHidden, then concatenates 25 | nvinfer1::ITensor* maskBidirRNNHidden(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, nvinfer1::ITensor* seqLens, nvinfer1::ITensor* maxLen, nvinfer1::ITensor* Ht1, nvinfer1::ITensor* Ht, nvinfer1::ITensor* singlePassShape); 26 | 27 | } // namespace onnx2trt 28 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_7.x/ShapedWeights.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | 28 | namespace onnx2trt 29 | { 30 | 31 | class ShapedWeights 32 | { 33 | public: 34 | using DataType = int32_t; 35 | DataType type; 36 | void* values; 37 | nvinfer1::Dims shape; 38 | const char* name = nullptr; 39 | static ShapedWeights empty(DataType type); 40 | ShapedWeights(); 41 | explicit ShapedWeights(DataType type, void* values, nvinfer1::Dims shape_); 42 | size_t count() const; 43 | size_t size_bytes() const; 44 | const char* getName() const; 45 | void setName(const char* name); 46 | explicit operator bool() const; 47 | operator nvinfer1::Weights() const; 48 | }; 49 | 50 | bool transposeWeights(ShapedWeights const& weights, nvinfer1::Permutation const& perm, ShapedWeights* result); 51 | 52 | } // namespace onnx2trt 53 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_7.x/builtin_op_importers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "onnx2trt.hpp" 26 | #include "utils.hpp" 27 | 28 | namespace onnx2trt 29 | { 30 | 31 | string_map& getBuiltinOpImporterMap(); 32 | 33 | } // namespace onnx2trt 34 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_7.x/onnx2trt_runtime.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "onnx2trt_common.hpp" 26 | 27 | namespace onnx2trt 28 | { 29 | 30 | typedef Plugin* (*plugin_deserializer)(const void* serialData, size_t serialLength); 31 | 32 | } // namespace onnx2trt 33 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_7.x/utils.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | template 28 | using string_map = std::unordered_map; 29 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_8.x/LoopHelpers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #include "LoopHelpers.hpp" 6 | #include "onnx2trt_utils.hpp" 7 | 8 | namespace onnx2trt 9 | { 10 | 11 | nvinfer1::ITensor* addLoopCounter(IImporterContext* ctx, nvinfer1::ILoop* loop, int32_t initial) 12 | { 13 | nvinfer1::ITensor* initialTensor = addConstantScalar(ctx, initial, ::onnx::TensorProto::INT32, nvinfer1::Dims{1, 1})->getOutput(0); 14 | nvinfer1::ITensor* one = addConstantScalar(ctx, 1, ::onnx::TensorProto::INT32, nvinfer1::Dims{1, 1})->getOutput(0); 15 | 16 | auto counter = loop->addRecurrence(*initialTensor); 17 | nvinfer1::ITensor* addOne = ctx->network()->addElementWise(*counter->getOutput(0), *one, nvinfer1::ElementWiseOperation::kSUM)->getOutput(0); 18 | counter->setInput(1, *addOne); 19 | return counter->getOutput(0); 20 | } 21 | 22 | } // namespace onnx2trt 23 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_8.x/LoopHelpers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include "ImporterContext.hpp" 10 | 11 | namespace onnx2trt 12 | { 13 | 14 | nvinfer1::ITensor* addLoopCounter(IImporterContext* ctx, nvinfer1::ILoop* loop, int32_t initial = 0); 15 | 16 | } // namespace onnx2trt 17 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_8.x/NvOnnxParser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #include "NvOnnxParser.h" 6 | #include "ModelImporter.hpp" 7 | 8 | extern "C" void* createNvOnnxParser_INTERNAL(void* network_, void* logger_, int version, const std::vector& input_dims) 9 | { 10 | auto network = static_cast(network_); 11 | auto logger = static_cast(logger_); 12 | return new onnx2trt::ModelImporter(network, logger, input_dims); 13 | } 14 | 15 | extern "C" int getNvOnnxParserVersion() 16 | { 17 | return NV_ONNX_PARSER_VERSION; 18 | } -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_8.x/OnnxAttrs.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "ImporterContext.hpp" 13 | 14 | class OnnxAttrs 15 | { 16 | template 17 | using string_map = std::unordered_map; 18 | typedef string_map<::onnx::AttributeProto const*> AttrMap; 19 | AttrMap _attrs; 20 | onnx2trt::IImporterContext* mCtx; 21 | 22 | public: 23 | explicit OnnxAttrs(::onnx::NodeProto const& onnx_node, onnx2trt::IImporterContext* ctx) 24 | : mCtx{ctx} 25 | { 26 | for (auto const& attr : onnx_node.attribute()) 27 | { 28 | _attrs.insert({attr.name(), &attr}); 29 | } 30 | } 31 | 32 | bool count(const std::string& key) const 33 | { 34 | return _attrs.count(key); 35 | } 36 | 37 | ::onnx::AttributeProto const* at(std::string key) const 38 | { 39 | if (!_attrs.count(key)) 40 | { 41 | throw std::out_of_range("Attribute not found: " + key); 42 | } 43 | return _attrs.at(key); 44 | } 45 | 46 | ::onnx::AttributeProto::AttributeType type(const std::string& key) const 47 | { 48 | return this->at(key)->type(); 49 | } 50 | 51 | 52 | template 53 | T get(const std::string& key) const; 54 | 55 | template 56 | T get(const std::string& key, T const& default_value) const 57 | { 58 | return _attrs.count(key) ? this->get(key) : default_value; 59 | } 60 | }; 61 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_8.x/RNNHelpers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "TensorOrWeights.hpp" 12 | #include "ImporterContext.hpp" 13 | 14 | namespace onnx2trt 15 | { 16 | 17 | nvinfer1::ITensor* addRNNInput(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, std::vector& inputs, const std::string& direction); 18 | 19 | // Zeros out invalid timesteps in toMask. maxLen must be provided if reverse is true 20 | nvinfer1::ITensor* clearMissingSequenceElements(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, nvinfer1::ITensor* seqLens, nvinfer1::ITensor* toMask, nvinfer1::ITensor* maxLen, bool reverse = false, nvinfer1::ITensor* counter = nullptr); 21 | 22 | // Returns a bool tensor which is true during valid timesteps 23 | nvinfer1::ITensor* getRaggedMask(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, nvinfer1::ITensor* seqLens, nvinfer1::ITensor* maxLen = nullptr, bool reverse = false, nvinfer1::ITensor* counter = nullptr); 24 | 25 | // Selects between prevH and Ht to forward previous hidden state through invalid timesteps 26 | nvinfer1::ITensor* maskRNNHidden(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, nvinfer1::ITensor* seqLens, nvinfer1::ITensor* prevH, nvinfer1::ITensor* Ht, nvinfer1::ITensor* maxLen = nullptr, bool reverse = false, nvinfer1::ITensor* counter = nullptr); 27 | 28 | // Splits a bidirectional hidden state into forward and reverse passes, masks each using maskRNNHidden, then concatenates 29 | nvinfer1::ITensor* maskBidirRNNHidden(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, nvinfer1::ITensor* seqLens, nvinfer1::ITensor* maxLen, nvinfer1::ITensor* Ht1, nvinfer1::ITensor* Ht, nvinfer1::ITensor* singlePassShape); 30 | 31 | } // namespace onnx2trt 32 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_8.x/ShapedWeights.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | namespace onnx2trt 11 | { 12 | 13 | class ShapedWeights 14 | { 15 | public: 16 | using DataType = int32_t; 17 | 18 | static ShapedWeights empty(DataType type); 19 | 20 | ShapedWeights(); 21 | 22 | explicit ShapedWeights(DataType type, void* values, nvinfer1::Dims shape_); 23 | 24 | size_t count() const; 25 | 26 | size_t size_bytes() const; 27 | 28 | const char* getName() const; 29 | 30 | void setName(const char* name); 31 | 32 | explicit operator bool() const; 33 | 34 | operator nvinfer1::Weights() const; 35 | 36 | template 37 | T& at(size_t index) 38 | { 39 | assert(index >= 0 && (index * sizeof(T)) < size_bytes()); 40 | return static_cast(values)[index]; 41 | } 42 | 43 | template 44 | const T& at(size_t index) const 45 | { 46 | assert(index >= 0 && (index * sizeof(T)) < size_bytes()); 47 | return static_cast(values)[index]; 48 | } 49 | 50 | public: 51 | DataType type; 52 | void* values; 53 | nvinfer1::Dims shape; 54 | const char* name{}; 55 | }; 56 | 57 | class IImporterContext; 58 | bool transposeWeights(ShapedWeights const& weights, nvinfer1::Permutation const& perm, ShapedWeights* result, IImporterContext* ctx); 59 | 60 | } // namespace onnx2trt 61 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_8.x/builtin_op_importers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "onnx2trt.hpp" 8 | #include "utils.hpp" 9 | 10 | namespace onnx2trt 11 | { 12 | 13 | string_map& getBuiltinOpImporterMap(); 14 | 15 | } // namespace onnx2trt 16 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_8.x/onnx2trt.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "NvOnnxParser.h" 8 | #include "ShapedWeights.hpp" 9 | #include "Status.hpp" 10 | #include "TensorOrWeights.hpp" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace onnx2trt 21 | { 22 | 23 | class IImporterContext; 24 | 25 | // TODO: Find ABI-safe alternative approach for this: 26 | // Can't use std::vector 27 | // Can't use ::onnx::NodeProto 28 | // Can't use std::function 29 | typedef ValueOrStatus> NodeImportResult; 30 | typedef std::function& inputs)> 32 | NodeImporter; 33 | 34 | template 35 | using StringMap = std::unordered_map; 36 | 37 | class IImporterContext 38 | { 39 | public: 40 | virtual nvinfer1::INetworkDefinition* network() = 0; 41 | virtual StringMap& tensors() = 0; 42 | virtual StringMap& tensorLocations() = 0; 43 | virtual StringMap& tensorRangeMins() = 0; 44 | virtual StringMap& tensorRangeMaxes() = 0; 45 | virtual StringMap& layerPrecisions() = 0; 46 | virtual std::unordered_set& unsupportedShapeTensors() = 0; 47 | virtual StringMap& loopTensors() = 0; 48 | virtual void setOnnxFileLocation(std::string location) = 0; 49 | virtual std::string getOnnxFileLocation() = 0; 50 | virtual void registerTensor(TensorOrWeights tensor, const std::string& basename) = 0; 51 | virtual void registerLayer(nvinfer1::ILayer* layer, const std::string& basename) = 0; 52 | virtual ShapedWeights createTempWeights(ShapedWeights::DataType type, nvinfer1::Dims shape, uint8_t value = 0) = 0; 53 | virtual int64_t getOpsetVersion(const char* domain = "") const = 0; 54 | virtual nvinfer1::ILogger& logger() = 0; 55 | virtual bool hasError() const = 0; 56 | virtual nvinfer1::IErrorRecorder* getErrorRecorder() const = 0; 57 | 58 | protected: 59 | virtual ~IImporterContext() 60 | { 61 | } 62 | }; 63 | 64 | } // namespace onnx2trt 65 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_8.x/onnx2trt_common.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | #if NV_TENSORRT_MAJOR < 4 11 | namespace nvinfer1 12 | { 13 | 14 | enum class PluginFormat : uint8_t 15 | { 16 | kNCHW = 0, //!< NCHW 17 | kNC2HW2 = 1, //!< NCHW with 2-element packed channels 18 | kNHWC8 = 2 //!< NHWC with 8-element packed channels (C 19 | //! must be a multiple of 8) 20 | }; 21 | // from NvInfer.h 22 | class IPluginExt : public IPlugin 23 | { 24 | public: 25 | virtual int getTensorRTVersion() const noexcept 26 | { 27 | return NV_TENSORRT_VERSION; 28 | } 29 | virtual bool supportsFormat(DataType type, PluginFormat format) const noexcept = 0; 30 | virtual void configureWithFormat(const Dims* inputDims, int nbInputs, const Dims* outputDims, int nbOutputs, 31 | DataType type, PluginFormat format, int maxBatchSize) noexcept 32 | = 0; 33 | 34 | protected: 35 | void configure( 36 | const Dims* inputDims, int nbInputs, const Dims* outputDims, int nbOutputs, int maxBatchSize) noexcept final 37 | { 38 | try 39 | { 40 | DataType type = nvinfer1::DataType::kFLOAT; 41 | PluginFormat format = nvinfer1::PluginFormat::kLINEAR; 42 | return this->configureWithFormat(inputDims, nbInputs, outputDims, nbOutputs, type, format, maxBatchSize); 43 | } 44 | catch (const std::exception& e) 45 | { 46 | nvinfer1::getLogger()->log(nvinfer1::ILogger::Severity::kERROR, e.what().c_str()); 47 | } 48 | } 49 | virtual ~IPluginExt() 50 | { 51 | } 52 | }; 53 | 54 | } // namespace nvinfer1 55 | #endif 56 | 57 | namespace onnx2trt 58 | { 59 | 60 | struct IOwnable 61 | { 62 | virtual void destroy() = 0; 63 | 64 | protected: 65 | virtual ~IOwnable() 66 | { 67 | } 68 | }; 69 | 70 | struct OwnableDeleter 71 | { 72 | void operator()(IOwnable* obj) const 73 | { 74 | obj->destroy(); 75 | } 76 | }; 77 | 78 | using UniqueOwnable = std::unique_ptr; 79 | class Plugin; 80 | class PluginV2; 81 | 82 | } // namespace onnx2trt 83 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_8.x/onnx2trt_runtime.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "onnx2trt_common.hpp" 8 | 9 | namespace onnx2trt 10 | { 11 | 12 | typedef Plugin* (*plugin_deserializer)(const void* serialData, size_t serialLength); 13 | 14 | } // namespace onnx2trt 15 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_8.x/readme.md: -------------------------------------------------------------------------------- 1 | # ONNX Parser 2 | - 这几个文件提取自官方的onnx-tensorrt,去掉python方面,其他都在 3 | - 另外增加了Plugin节点的支持 4 | - https://github.com/onnx/onnx-tensorrt -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/onnx_parser_8.x/utils.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | template 10 | using string_map = std::unordered_map; 11 | -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/readme.md: -------------------------------------------------------------------------------- 1 | # Onnx parser for 7.x/8.x 2 | - Origin Code 7.x: https://github.com/onnx/onnx-tensorrt/releases/tag/release%2F7.2.1 3 | - Origin Code 8.x: https://github.com/onnx/onnx-tensorrt/releases/tag/release%2F8.0 4 | 5 | # TensorRT 7.x support 6 | 1. Replace onnx_parser_for_7.x/onnx_parser to src/tensorRT/onnx_parser 7 | - `rm -rf src/tensorRT/onnx_parser` 8 | - `cp -r onnx_parser/onnx_parser_7.x src/tensorRT/onnx_parser` 9 | - or execute `bash onnx_parser/use_tensorrt_7.x.sh` 10 | 2. Configure Makefile/CMakeLists.txt path to TensorRT7.x 11 | 3. Execute `make yolo -j64` 12 | 13 | # TensorRT 8.x support 14 | 1. Replace onnx_parser_for_8.x/onnx_parser to src/tensorRT/onnx_parser 15 | - `rm -rf src/tensorRT/onnx_parser` 16 | - `cp -r onnx_parser/onnx_parser_8.x src/tensorRT/onnx_parser` 17 | - or execute `bash onnx_parser/use_tensorrt_8.x.sh` 18 | 2. Configure Makefile/CMakeLists.txt path to TensorRT8.x 19 | 3. Execute `make yolo -j64` 20 | 21 | # Unsupported TensorRT for less 7.x version -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/use_tensorrt_7.x.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo Remove src/tensorRT/onnx_parser 4 | rm -rf src/tensorRT/onnx_parser 5 | 6 | echo Copy [onnx_parser/onnx_parser_7.x] to [src/tensorRT/onnx_parser] 7 | cp -r onnx_parser/onnx_parser_7.x src/tensorRT/onnx_parser 8 | 9 | echo Configure your tensorRT path to 7.x 10 | echo After that, you can execute the command 'make yolo -j64' -------------------------------------------------------------------------------- /tensorrt_code/onnx_parser/use_tensorrt_8.x.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo Remove src/tensorRT/onnx_parser 4 | rm -rf src/tensorRT/onnx_parser 5 | 6 | echo Copy [onnx_parser/onnx_parser_8.x] to [src/tensorRT/onnx_parser] 7 | cp -r onnx_parser/onnx_parser_8.x src/tensorRT/onnx_parser 8 | 9 | echo Configure your tensorRT path to 8.x 10 | echo After that, you can execute the command 'make yolo -j64' -------------------------------------------------------------------------------- /tensorrt_code/python/copy_dll_to_trtpy.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | copy ..\lean\cuda10.1\bin\cublas64_100.dll .\trtpy\ 3 | copy ..\lean\cuda10.1\bin\cublasLt64_10.dll .\trtpy\ 4 | copy ..\lean\cuda10.1\bin\cudart64_101.dll .\trtpy\ 5 | copy ..\lean\cuda10.1\bin\cublas64_10.dll .\trtpy\ 6 | 7 | copy ..\lean\opencv3.4.6\lib\opencv_world346.dll .\trtpy\ 8 | copy ..\lean\TensorRT-8.0.1.6\lib\nvinfer.dll .\trtpy\ 9 | copy ..\lean\TensorRT-8.0.1.6\lib\nvinfer_plugin.dll .\trtpy\ 10 | copy ..\lean\cudnn8.2.2.26\*.dll .\trtpy\ 11 | 12 | -------------------------------------------------------------------------------- /tensorrt_code/python/setup.py: -------------------------------------------------------------------------------- 1 | 2 | from setuptools import find_packages 3 | from setuptools import setup 4 | import platform 5 | import os 6 | 7 | os_name = platform.system() 8 | if os_name == "Linux": 9 | cpp_library = ["libtrtpyc.so"] 10 | elif os_name == "Windows": 11 | os.system("copy_dll_to_trtpy.bat") 12 | cpp_library = [ 13 | "libtrtpyc.pyd", 14 | "cublas64_10.dll", 15 | "cublas64_100.dll", 16 | "cublasLt64_10.dll", 17 | "cudart64_101.dll", 18 | "cudnn64_8.dll", 19 | "cudnn_adv_infer64_8.dll", 20 | "cudnn_adv_train64_8.dll", 21 | "cudnn_cnn_infer64_8.dll", 22 | "cudnn_cnn_train64_8.dll", 23 | "cudnn_ops_infer64_8.dll", 24 | "cudnn_ops_train64_8.dll", 25 | "nvinfer.dll", 26 | "nvinfer_plugin.dll", 27 | "opencv_world346.dll" 28 | ] 29 | 30 | else: 31 | raise RuntimeError(f"Unsupport platform {os_name}") 32 | 33 | setup( 34 | name="trtpy", 35 | version="1.0", 36 | author="Wish", 37 | url="https://github.com/shouxieai/tensorRT_cpp", 38 | description="tensorRT CPP/Python", 39 | packages=find_packages(), 40 | package_data={ 41 | "": cpp_library 42 | }, 43 | zip_safe=False 44 | ) -------------------------------------------------------------------------------- /tensorrt_code/python/test_centernet.py: -------------------------------------------------------------------------------- 1 | import os 2 | import cv2 3 | import numpy as np 4 | import trtpy as tp 5 | 6 | # change current workspace 7 | os.chdir("../workspace/") 8 | 9 | # 如果执行出错,请删掉 ~/.trtpy的缓存模型 10 | # rm -rf ~/.trtpy,重新下载 11 | engine_file = "centernet_r18_dcn.fp32.trtmodel" 12 | if not os.path.exists(engine_file): 13 | tp.compile_onnx_to_file(5, tp.onnx_hub("centernet_r18_dcn"), engine_file) 14 | 15 | model = tp.CenterNet(engine_file) 16 | image = cv2.imread("inference/car.jpg") 17 | bboxes = model.commit(image).get() 18 | print(f"{len(bboxes)} objects") 19 | 20 | for box in bboxes: 21 | print(box) 22 | left, top, right, bottom = map(int, [box.left, box.top, box.right, box.bottom]) 23 | cv2.rectangle(image, (left, top), (right, bottom), tp.random_color(box.class_label), 5) 24 | 25 | os.makedirs("single_inference", exist_ok=True) 26 | saveto = "single_inference/centernet.car.jpg" 27 | print(f"Save to {saveto}") 28 | 29 | cv2.imwrite(saveto, image) 30 | 31 | -------------------------------------------------------------------------------- /tensorrt_code/python/test_retinaface.py: -------------------------------------------------------------------------------- 1 | import os 2 | import cv2 3 | import numpy as np 4 | import trtpy as tp 5 | 6 | # change current workspace 7 | os.chdir("../workspace/") 8 | 9 | def compile_model(width, height): 10 | 11 | width = tp.upbound(width) 12 | height = tp.upbound(height) 13 | index_of_reshape_layer = 0 14 | def hook_reshape(name, shape): 15 | # print(name) 16 | # layerset = [ 17 | # "Reshape_100", "Reshape_104", "Reshape_108", 18 | # "Reshape_113", "Reshape_117", "Reshape_121", 19 | # "Reshape_126", "Reshape_130", "Reshape_134" 20 | # ] 21 | nonlocal index_of_reshape_layer 22 | strides = [8, 16, 32, 8, 16, 32, 8, 16, 32] 23 | index = index_of_reshape_layer 24 | index_of_reshape_layer += 1 25 | 26 | stride = strides[index] 27 | return [-1, height * width // stride // stride * 2, shape[2]] 28 | 29 | engine_file = f"retinaface.{width}x{height}.fp32.trtmodel" 30 | if not os.path.exists(engine_file): 31 | 32 | tp.set_compile_hook_reshape_layer(hook_reshape) 33 | tp.compile_onnx_to_file( 34 | 5, tp.onnx_hub("mb_retinaface"), engine_file, 35 | inputs_dims=np.array([ 36 | [1, 3, height, width] 37 | ], dtype=np.int32) 38 | ) 39 | return engine_file 40 | 41 | 42 | engine_file = compile_model(640, 640) 43 | detector = tp.Retinaface(engine_file, nms_threshold=0.4) 44 | image = cv2.imread("inference/group.jpg") 45 | faces = detector.commit(image).get() 46 | 47 | for face in faces: 48 | left, top, right, bottom = map(int, [face.left, face.top, face.right, face.bottom]) 49 | cv2.rectangle(image, (left, top), (right, bottom), (255, 0, 255), 5) 50 | 51 | for x, y in face.landmark.astype(int): 52 | cv2.circle(image, (x, y), 3, (0, 255, 0), -1, 16) 53 | 54 | os.makedirs("single_inference", exist_ok=True) 55 | saveto = "single_inference/retinaface.group.jpg" 56 | print(f"{len(faces)} faces, Save to {saveto}") 57 | cv2.imwrite(saveto, image) -------------------------------------------------------------------------------- /tensorrt_code/python/test_scrfd.py: -------------------------------------------------------------------------------- 1 | import os 2 | import cv2 3 | import numpy as np 4 | import trtpy as tp 5 | 6 | # change current workspace 7 | os.chdir("../workspace/") 8 | tp.set_log_level(tp.LogLevel.Verbose) 9 | 10 | def compile_model(width, height): 11 | 12 | def hook_reshape(name, shape): 13 | layerset = [ 14 | "Reshape_108", "Reshape_110", "Reshape_112", 15 | "Reshape_126", "Reshape_128", "Reshape_130", 16 | "Reshape_144", "Reshape_146", "Reshape_148" 17 | ] 18 | strides = [8, 8, 8, 16, 16, 16, 32, 32, 32] 19 | 20 | if name in layerset: 21 | index = layerset.index(name) 22 | stride = strides[index] 23 | return [-1, height * width // stride // stride * 2, shape[2]] 24 | 25 | return shape 26 | 27 | engine_file = f"scrfd.{width}x{height}.fp32.trtmodel" 28 | if not os.path.exists(engine_file): 29 | 30 | tp.set_compile_hook_reshape_layer(hook_reshape) 31 | tp.compile_onnx_to_file( 32 | 5, tp.onnx_hub("scrfd_2.5g_bnkps"), engine_file, 33 | inputs_dims=np.array([ 34 | [1, 3, height, width] 35 | ], dtype=np.int32) 36 | ) 37 | return engine_file 38 | 39 | 40 | engine_file = compile_model(640, 640) 41 | detector = tp.Scrfd(engine_file, nms_threshold=0.5) 42 | image = cv2.imread("inference/group.jpg") 43 | faces = detector.commit(image).get() 44 | 45 | for face in faces: 46 | left, top, right, bottom = map(int, [face.left, face.top, face.right, face.bottom]) 47 | cv2.rectangle(image, (left, top), (right, bottom), (255, 0, 255), 5) 48 | 49 | for x, y in face.landmark.astype(int): 50 | cv2.circle(image, (x, y), 3, (0, 255, 0), -1, 16) 51 | 52 | os.makedirs("single_inference", exist_ok=True) 53 | saveto = "single_inference/scrfd.group.jpg" 54 | print(f"{len(faces)} faces, Save to {saveto}") 55 | cv2.imwrite(saveto, image) -------------------------------------------------------------------------------- /tensorrt_code/python/test_torch.py: -------------------------------------------------------------------------------- 1 | 2 | import torch 3 | import torchvision.models as models 4 | import trtpy as tp 5 | import numpy as np 6 | import os 7 | 8 | os.chdir("../workspace/") 9 | device = "cuda" if torch.cuda.is_available() else "cpu" 10 | 11 | # 基于torch的tensor输入 12 | input = torch.full((5, 3, 224, 224), 0.3).to(device) 13 | model = models.resnet18(True).eval().to(device) 14 | trt_model = tp.from_torch(model, input, engine_save_file="torch.engine.trtmodel", onnx_save_file="torch.onnx") 15 | torch_out = model(input) 16 | trt_out = trt_model(input) 17 | 18 | trt_model.save("torch.trtmodel") 19 | 20 | abs_diff = (torch_out - trt_out).abs().max() 21 | print(f"Torch and TRTModel abs diff is {abs_diff}") 22 | 23 | 24 | 25 | print(trt_model.input().shape) 26 | trt_model.input().resize_single_dim(0, 1) 27 | print(trt_model.input().shape) 28 | trt_model.input().resize_single_dim(0, 5) 29 | 30 | # 获取模型的input,并对输入进行赋值为0.5 31 | trt_model.input().numpy[:] = 0.5 32 | 33 | # 执行推理 34 | trt_model.forward() 35 | 36 | # 获取输出 37 | trt_out = trt_model.output().numpy 38 | 39 | #对torch进行推理 40 | input[:] = 0.5 41 | torch_out = model(input).cpu().data.numpy() 42 | 43 | # 对比差距绝对值 44 | abs_diff = np.abs(torch_out - trt_out).max() 45 | print(f"Torch and TRTModel abs diff is {abs_diff}") -------------------------------------------------------------------------------- /tensorrt_code/python/test_yolov5.py: -------------------------------------------------------------------------------- 1 | import os 2 | import cv2 3 | import numpy as np 4 | import trtpy as tp 5 | 6 | # change current workspace 7 | os.chdir("../workspace/") 8 | 9 | # 如果执行出错,请删掉 ~/.trtpy的缓存模型 10 | # rm -rf ~/.trtpy,重新下载 11 | engine_file = "yolov5m.fp32.trtmodel" 12 | if not os.path.exists(engine_file): 13 | tp.compile_onnx_to_file(5, tp.onnx_hub("yolov5m"), engine_file) 14 | 15 | yolo = tp.Yolo(engine_file, type=tp.YoloType.V5) 16 | image = cv2.imread("inference/car.jpg") 17 | bboxes = yolo.commit(image).get() 18 | print(f"{len(bboxes)} objects") 19 | 20 | for box in bboxes: 21 | left, top, right, bottom = map(int, [box.left, box.top, box.right, box.bottom]) 22 | cv2.rectangle(image, (left, top), (right, bottom), tp.random_color(box.class_label), 5) 23 | 24 | os.makedirs("single_inference", exist_ok=True) 25 | saveto = "single_inference/yolov5.car.jpg" 26 | print(f"Save to {saveto}") 27 | 28 | cv2.imwrite(saveto, image) 29 | 30 | -------------------------------------------------------------------------------- /tensorrt_code/python/test_yolox.py: -------------------------------------------------------------------------------- 1 | import os 2 | import cv2 3 | import numpy as np 4 | import trtpy as tp 5 | 6 | # change current workspace 7 | os.chdir("../workspace/") 8 | 9 | # 如果执行出错,请删掉 ~/.trtpy的缓存模型 10 | # rm -rf ~/.trtpy,重新下载 11 | engine_file = "yolox_m.fp32.trtmodel" 12 | if not os.path.exists(engine_file): 13 | tp.compile_onnx_to_file(5, tp.onnx_hub("yolox_m"), engine_file) 14 | 15 | yolo = tp.Yolo(engine_file, type=tp.YoloType.X) 16 | image = cv2.imread("inference/car.jpg") 17 | bboxes = yolo.commit(image).get() 18 | print(f"{len(bboxes)} objects") 19 | 20 | for box in bboxes: 21 | print(f"{box}") 22 | left, top, right, bottom = map(int, [box.left, box.top, box.right, box.bottom]) 23 | cv2.rectangle(image, (left, top), (right, bottom), tp.random_color(box.class_label), 5) 24 | 25 | os.makedirs("single_inference", exist_ok=True) 26 | saveto = "single_inference/yolox.car.jpg" 27 | print(f"Save to {saveto}") 28 | 29 | cv2.imwrite(saveto, image) -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_alphapose.cpp: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @file _main.cpp 4 | * @author 手写AI (zifuture.com:8090) 5 | * @date 2021-07-26 6 | * 7 | * 实现了基于TensorRT对yolox的推理工作 8 | * 1. 基于FP32的模型编译、和推理执行 9 | * 2. 基于INT8的模型编译、和推理执行 10 | * 3. 自定义插件的实现,从pytorch导出到推理编译,并支持FP16 11 | * 12 | * 预处理、后处理采用CPU实现(若想GPU可以自行实现) 13 | * 一次推理5张图获取结果 14 | * 15 | * 我们是一群热血的个人组织者,力图发布免费高质量内容 16 | * 我们的博客地址:http://zifuture.com:8090 17 | * 我们的B站地址:https://space.bilibili.com/1413433465 18 | * 19 | * 如果想要深入学习关于tensorRT的技术栈,请通过博客中的二维码联系我们(免费崔更即可) 20 | * 请关注B站,我们根据情况发布相关教程视频(免费) 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include "app_alphapose/alpha_pose.hpp" 27 | 28 | using namespace std; 29 | using namespace cv; 30 | 31 | bool requires(const char* name); 32 | 33 | int app_alphapose(){ 34 | 35 | TRT::set_device(0); 36 | INFO("===================== test alphapose fp32 =================================="); 37 | 38 | const char* name = "sppe"; 39 | if(not requires(name)) 40 | return 0; 41 | 42 | string onnx_file = iLogger::format("%s.onnx", name); 43 | string model_file = iLogger::format("%s.FP32.trtmodel", name); 44 | int test_batch_size = 16; 45 | 46 | if(!iLogger::exists(model_file)){ 47 | TRT::compile( 48 | TRT::Mode::FP32, // FP32、FP16、INT8 49 | test_batch_size, // max_batch_size 50 | onnx_file, // source 51 | model_file // save to 52 | ); 53 | } 54 | 55 | Mat image = imread("inference/gril.jpg"); 56 | auto engine = AlphaPose::create_infer(model_file, 0); 57 | auto box = Rect(158, 104, 176, 693); 58 | auto keys = engine->commit(make_tuple(image, box)).get(); 59 | for(int i = 0; i < keys.size(); ++i){ 60 | float x = keys[i].x; 61 | float y = keys[i].y; 62 | cv::circle(image, Point(x, y), 5, Scalar(0, 255, 0), -1, 16); 63 | } 64 | 65 | auto save_file = "pose.show.jpg"; 66 | INFO("Save to %s", save_file); 67 | 68 | imwrite(save_file, image); 69 | INFO("Done"); 70 | return 0; 71 | } -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_alphapose/alpha_pose.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ALPHA_POSE_HPP 2 | #define ALPHA_POSE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace AlphaPose{ 11 | 12 | using namespace std; 13 | using namespace cv; 14 | 15 | typedef tuple Input; 16 | 17 | class Infer{ 18 | public: 19 | virtual shared_future> commit(const Input& input) = 0; 20 | virtual vector>> commits(const vector& inputs) = 0; 21 | }; 22 | 23 | shared_ptr create_infer(const string& engine_file, int gpuid); 24 | 25 | }; // namespace AlphaPose 26 | 27 | #endif // ALPHA_POSE_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_arcface/arcface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ARCFACE_HPP 2 | #define ARCFACE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace Arcface{ 11 | 12 | using namespace std; 13 | 14 | struct landmarks{ 15 | float points[10]; 16 | }; 17 | 18 | typedef cv::Mat_ feature; 19 | typedef tuple commit_input; 20 | 21 | class Infer{ 22 | public: 23 | virtual shared_future commit (const commit_input& input) = 0; 24 | virtual vector> commits(const vector& inputs) = 0; 25 | }; 26 | 27 | cv::Mat face_alignment(const cv::Mat& image, const landmarks& landmark); 28 | shared_ptr create_infer(const string& engine_file, int gpuid=0); 29 | 30 | }; // namespace RetinaFace 31 | 32 | #endif // ARCFACE_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_cat/yolo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef YOLO_HPP 2 | #define YOLO_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @brief 发挥极致的性能体验 14 | * 支持YoloX和YoloV5 15 | */ 16 | namespace CatYolo{ 17 | 18 | using namespace std; 19 | using namespace ObjectDetector; 20 | 21 | enum class Type : int{ 22 | V5 = 0, 23 | X = 1 24 | }; 25 | 26 | void image_to_tensor(const cv::Mat& image, shared_ptr& tensor, Type type, int ibatch); 27 | 28 | class Infer{ 29 | public: 30 | virtual shared_future commit(const cv::Mat& image) = 0; 31 | virtual vector> commits(const vector& images) = 0; 32 | }; 33 | 34 | shared_ptr create_infer(const string& engine_file, Type type, int gpuid, float confidence_threshold=0.25f, float nms_threshold=0.5f); 35 | const char* type_name(Type type); 36 | 37 | }; // namespace Yolo 38 | 39 | #endif // YOLO_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_centernet/centernet.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CENTERNET_HPP 2 | #define CENTERNET_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace CenterNet{ 13 | 14 | using namespace std; 15 | using namespace ObjectDetector; 16 | 17 | void image_to_tensor(const cv::Mat& image, shared_ptr& tensor, int ibatch); 18 | 19 | class Infer{ 20 | public: 21 | virtual shared_future commit(const cv::Mat& image) = 0; 22 | virtual vector> commits(const vector& images) = 0; 23 | }; 24 | 25 | shared_ptr create_infer(const string& engine_file, int gpuid, float confidence_threshold=0.25f, float nms_threshold=0.5f); 26 | 27 | }; // namespace CenterNet 28 | 29 | 30 | #endif // CENTERNET_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_dbface/dbface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DBFACE_HPP 2 | #define DBFACE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace DBFace{ 13 | 14 | using namespace std; 15 | using namespace FaceDetector; 16 | 17 | void image_to_tensor(const cv::Mat& image, shared_ptr& tensor, int ibatch); 18 | 19 | class Infer{ 20 | public: 21 | virtual shared_future commit(const cv::Mat& image) = 0; 22 | virtual vector> commits(const vector& images) = 0; 23 | }; 24 | 25 | shared_ptr create_infer(const string& engine_file, int gpuid, float confidence_threshold=0.25f, float nms_threshold=0.5f); 26 | 27 | }; // namespace CenterNet 28 | 29 | 30 | #endif // DBFACE_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_fall_gcn/fall_gcn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FALL_GCN_HPP 2 | #define FALL_GCN_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace FallGCN{ 11 | 12 | using namespace std; 13 | using namespace cv; 14 | 15 | typedef tuple, Rect> Input; 16 | 17 | enum class FallState : int{ 18 | Fall = 0, 19 | Stand = 1, 20 | UnCertain = 2 21 | }; 22 | 23 | const char* state_name(FallState state); 24 | 25 | class Infer{ 26 | public: 27 | virtual shared_future> commit(const Input& input) = 0; 28 | virtual vector>> commits(const vector& inputs) = 0; 29 | }; 30 | 31 | shared_ptr create_infer(const string& engine_file, int gpuid); 32 | 33 | }; // namespace AlphaPose 34 | 35 | #endif // FALL_GCN_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_fasterrcnn/fasterrcnn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef YOLO_HPP 2 | #define YOLO_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @brief 发挥极致的性能体验 14 | * 支持YoloX和YoloV5 15 | */ 16 | namespace FasterRCNN{ 17 | 18 | using namespace std; 19 | using namespace ObjectDetector; 20 | 21 | enum class Type : int{ 22 | FasterRCNN = 0, 23 | }; 24 | 25 | void image_to_tensor(const cv::Mat& image, shared_ptr& tensor, Type type, int ibatch); 26 | 27 | class Infer{ 28 | public: 29 | virtual shared_future commit(const cv::Mat& image) = 0; 30 | virtual vector> commits(const vector& images) = 0; 31 | }; 32 | 33 | shared_ptr create_infer(const vector& engine_file, Type type, int gpuid, float confidence_threshold=0.25f, float nms_threshold=0.5f); 34 | const char* type_name(Type type); 35 | 36 | }; // namespace Yolo 37 | 38 | #endif // YOLO_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_high_performance/alpha_pose_high_perf.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ALPHA_POSE_HIGH_PERF_HPP 2 | #define ALPHA_POSE_HIGH_PERF_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "high_performance.hpp" 10 | 11 | namespace AlphaPoseHighPerf{ 12 | 13 | using namespace std; 14 | using namespace cv; 15 | using namespace HighPerformance; 16 | 17 | typedef tuple Input; 18 | 19 | class PointArray : public Data, public vector{ 20 | public: 21 | SetupData(PointArray); 22 | }; 23 | 24 | class Infer{ 25 | public: 26 | virtual shared_future commit(const Input& input) = 0; 27 | virtual vector> commits(const vector& inputs) = 0; 28 | }; 29 | 30 | shared_ptr create_infer(const string& engine_file, int gpuid); 31 | 32 | }; // namespace AlphaPose 33 | 34 | #endif // ALPHA_POSE_HIGH_PERF_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_high_performance/yolo_high_perf.hpp: -------------------------------------------------------------------------------- 1 | #ifndef YOLO_HIGHPERF_HPP 2 | #define YOLO_HIGHPERF_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "high_performance.hpp" 10 | 11 | /** 12 | * @brief 发挥极致的性能体验 13 | * 支持YoloX和YoloV5 14 | */ 15 | namespace YoloHighPerf{ 16 | 17 | using namespace std; 18 | using namespace HighPerformance; 19 | 20 | enum class Type : int{ 21 | V5 = 0, 22 | X = 1 23 | }; 24 | 25 | struct Box{ 26 | float left, top, right, bottom, confidence; 27 | int class_label; 28 | 29 | Box() = default; 30 | 31 | Box(float left, float top, float right, float bottom, float confidence, int class_label) 32 | :left(left), top(top), right(right), bottom(bottom), confidence(confidence), class_label(class_label){} 33 | }; 34 | 35 | class BoxArray : public Data, public vector{ 36 | public: 37 | SetupData(BoxArray); 38 | }; 39 | 40 | class Infer{ 41 | public: 42 | virtual shared_future commit(const cv::Mat& image) = 0; 43 | virtual vector> commits(const vector& images) = 0; 44 | }; 45 | 46 | shared_ptr create_infer(const string& engine_file, Type type, int gpuid, float confidence_threshold=0.25f, float nms_threshold=0.5f); 47 | const char* type_name(Type type); 48 | 49 | }; // namespace Yolo 50 | 51 | #endif // YOLO_HIGHPERF_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_retinaface/retinaface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RETINAFACE_HPP 2 | #define RETINAFACE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "../common/face_detector.hpp" 10 | 11 | namespace RetinaFace{ 12 | 13 | using namespace std; 14 | using namespace FaceDetector; 15 | 16 | class Infer{ 17 | public: 18 | virtual shared_future commit(const cv::Mat& image) = 0; 19 | virtual vector> commits(const vector& images) = 0; 20 | 21 | }; 22 | 23 | tuple crop_face_and_landmark( 24 | const cv::Mat& image, const Box& box, float scale_box=1.5f 25 | ); 26 | 27 | shared_ptr create_infer(const string& engine_file, int gpuid, float confidence_threshold=0.5f, float nms_threshold=0.5f); 28 | 29 | }; // namespace RetinaFace 30 | 31 | #endif // RETINAFACE_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_scrfd/scrfd.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SCRFD_HPP 2 | #define SCRFD_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "../common/face_detector.hpp" 10 | 11 | namespace Scrfd{ 12 | 13 | using namespace std; 14 | using namespace FaceDetector; 15 | 16 | class Infer{ 17 | public: 18 | virtual shared_future commit(const cv::Mat& image) = 0; 19 | virtual vector> commits(const vector& images) = 0; 20 | }; 21 | 22 | tuple crop_face_and_landmark( 23 | const cv::Mat& image, const Box& box, float scale_box=1.5f 24 | ); 25 | 26 | shared_ptr create_infer(const string& engine_file, int gpuid, float confidence_threshold=0.5f, float nms_threshold=0.5f); 27 | 28 | }; // namespace Scrfd 29 | 30 | #endif // SCRFD_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_shufflenet/shufflenetv2.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SHUFFLENETV2 2 | #define SHUFFLENETV2 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | namespace ShuffleNetV2 { 13 | 14 | using namespace std; 15 | 16 | void image_to_tensor(const cv::Mat& image, shared_ptr& tensor, int ibatch); 17 | 18 | class Infer{ 19 | public: 20 | virtual shared_future> commit(const cv::Mat& image) = 0; 21 | virtual vector>> commits(const vector& images) = 0; 22 | }; 23 | 24 | shared_ptr create_infer(const string& engine_file,int gpu_id = 0); 25 | 26 | }; // namespace Yolo 27 | 28 | #endif // YOLO_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_yolo/yolo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef YOLO_HPP 2 | #define YOLO_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @brief 发挥极致的性能体验 14 | * 支持YoloX和YoloV5 15 | */ 16 | namespace Yolo{ 17 | 18 | using namespace std; 19 | using namespace ObjectDetector; 20 | 21 | enum class Type : int{ 22 | V5 = 0, 23 | X = 1 24 | }; 25 | 26 | void image_to_tensor(const cv::Mat& image, shared_ptr& tensor, Type type, int ibatch); 27 | 28 | class Infer{ 29 | public: 30 | virtual shared_future commit(const cv::Mat& image) = 0; 31 | virtual vector> commits(const vector& images) = 0; 32 | }; 33 | 34 | shared_ptr create_infer(const string& engine_file, Type type, int gpuid, float confidence_threshold=0.25f, float nms_threshold=0.5f); 35 | const char* type_name(Type type); 36 | 37 | }; // namespace Yolo 38 | 39 | #endif // YOLO_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/app_yolo_fast/yolo_fast.hpp: -------------------------------------------------------------------------------- 1 | #ifndef YOLO_FAST_HPP 2 | #define YOLO_FAST_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @brief 发挥极致的性能体验 14 | * 支持YoloX和YoloV5 15 | */ 16 | namespace YoloFast{ 17 | 18 | using namespace std; 19 | using namespace ObjectDetector; 20 | 21 | enum class Type : int{ 22 | V5_P5 = 0, 23 | V5_P6 = 1, 24 | X = 2 25 | }; 26 | 27 | struct DecodeMeta{ 28 | int num_anchor; 29 | int num_level; 30 | float w[16], h[16]; 31 | int strides[16]; 32 | 33 | static DecodeMeta v5_p5_default_meta(); 34 | static DecodeMeta v5_p6_default_meta(); 35 | static DecodeMeta x_default_meta(); 36 | }; 37 | 38 | class Infer{ 39 | public: 40 | virtual shared_future commit(const cv::Mat& image) = 0; 41 | virtual vector> commits(const vector& images) = 0; 42 | }; 43 | 44 | void image_to_tensor(const cv::Mat& image, shared_ptr& tensor, Type type, int ibatch); 45 | 46 | shared_ptr create_infer( 47 | const string& engine_file, 48 | Type type, 49 | int gpuid, 50 | float confidence_threshold=0.25f, 51 | float nms_threshold=0.5f, 52 | const DecodeMeta& meta = DecodeMeta::v5_p5_default_meta() 53 | ); 54 | const char* type_name(Type type); 55 | 56 | }; // namespace YoloFast 57 | 58 | #endif // YOLO_FAST_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/common/face_detector.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FACE_DETECTOR_HPP 2 | #define FACE_DETECTOR_HPP 3 | 4 | #include 5 | #include 6 | 7 | namespace FaceDetector{ 8 | 9 | struct Box{ 10 | float left, top, right, bottom, confidence; 11 | float landmark[10]; 12 | 13 | cv::Rect cvbox() const{return cv::Rect(left, top, right-left, bottom-top);} 14 | float width() const{return std::max(0.0f, right-left);} 15 | float height() const{return std::max(0.0f, bottom-top);} 16 | float area() const{return width() * height();} 17 | float get_left() {return left;} 18 | void set_left(float value) {left = value;} 19 | float get_top() {return top;} 20 | void set_top(float value) {top = value;} 21 | float get_right() {return right;} 22 | void set_right(float value) {right = value;} 23 | float get_bottom() {return bottom;} 24 | void set_bottom(float value) {bottom = value;} 25 | float get_confidence() {return confidence;} 26 | void set_confidence(float value){confidence = value;} 27 | }; 28 | 29 | typedef std::vector BoxArray; 30 | }; 31 | 32 | #endif // FACE_DETECTOR_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/common/object_detector.hpp: -------------------------------------------------------------------------------- 1 | #ifndef OBJECT_DETECTOR_HPP 2 | #define OBJECT_DETECTOR_HPP 3 | 4 | #include 5 | 6 | namespace ObjectDetector { 7 | 8 | struct Box{ 9 | float left, top, right, bottom, confidence; 10 | int class_label; 11 | 12 | Box() = default; 13 | 14 | Box(float left, float top, float right, float bottom, float confidence, int class_label) 15 | :left(left), top(top), right(right), bottom(bottom), confidence(confidence), class_label(class_label){} 16 | }; 17 | 18 | typedef std::vector BoxArray; 19 | }; 20 | 21 | 22 | #endif // OBJECT_DETECTOR_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(RegexUtils) 2 | test_escape_string_as_regex() 3 | 4 | file(GLOB Eigen_directory_files "*") 5 | 6 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 7 | 8 | foreach(f ${Eigen_directory_files}) 9 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src") 10 | list(APPEND Eigen_directory_files_to_install ${f}) 11 | endif() 12 | endforeach(f ${Eigen_directory_files}) 13 | 14 | install(FILES 15 | ${Eigen_directory_files_to_install} 16 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel 17 | ) 18 | 19 | install(DIRECTORY src DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel FILES_MATCHING PATTERN "*.h") 20 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/Cholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLESKY_MODULE_H 9 | #define EIGEN_CHOLESKY_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Cholesky_Module Cholesky module 16 | * 17 | * 18 | * 19 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 20 | * Those decompositions are also accessible via the following methods: 21 | * - MatrixBase::llt() 22 | * - MatrixBase::ldlt() 23 | * - SelfAdjointView::llt() 24 | * - SelfAdjointView::ldlt() 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | */ 30 | 31 | #include "src/Cholesky/LLT.h" 32 | #include "src/Cholesky/LDLT.h" 33 | #ifdef EIGEN_USE_LAPACKE 34 | #include "src/misc/lapacke.h" 35 | #include "src/Cholesky/LLT_LAPACKE.h" 36 | #endif 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_CHOLESKY_MODULE_H 41 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 42 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/CholmodSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H 9 | #define EIGEN_CHOLMODSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup CholmodSupport_Module CholmodSupport module 21 | * 22 | * This module provides an interface to the Cholmod library which is part of the suitesparse package. 23 | * It provides the two following main factorization classes: 24 | * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization. 25 | * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial). 26 | * 27 | * For the sake of completeness, this module also propose the two following classes: 28 | * - class CholmodSimplicialLLT 29 | * - class CholmodSimplicialLDLT 30 | * Note that these classes does not bring any particular advantage compared to the built-in 31 | * SimplicialLLT and SimplicialLDLT factorization classes. 32 | * 33 | * \code 34 | * #include 35 | * \endcode 36 | * 37 | * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies. 38 | * The dependencies depend on how cholmod has been compiled. 39 | * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task. 40 | * 41 | */ 42 | 43 | #include "src/CholmodSupport/CholmodSupport.h" 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_CHOLMODSUPPORT_MODULE_H 48 | 49 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | #include "Sparse" 3 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/Eigenvalues: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_EIGENVALUES_MODULE_H 9 | #define EIGEN_EIGENVALUES_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Cholesky" 16 | #include "Jacobi" 17 | #include "Householder" 18 | #include "LU" 19 | #include "Geometry" 20 | 21 | /** \defgroup Eigenvalues_Module Eigenvalues module 22 | * 23 | * 24 | * 25 | * This module mainly provides various eigenvalue solvers. 26 | * This module also provides some MatrixBase methods, including: 27 | * - MatrixBase::eigenvalues(), 28 | * - MatrixBase::operatorNorm() 29 | * 30 | * \code 31 | * #include 32 | * \endcode 33 | */ 34 | 35 | #include "src/misc/RealSvd2x2.h" 36 | #include "src/Eigenvalues/Tridiagonalization.h" 37 | #include "src/Eigenvalues/RealSchur.h" 38 | #include "src/Eigenvalues/EigenSolver.h" 39 | #include "src/Eigenvalues/SelfAdjointEigenSolver.h" 40 | #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" 41 | #include "src/Eigenvalues/HessenbergDecomposition.h" 42 | #include "src/Eigenvalues/ComplexSchur.h" 43 | #include "src/Eigenvalues/ComplexEigenSolver.h" 44 | #include "src/Eigenvalues/RealQZ.h" 45 | #include "src/Eigenvalues/GeneralizedEigenSolver.h" 46 | #include "src/Eigenvalues/MatrixBaseEigenvalues.h" 47 | #ifdef EIGEN_USE_LAPACKE 48 | #include "src/misc/lapacke.h" 49 | #include "src/Eigenvalues/RealSchur_LAPACKE.h" 50 | #include "src/Eigenvalues/ComplexSchur_LAPACKE.h" 51 | #include "src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h" 52 | #endif 53 | 54 | #include "src/Core/util/ReenableStupidWarnings.h" 55 | 56 | #endif // EIGEN_EIGENVALUES_MODULE_H 57 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 58 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/Geometry: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_GEOMETRY_MODULE_H 9 | #define EIGEN_GEOMETRY_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "SVD" 16 | #include "LU" 17 | #include 18 | 19 | /** \defgroup Geometry_Module Geometry module 20 | * 21 | * This module provides support for: 22 | * - fixed-size homogeneous transformations 23 | * - translation, scaling, 2D and 3D rotations 24 | * - \link Quaternion quaternions \endlink 25 | * - cross products (\ref MatrixBase::cross, \ref MatrixBase::cross3) 26 | * - orthognal vector generation (\ref MatrixBase::unitOrthogonal) 27 | * - some linear components: \link ParametrizedLine parametrized-lines \endlink and \link Hyperplane hyperplanes \endlink 28 | * - \link AlignedBox axis aligned bounding boxes \endlink 29 | * - \link umeyama least-square transformation fitting \endlink 30 | * 31 | * \code 32 | * #include 33 | * \endcode 34 | */ 35 | 36 | #include "src/Geometry/OrthoMethods.h" 37 | #include "src/Geometry/EulerAngles.h" 38 | 39 | #include "src/Geometry/Homogeneous.h" 40 | #include "src/Geometry/RotationBase.h" 41 | #include "src/Geometry/Rotation2D.h" 42 | #include "src/Geometry/Quaternion.h" 43 | #include "src/Geometry/AngleAxis.h" 44 | #include "src/Geometry/Transform.h" 45 | #include "src/Geometry/Translation.h" 46 | #include "src/Geometry/Scaling.h" 47 | #include "src/Geometry/Hyperplane.h" 48 | #include "src/Geometry/ParametrizedLine.h" 49 | #include "src/Geometry/AlignedBox.h" 50 | #include "src/Geometry/Umeyama.h" 51 | 52 | // Use the SSE optimized version whenever possible. At the moment the 53 | // SSE version doesn't compile when AVX is enabled 54 | #if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX 55 | #include "src/Geometry/arch/Geometry_SSE.h" 56 | #endif 57 | 58 | #include "src/Core/util/ReenableStupidWarnings.h" 59 | 60 | #endif // EIGEN_GEOMETRY_MODULE_H 61 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 62 | 63 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/Householder: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 9 | #define EIGEN_HOUSEHOLDER_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Householder_Module Householder module 16 | * This module provides Householder transformations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/Householder/Householder.h" 24 | #include "src/Householder/HouseholderSequence.h" 25 | #include "src/Householder/BlockHouseholder.h" 26 | 27 | #include "src/Core/util/ReenableStupidWarnings.h" 28 | 29 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 30 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 31 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/IterativeLinearSolvers: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 9 | #define EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | 14 | #include "src/Core/util/DisableStupidWarnings.h" 15 | 16 | /** 17 | * \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module 18 | * 19 | * This module currently provides iterative methods to solve problems of the form \c A \c x = \c b, where \c A is a squared matrix, usually very large and sparse. 20 | * Those solvers are accessible via the following classes: 21 | * - ConjugateGradient for selfadjoint (hermitian) matrices, 22 | * - LeastSquaresConjugateGradient for rectangular least-square problems, 23 | * - BiCGSTAB for general square matrices. 24 | * 25 | * These iterative solvers are associated with some preconditioners: 26 | * - IdentityPreconditioner - not really useful 27 | * - DiagonalPreconditioner - also called Jacobi preconditioner, work very well on diagonal dominant matrices. 28 | * - IncompleteLUT - incomplete LU factorization with dual thresholding 29 | * 30 | * Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport. 31 | * 32 | \code 33 | #include 34 | \endcode 35 | */ 36 | 37 | #include "src/IterativeLinearSolvers/SolveWithGuess.h" 38 | #include "src/IterativeLinearSolvers/IterativeSolverBase.h" 39 | #include "src/IterativeLinearSolvers/BasicPreconditioners.h" 40 | #include "src/IterativeLinearSolvers/ConjugateGradient.h" 41 | #include "src/IterativeLinearSolvers/LeastSquareConjugateGradient.h" 42 | #include "src/IterativeLinearSolvers/BiCGSTAB.h" 43 | #include "src/IterativeLinearSolvers/IncompleteLUT.h" 44 | #include "src/IterativeLinearSolvers/IncompleteCholesky.h" 45 | 46 | #include "src/Core/util/ReenableStupidWarnings.h" 47 | 48 | #endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 49 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/Jacobi: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_JACOBI_MODULE_H 9 | #define EIGEN_JACOBI_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Jacobi_Module Jacobi module 16 | * This module provides Jacobi and Givens rotations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | * 22 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 23 | * - MatrixBase::applyOnTheLeft() 24 | * - MatrixBase::applyOnTheRight(). 25 | */ 26 | 27 | #include "src/Jacobi/Jacobi.h" 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif // EIGEN_JACOBI_MODULE_H 32 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 33 | 34 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/LU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_LU_MODULE_H 9 | #define EIGEN_LU_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup LU_Module LU module 16 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 17 | * This module defines the following MatrixBase methods: 18 | * - MatrixBase::inverse() 19 | * - MatrixBase::determinant() 20 | * 21 | * \code 22 | * #include 23 | * \endcode 24 | */ 25 | 26 | #include "src/misc/Kernel.h" 27 | #include "src/misc/Image.h" 28 | #include "src/LU/FullPivLU.h" 29 | #include "src/LU/PartialPivLU.h" 30 | #ifdef EIGEN_USE_LAPACKE 31 | #include "src/misc/lapacke.h" 32 | #include "src/LU/PartialPivLU_LAPACKE.h" 33 | #endif 34 | #include "src/LU/Determinant.h" 35 | #include "src/LU/InverseImpl.h" 36 | 37 | // Use the SSE optimized version whenever possible. At the moment the 38 | // SSE version doesn't compile when AVX is enabled 39 | #if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX 40 | #include "src/LU/arch/Inverse_SSE.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_LU_MODULE_H 46 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 47 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/MetisSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_METISSUPPORT_MODULE_H 9 | #define EIGEN_METISSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | 20 | /** \ingroup Support_modules 21 | * \defgroup MetisSupport_Module MetisSupport module 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). 27 | * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink 28 | */ 29 | 30 | 31 | #include "src/MetisSupport/MetisSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_METISSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/PaStiXSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PASTIXSUPPORT_MODULE_H 9 | #define EIGEN_PASTIXSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | #include 18 | } 19 | 20 | #ifdef complex 21 | #undef complex 22 | #endif 23 | 24 | /** \ingroup Support_modules 25 | * \defgroup PaStiXSupport_Module PaStiXSupport module 26 | * 27 | * This module provides an interface to the PaSTiX library. 28 | * PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver. 29 | * It provides the two following main factorization classes: 30 | * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization. 31 | * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization. 32 | * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern). 33 | * 34 | * \code 35 | * #include 36 | * \endcode 37 | * 38 | * In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies. 39 | * The dependencies depend on how PaSTiX has been compiled. 40 | * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task. 41 | * 42 | */ 43 | 44 | #include "src/PaStiXSupport/PaStiXSupport.h" 45 | 46 | #include "src/Core/util/ReenableStupidWarnings.h" 47 | 48 | #endif // EIGEN_PASTIXSUPPORT_MODULE_H 49 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/PardisoSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PARDISOSUPPORT_MODULE_H 9 | #define EIGEN_PARDISOSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup PardisoSupport_Module PardisoSupport module 19 | * 20 | * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies. 27 | * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration. 28 | * 29 | */ 30 | 31 | #include "src/PardisoSupport/PardisoSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_PARDISOSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/QR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QR_MODULE_H 9 | #define EIGEN_QR_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Cholesky" 16 | #include "Jacobi" 17 | #include "Householder" 18 | 19 | /** \defgroup QR_Module QR module 20 | * 21 | * 22 | * 23 | * This module provides various QR decompositions 24 | * This module also provides some MatrixBase methods, including: 25 | * - MatrixBase::householderQr() 26 | * - MatrixBase::colPivHouseholderQr() 27 | * - MatrixBase::fullPivHouseholderQr() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/QR/HouseholderQR.h" 35 | #include "src/QR/FullPivHouseholderQR.h" 36 | #include "src/QR/ColPivHouseholderQR.h" 37 | #include "src/QR/CompleteOrthogonalDecomposition.h" 38 | #ifdef EIGEN_USE_LAPACKE 39 | #include "src/misc/lapacke.h" 40 | #include "src/QR/HouseholderQR_LAPACKE.h" 41 | #include "src/QR/ColPivHouseholderQR_LAPACKE.h" 42 | #endif 43 | 44 | #include "src/Core/util/ReenableStupidWarnings.h" 45 | 46 | #endif // EIGEN_QR_MODULE_H 47 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 48 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QTMALLOC_MODULE_H 9 | #define EIGEN_QTMALLOC_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | void *qMalloc(std::size_t size) 18 | { 19 | return Eigen::internal::aligned_malloc(size); 20 | } 21 | 22 | void qFree(void *ptr) 23 | { 24 | Eigen::internal::aligned_free(ptr); 25 | } 26 | 27 | void *qRealloc(void *ptr, std::size_t size) 28 | { 29 | void* newPtr = Eigen::internal::aligned_malloc(size); 30 | memcpy(newPtr, ptr, size); 31 | Eigen::internal::aligned_free(ptr); 32 | return newPtr; 33 | } 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | 39 | #endif // EIGEN_QTMALLOC_MODULE_H 40 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 41 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/SPQRSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPQRSUPPORT_MODULE_H 9 | #define EIGEN_SPQRSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "SuiteSparseQR.hpp" 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup SPQRSupport_Module SuiteSparseQR module 19 | * 20 | * This module provides an interface to the SPQR library, which is part of the suitesparse package. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...). 27 | * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules 28 | * 29 | */ 30 | 31 | #include "src/CholmodSupport/CholmodSupport.h" 32 | #include "src/SPQRSupport/SuiteSparseQRSupport.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/SVD: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SVD_MODULE_H 9 | #define EIGEN_SVD_MODULE_H 10 | 11 | #include "QR" 12 | #include "Householder" 13 | #include "Jacobi" 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | /** \defgroup SVD_Module SVD module 18 | * 19 | * 20 | * 21 | * This module provides SVD decomposition for matrices (both real and complex). 22 | * Two decomposition algorithms are provided: 23 | * - JacobiSVD implementing two-sided Jacobi iterations is numerically very accurate, fast for small matrices, but very slow for larger ones. 24 | * - BDCSVD implementing a recursive divide & conquer strategy on top of an upper-bidiagonalization which remains fast for large problems. 25 | * These decompositions are accessible via the respective classes and following MatrixBase methods: 26 | * - MatrixBase::jacobiSvd() 27 | * - MatrixBase::bdcSvd() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/misc/RealSvd2x2.h" 35 | #include "src/SVD/UpperBidiagonalization.h" 36 | #include "src/SVD/SVDBase.h" 37 | #include "src/SVD/JacobiSVD.h" 38 | #include "src/SVD/BDCSVD.h" 39 | #if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT) 40 | #include "src/misc/lapacke.h" 41 | #include "src/SVD/JacobiSVD_LAPACKE.h" 42 | #endif 43 | 44 | #include "src/Core/util/ReenableStupidWarnings.h" 45 | 46 | #endif // EIGEN_SVD_MODULE_H 47 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 48 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSE_MODULE_H 9 | #define EIGEN_SPARSE_MODULE_H 10 | 11 | /** \defgroup Sparse_Module Sparse meta-module 12 | * 13 | * Meta-module including all related modules: 14 | * - \ref SparseCore_Module 15 | * - \ref OrderingMethods_Module 16 | * - \ref SparseCholesky_Module 17 | * - \ref SparseLU_Module 18 | * - \ref SparseQR_Module 19 | * - \ref IterativeLinearSolvers_Module 20 | * 21 | \code 22 | #include 23 | \endcode 24 | */ 25 | 26 | #include "SparseCore" 27 | #include "OrderingMethods" 28 | #ifndef EIGEN_MPL2_ONLY 29 | #include "SparseCholesky" 30 | #endif 31 | #include "SparseLU" 32 | #include "SparseQR" 33 | #include "IterativeLinearSolvers" 34 | 35 | #endif // EIGEN_SPARSE_MODULE_H 36 | 37 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/SparseCholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2013 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSECHOLESKY_MODULE_H 11 | #define EIGEN_SPARSECHOLESKY_MODULE_H 12 | 13 | #include "SparseCore" 14 | #include "OrderingMethods" 15 | 16 | #include "src/Core/util/DisableStupidWarnings.h" 17 | 18 | /** 19 | * \defgroup SparseCholesky_Module SparseCholesky module 20 | * 21 | * This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices. 22 | * Those decompositions are accessible via the following classes: 23 | * - SimplicialLLt, 24 | * - SimplicialLDLt 25 | * 26 | * Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module. 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #ifdef EIGEN_MPL2_ONLY 34 | #error The SparseCholesky module has nothing to offer in MPL2 only mode 35 | #endif 36 | 37 | #include "src/SparseCholesky/SimplicialCholesky.h" 38 | 39 | #ifndef EIGEN_MPL2_ONLY 40 | #include "src/SparseCholesky/SimplicialCholesky_impl.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_SPARSECHOLESKY_MODULE_H 46 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/SparseLU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // Copyright (C) 2012 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_SPARSELU_MODULE_H 12 | #define EIGEN_SPARSELU_MODULE_H 13 | 14 | #include "SparseCore" 15 | 16 | /** 17 | * \defgroup SparseLU_Module SparseLU module 18 | * This module defines a supernodal factorization of general sparse matrices. 19 | * The code is fully optimized for supernode-panel updates with specialized kernels. 20 | * Please, see the documentation of the SparseLU class for more details. 21 | */ 22 | 23 | // Ordering interface 24 | #include "OrderingMethods" 25 | 26 | #include "src/SparseLU/SparseLU_gemm_kernel.h" 27 | 28 | #include "src/SparseLU/SparseLU_Structs.h" 29 | #include "src/SparseLU/SparseLU_SupernodalMatrix.h" 30 | #include "src/SparseLU/SparseLUImpl.h" 31 | #include "src/SparseCore/SparseColEtree.h" 32 | #include "src/SparseLU/SparseLU_Memory.h" 33 | #include "src/SparseLU/SparseLU_heap_relax_snode.h" 34 | #include "src/SparseLU/SparseLU_relax_snode.h" 35 | #include "src/SparseLU/SparseLU_pivotL.h" 36 | #include "src/SparseLU/SparseLU_panel_dfs.h" 37 | #include "src/SparseLU/SparseLU_kernel_bmod.h" 38 | #include "src/SparseLU/SparseLU_panel_bmod.h" 39 | #include "src/SparseLU/SparseLU_column_dfs.h" 40 | #include "src/SparseLU/SparseLU_column_bmod.h" 41 | #include "src/SparseLU/SparseLU_copy_to_ucol.h" 42 | #include "src/SparseLU/SparseLU_pruneL.h" 43 | #include "src/SparseLU/SparseLU_Utils.h" 44 | #include "src/SparseLU/SparseLU.h" 45 | 46 | #endif // EIGEN_SPARSELU_MODULE_H 47 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/SparseQR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSEQR_MODULE_H 9 | #define EIGEN_SPARSEQR_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup SparseQR_Module SparseQR module 16 | * \brief Provides QR decomposition for sparse matrices 17 | * 18 | * This module provides a simplicial version of the left-looking Sparse QR decomposition. 19 | * The columns of the input matrix should be reordered to limit the fill-in during the 20 | * decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end. 21 | * See the \link OrderingMethods_Module OrderingMethods\endlink module for the list 22 | * of built-in and external ordering methods. 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | * 28 | * 29 | */ 30 | 31 | #include "OrderingMethods" 32 | #include "src/SparseCore/SparseColEtree.h" 33 | #include "src/SparseQR/SparseQR.h" 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/StdDeque: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDDEQUE_MODULE_H 12 | #define EIGEN_STDDEQUE_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdDeque.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDDEQUE_MODULE_H 28 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/StdList: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Hauke Heibel 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_STDLIST_MODULE_H 11 | #define EIGEN_STDLIST_MODULE_H 12 | 13 | #include "Core" 14 | #include 15 | 16 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 17 | 18 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 19 | 20 | #else 21 | 22 | #include "src/StlSupport/StdList.h" 23 | 24 | #endif 25 | 26 | #endif // EIGEN_STDLIST_MODULE_H 27 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/StdVector: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDVECTOR_MODULE_H 12 | #define EIGEN_STDVECTOR_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdVector.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDVECTOR_MODULE_H 28 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/UmfPackSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_UMFPACKSUPPORT_MODULE_H 9 | #define EIGEN_UMFPACKSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup UmfPackSupport_Module UmfPackSupport module 21 | * 22 | * This module provides an interface to the UmfPack library which is part of the suitesparse package. 23 | * It provides the following factorization class: 24 | * - class UmfPackLU: a multifrontal sequential LU factorization. 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | * 30 | * In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies. 31 | * The dependencies depend on how umfpack has been compiled. 32 | * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task. 33 | * 34 | */ 35 | 36 | #include "src/UmfPackSupport/UmfPackSupport.h" 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_UMFPACKSUPPORT_MODULE_H 41 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/src/Core/DiagonalProduct.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2007-2009 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_DIAGONALPRODUCT_H 12 | #define EIGEN_DIAGONALPRODUCT_H 13 | 14 | namespace Eigen { 15 | 16 | /** \returns the diagonal matrix product of \c *this by the diagonal matrix \a diagonal. 17 | */ 18 | template 19 | template 20 | inline const Product 21 | MatrixBase::operator*(const DiagonalBase &a_diagonal) const 22 | { 23 | return Product(derived(),a_diagonal.derived()); 24 | } 25 | 26 | } // end namespace Eigen 27 | 28 | #endif // EIGEN_DIAGONALPRODUCT_H 29 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/src/Core/SelfCwiseBinaryOp.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SELFCWISEBINARYOP_H 11 | #define EIGEN_SELFCWISEBINARYOP_H 12 | 13 | namespace Eigen { 14 | 15 | // TODO generalize the scalar type of 'other' 16 | 17 | template 18 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator*=(const Scalar& other) 19 | { 20 | typedef typename Derived::PlainObject PlainObject; 21 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::mul_assign_op()); 22 | return derived(); 23 | } 24 | 25 | template 26 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase::operator+=(const Scalar& other) 27 | { 28 | typedef typename Derived::PlainObject PlainObject; 29 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::add_assign_op()); 30 | return derived(); 31 | } 32 | 33 | template 34 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase::operator-=(const Scalar& other) 35 | { 36 | typedef typename Derived::PlainObject PlainObject; 37 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::sub_assign_op()); 38 | return derived(); 39 | } 40 | 41 | template 42 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator/=(const Scalar& other) 43 | { 44 | typedef typename Derived::PlainObject PlainObject; 45 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::div_assign_op()); 46 | return derived(); 47 | } 48 | 49 | } // end namespace Eigen 50 | 51 | #endif // EIGEN_SELFCWISEBINARYOP_H 52 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/src/Core/arch/AVX/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2015 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_AVX_H 11 | #define EIGEN_TYPE_CASTING_AVX_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | // For now we use SSE to handle integers, so we can't use AVX instructions to cast 18 | // from int to float 19 | template <> 20 | struct type_casting_traits { 21 | enum { 22 | VectorizedCast = 0, 23 | SrcCoeffRatio = 1, 24 | TgtCoeffRatio = 1 25 | }; 26 | }; 27 | 28 | template <> 29 | struct type_casting_traits { 30 | enum { 31 | VectorizedCast = 0, 32 | SrcCoeffRatio = 1, 33 | TgtCoeffRatio = 1 34 | }; 35 | }; 36 | 37 | 38 | 39 | template<> EIGEN_STRONG_INLINE Packet8i pcast(const Packet8f& a) { 40 | return _mm256_cvtps_epi32(a); 41 | } 42 | 43 | template<> EIGEN_STRONG_INLINE Packet8f pcast(const Packet8i& a) { 44 | return _mm256_cvtepi32_ps(a); 45 | } 46 | 47 | } // end namespace internal 48 | 49 | } // end namespace Eigen 50 | 51 | #endif // EIGEN_TYPE_CASTING_AVX_H 52 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/src/Core/arch/Default/Settings.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | 12 | /* All the parameters defined in this file can be specialized in the 13 | * architecture specific files, and/or by the user. 14 | * More to come... */ 15 | 16 | #ifndef EIGEN_DEFAULT_SETTINGS_H 17 | #define EIGEN_DEFAULT_SETTINGS_H 18 | 19 | /** Defines the maximal loop size to enable meta unrolling of loops. 20 | * Note that the value here is expressed in Eigen's own notion of "number of FLOPS", 21 | * it does not correspond to the number of iterations or the number of instructions 22 | */ 23 | #ifndef EIGEN_UNROLLING_LIMIT 24 | #define EIGEN_UNROLLING_LIMIT 100 25 | #endif 26 | 27 | /** Defines the threshold between a "small" and a "large" matrix. 28 | * This threshold is mainly used to select the proper product implementation. 29 | */ 30 | #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 31 | #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 32 | #endif 33 | 34 | /** Defines the maximal width of the blocks used in the triangular product and solver 35 | * for vectors (level 2 blas xTRMV and xTRSV). The default is 8. 36 | */ 37 | #ifndef EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 38 | #define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 8 39 | #endif 40 | 41 | 42 | /** Defines the default number of registers available for that architecture. 43 | * Currently it must be 8 or 16. Other values will fail. 44 | */ 45 | #ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 46 | #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 8 47 | #endif 48 | 49 | #endif // EIGEN_DEFAULT_SETTINGS_H 50 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/src/Core/arch/SSE/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2015 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_SSE_H 11 | #define EIGEN_TYPE_CASTING_SSE_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | template <> 18 | struct type_casting_traits { 19 | enum { 20 | VectorizedCast = 1, 21 | SrcCoeffRatio = 1, 22 | TgtCoeffRatio = 1 23 | }; 24 | }; 25 | 26 | template<> EIGEN_STRONG_INLINE Packet4i pcast(const Packet4f& a) { 27 | return _mm_cvttps_epi32(a); 28 | } 29 | 30 | 31 | template <> 32 | struct type_casting_traits { 33 | enum { 34 | VectorizedCast = 1, 35 | SrcCoeffRatio = 1, 36 | TgtCoeffRatio = 1 37 | }; 38 | }; 39 | 40 | template<> EIGEN_STRONG_INLINE Packet4f pcast(const Packet4i& a) { 41 | return _mm_cvtepi32_ps(a); 42 | } 43 | 44 | 45 | template <> 46 | struct type_casting_traits { 47 | enum { 48 | VectorizedCast = 1, 49 | SrcCoeffRatio = 2, 50 | TgtCoeffRatio = 1 51 | }; 52 | }; 53 | 54 | template<> EIGEN_STRONG_INLINE Packet4f pcast(const Packet2d& a, const Packet2d& b) { 55 | return _mm_shuffle_ps(_mm_cvtpd_ps(a), _mm_cvtpd_ps(b), (1 << 2) | (1 << 6)); 56 | } 57 | 58 | template <> 59 | struct type_casting_traits { 60 | enum { 61 | VectorizedCast = 1, 62 | SrcCoeffRatio = 1, 63 | TgtCoeffRatio = 2 64 | }; 65 | }; 66 | 67 | template<> EIGEN_STRONG_INLINE Packet2d pcast(const Packet4f& a) { 68 | // Simply discard the second half of the input 69 | return _mm_cvtps_pd(a); 70 | } 71 | 72 | 73 | } // end namespace internal 74 | 75 | } // end namespace Eigen 76 | 77 | #endif // EIGEN_TYPE_CASTING_SSE_H 78 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/src/Core/functors/TernaryFunctors.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Eugene Brevdo 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TERNARY_FUNCTORS_H 11 | #define EIGEN_TERNARY_FUNCTORS_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | //---------- associative ternary functors ---------- 18 | 19 | 20 | 21 | } // end namespace internal 22 | 23 | } // end namespace Eigen 24 | 25 | #endif // EIGEN_TERNARY_FUNCTORS_H 26 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/src/Core/util/NonMPL2.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_MPL2_ONLY 2 | #error Including non-MPL2 code in EIGEN_MPL2_ONLY mode 3 | #endif 4 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED 2 | #undef EIGEN_WARNINGS_DISABLED 3 | 4 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 5 | #ifdef _MSC_VER 6 | #pragma warning( pop ) 7 | #elif defined __INTEL_COMPILER 8 | #pragma warning pop 9 | #elif defined __clang__ 10 | #pragma clang diagnostic pop 11 | #elif defined __GNUC__ && __GNUC__>=6 12 | #pragma GCC diagnostic pop 13 | #endif 14 | 15 | #if defined __NVCC__ 16 | // Don't reenable the diagnostic messages, as it turns out these messages need 17 | // to be disabled at the point of the template instantiation (i.e the user code) 18 | // otherwise they'll be triggered by nvcc. 19 | // #pragma diag_default code_is_unreachable 20 | // #pragma diag_default initialization_not_reachable 21 | // #pragma diag_default 2651 22 | // #pragma diag_default 2653 23 | #endif 24 | 25 | #endif 26 | 27 | #endif // EIGEN_WARNINGS_DISABLED 28 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/src/SparseCore/SparseFuzzy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSE_FUZZY_H 11 | #define EIGEN_SPARSE_FUZZY_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | template 17 | bool SparseMatrixBase::isApprox(const SparseMatrixBase& other, const RealScalar &prec) const 18 | { 19 | const typename internal::nested_eval::type actualA(derived()); 20 | typename internal::conditional::type, 22 | const PlainObject>::type actualB(other.derived()); 23 | 24 | return (actualA - actualB).squaredNorm() <= prec * prec * numext::mini(actualA.squaredNorm(), actualB.squaredNorm()); 25 | } 26 | 27 | } // end namespace Eigen 28 | 29 | #endif // EIGEN_SPARSE_FUZZY_H 30 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/src/SparseCore/SparseRedux.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSEREDUX_H 11 | #define EIGEN_SPARSEREDUX_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | typename internal::traits::Scalar 17 | SparseMatrixBase::sum() const 18 | { 19 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 20 | Scalar res(0); 21 | internal::evaluator thisEval(derived()); 22 | for (Index j=0; j::InnerIterator iter(thisEval,j); iter; ++iter) 24 | res += iter.value(); 25 | return res; 26 | } 27 | 28 | template 29 | typename internal::traits >::Scalar 30 | SparseMatrix<_Scalar,_Options,_Index>::sum() const 31 | { 32 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 33 | if(this->isCompressed()) 34 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 35 | else 36 | return Base::sum(); 37 | } 38 | 39 | template 40 | typename internal::traits >::Scalar 41 | SparseVector<_Scalar,_Options,_Index>::sum() const 42 | { 43 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 44 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 45 | } 46 | 47 | } // end namespace Eigen 48 | 49 | #endif // EIGEN_SPARSEREDUX_H 50 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/src/SparseLU/SparseLU_Utils.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | 11 | #ifndef EIGEN_SPARSELU_UTILS_H 12 | #define EIGEN_SPARSELU_UTILS_H 13 | 14 | namespace Eigen { 15 | namespace internal { 16 | 17 | /** 18 | * \brief Count Nonzero elements in the factors 19 | */ 20 | template 21 | void SparseLUImpl::countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu) 22 | { 23 | nnzL = 0; 24 | nnzU = (glu.xusub)(n); 25 | Index nsuper = (glu.supno)(n); 26 | Index jlen; 27 | Index i, j, fsupc; 28 | if (n <= 0 ) return; 29 | // For each supernode 30 | for (i = 0; i <= nsuper; i++) 31 | { 32 | fsupc = glu.xsup(i); 33 | jlen = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); 34 | 35 | for (j = fsupc; j < glu.xsup(i+1); j++) 36 | { 37 | nnzL += jlen; 38 | nnzU += j - fsupc + 1; 39 | jlen--; 40 | } 41 | } 42 | } 43 | 44 | /** 45 | * \brief Fix up the data storage lsub for L-subscripts. 46 | * 47 | * It removes the subscripts sets for structural pruning, 48 | * and applies permutation to the remaining subscripts 49 | * 50 | */ 51 | template 52 | void SparseLUImpl::fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu) 53 | { 54 | Index fsupc, i, j, k, jstart; 55 | 56 | StorageIndex nextl = 0; 57 | Index nsuper = (glu.supno)(n); 58 | 59 | // For each supernode 60 | for (i = 0; i <= nsuper; i++) 61 | { 62 | fsupc = glu.xsup(i); 63 | jstart = glu.xlsub(fsupc); 64 | glu.xlsub(fsupc) = nextl; 65 | for (j = jstart; j < glu.xlsub(fsupc + 1); j++) 66 | { 67 | glu.lsub(nextl) = perm_r(glu.lsub(j)); // Now indexed into P*A 68 | nextl++; 69 | } 70 | for (k = fsupc+1; k < glu.xsup(i+1); k++) 71 | glu.xlsub(k) = nextl; // other columns in supernode i 72 | } 73 | 74 | glu.xlsub(n) = nextl; 75 | } 76 | 77 | } // end namespace internal 78 | 79 | } // end namespace Eigen 80 | #endif // EIGEN_SPARSELU_UTILS_H 81 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/src/misc/RealSvd2x2.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Benoit Jacob 5 | // Copyright (C) 2013-2016 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_REALSVD2X2_H 12 | #define EIGEN_REALSVD2X2_H 13 | 14 | namespace Eigen { 15 | 16 | namespace internal { 17 | 18 | template 19 | void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q, 20 | JacobiRotation *j_left, 21 | JacobiRotation *j_right) 22 | { 23 | using std::sqrt; 24 | using std::abs; 25 | Matrix m; 26 | m << numext::real(matrix.coeff(p,p)), numext::real(matrix.coeff(p,q)), 27 | numext::real(matrix.coeff(q,p)), numext::real(matrix.coeff(q,q)); 28 | JacobiRotation rot1; 29 | RealScalar t = m.coeff(0,0) + m.coeff(1,1); 30 | RealScalar d = m.coeff(1,0) - m.coeff(0,1); 31 | 32 | if(abs(d) < (std::numeric_limits::min)()) 33 | { 34 | rot1.s() = RealScalar(0); 35 | rot1.c() = RealScalar(1); 36 | } 37 | else 38 | { 39 | // If d!=0, then t/d cannot overflow because the magnitude of the 40 | // entries forming d are not too small compared to the ones forming t. 41 | RealScalar u = t / d; 42 | RealScalar tmp = sqrt(RealScalar(1) + numext::abs2(u)); 43 | rot1.s() = RealScalar(1) / tmp; 44 | rot1.c() = u / tmp; 45 | } 46 | m.applyOnTheLeft(0,1,rot1); 47 | j_right->makeJacobi(m,0,1); 48 | *j_left = rot1 * j_right->transpose(); 49 | } 50 | 51 | } // end namespace internal 52 | 53 | } // end namespace Eigen 54 | 55 | #endif // EIGEN_REALSVD2X2_H 56 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/Eigen/src/misc/lapacke_mangling.h: -------------------------------------------------------------------------------- 1 | #ifndef LAPACK_HEADER_INCLUDED 2 | #define LAPACK_HEADER_INCLUDED 3 | 4 | #ifndef LAPACK_GLOBAL 5 | #if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_) 6 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 7 | #elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER) 8 | #define LAPACK_GLOBAL(lcname,UCNAME) UCNAME 9 | #elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE) 10 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname 11 | #else 12 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 13 | #endif 14 | #endif 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/auto_download.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | bool requires(const char* name) { 8 | 9 | auto onnx_file = iLogger::format("%s.onnx", name); 10 | if (not iLogger::exists(onnx_file)) { 11 | INFO("Auto download %s", onnx_file.c_str()); 12 | system(iLogger::format("wget http://zifuture.com:1556/fs/25.shared/%s", onnx_file.c_str()).c_str()); 13 | } 14 | 15 | bool exists = iLogger::exists(onnx_file); 16 | if (not exists) { 17 | INFOE("Download %s failed", onnx_file.c_str()); 18 | } 19 | return exists; 20 | } -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/zmq_remote_show.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "zmq_remote_show.hpp" 3 | #include "zmq_u.hpp" 4 | #include 5 | 6 | using namespace std; 7 | 8 | class ZMQRemoteShowImpl : public ZMQRemoteShow{ 9 | public: 10 | bool listen(const char* url){ 11 | try{ 12 | context_.reset(new zmq::context_t()); 13 | socket_.reset(new zmq::socket_t(*context_.get(), zmq::socket_type::rep)); 14 | socket_->bind(url); 15 | return true; 16 | }catch(zmq::error_t err){ 17 | INFOE("ZMQ exception: %s", err.what()); 18 | socket_.reset(); 19 | context_.reset(); 20 | } 21 | return false; 22 | } 23 | 24 | virtual void post(const void* data, int size) override{ 25 | 26 | if(size < 1 || data == nullptr){ 27 | INFOE("Null data to post"); 28 | return; 29 | } 30 | 31 | zmq::message_t msg; 32 | socket_->recv(msg); 33 | socket_->send(zmq::message_t(data, size)); 34 | } 35 | 36 | virtual void post(const cv::Mat& image) override{ 37 | 38 | vector data; 39 | cv::imencode(".jpg", image, data); 40 | post(data.data(), data.size()); 41 | } 42 | 43 | private: 44 | shared_ptr context_; 45 | shared_ptr socket_; 46 | }; 47 | 48 | std::shared_ptr create_zmq_remote_show(const char* listen){ 49 | 50 | shared_ptr instance(new ZMQRemoteShowImpl()); 51 | if(!instance->listen(listen)){ 52 | instance.reset(); 53 | } 54 | return instance; 55 | } 56 | -------------------------------------------------------------------------------- /tensorrt_code/src/application/tools/zmq_remote_show.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef ZMQ_REMOTE_SHOW_HPP 4 | #define ZMQ_REMOTE_SHOW_HPP 5 | 6 | #include 7 | #include 8 | 9 | class ZMQRemoteShow{ 10 | public: 11 | virtual void post(const void* data, int size) = 0; 12 | virtual void post(const cv::Mat& image) = 0; 13 | }; 14 | 15 | std::shared_ptr create_zmq_remote_show(const char* listen="tcp://0.0.0.0:15556"); 16 | 17 | #endif // ZMQ_REMOTE_SHOW_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/common/cuda_tools.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * 系统关于CUDA的功能函数 4 | */ 5 | 6 | 7 | #include "cuda_tools.hpp" 8 | 9 | namespace CUDATools{ 10 | bool check_driver(CUresult e, const char* call, int line, const char *file) { 11 | if (e != CUDA_SUCCESS) { 12 | 13 | const char* message = nullptr; 14 | const char* name = nullptr; 15 | cuGetErrorString(e, &message); 16 | cuGetErrorName(e, &name); 17 | INFOE("CUDA Driver error %s # %s, code = %s [ %d ] in file %s:%d", call, message, name, e, file, line); 18 | return false; 19 | } 20 | return true; 21 | } 22 | 23 | bool check_runtime(cudaError_t e, const char* call, int line, const char *file){ 24 | if (e != cudaSuccess) { 25 | INFOE("CUDA Runtime error %s # %s, code = %s [ %d ] in file %s:%d", call, cudaGetErrorString(e), cudaGetErrorName(e), e, file, line); 26 | return false; 27 | } 28 | return true; 29 | } 30 | 31 | dim3 grid_dims(int numJobs) { 32 | int numBlockThreads = numJobs < GPU_BLOCK_THREADS ? numJobs : GPU_BLOCK_THREADS; 33 | return dim3(((numJobs + numBlockThreads - 1) / (float)numBlockThreads)); 34 | } 35 | 36 | dim3 block_dims(int numJobs) { 37 | return numJobs < GPU_BLOCK_THREADS ? numJobs : GPU_BLOCK_THREADS; 38 | } 39 | 40 | std::string device_capability(int device_id){ 41 | cudaDeviceProp prop; 42 | checkCudaRuntime(cudaGetDeviceProperties(&prop, device_id)); 43 | return iLogger::format("%d.%d", prop.major, prop.minor); 44 | } 45 | 46 | AutoDevice::AutoDevice(int device_id){ 47 | cudaGetDevice(&old_); 48 | checkCudaRuntime(cudaSetDevice(device_id)); 49 | } 50 | 51 | AutoDevice::~AutoDevice(){ 52 | if(old_ != -1){ 53 | checkCudaRuntime(cudaSetDevice(old_)); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/common/cuda_tools.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CUDA_TOOLS_HPP 2 | #define CUDA_TOOLS_HPP 3 | 4 | 5 | /* 6 | * 系统关于CUDA的功能函数 7 | */ 8 | 9 | #include 10 | #include 11 | #include "ilogger.hpp" 12 | 13 | #define GPU_BLOCK_THREADS 512 14 | 15 | 16 | #define KernelPositionBlock \ 17 | int position = (blockDim.x * blockIdx.x + threadIdx.x); \ 18 | if (position >= (edge)) return; 19 | 20 | 21 | #define checkCudaDriver(call) CUDATools::check_driver(call, #call, __LINE__, __FILE__) 22 | #define checkCudaRuntime(call) CUDATools::check_runtime(call, #call, __LINE__, __FILE__) 23 | 24 | #define checkCudaKernel(...) \ 25 | __VA_ARGS__; \ 26 | do{cudaError_t cudaStatus = cudaPeekAtLastError(); \ 27 | if (cudaStatus != cudaSuccess){ \ 28 | INFOE("launch failed: %s", cudaGetErrorString(cudaStatus)); \ 29 | }} while(0); 30 | 31 | 32 | #define Assert(op) \ 33 | do{ \ 34 | bool cond = !(!(op)); \ 35 | if(!cond){ \ 36 | INFOF("Assert failed, " #op); \ 37 | } \ 38 | }while(false) 39 | 40 | 41 | struct CUctx_st; 42 | struct CUstream_st; 43 | 44 | typedef CUstream_st* ICUStream; 45 | typedef CUctx_st* ICUContext; 46 | typedef void* ICUDeviceptr; 47 | typedef int DeviceID; 48 | 49 | namespace CUDATools{ 50 | bool check_driver(CUresult e, const char* call, int iLine, const char *szFile); 51 | bool check_runtime(cudaError_t e, const char* call, int iLine, const char *szFile); 52 | 53 | dim3 grid_dims(int numJobs); 54 | dim3 block_dims(int numJobs); 55 | 56 | // return 8.6 etc. 57 | std::string device_capability(int device_id); 58 | 59 | class AutoDevice{ 60 | public: 61 | AutoDevice(int device_id = 0); 62 | virtual ~AutoDevice(); 63 | 64 | private: 65 | int old_ = -1; 66 | }; 67 | } 68 | 69 | 70 | #endif // CUDA_TOOLS_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/common/preprocess_kernel.cuh: -------------------------------------------------------------------------------- 1 | #ifndef PREPROCESS_KERNEL_CUH 2 | #define PREPROCESS_KERNEL_CUH 3 | 4 | #include "cuda_tools.hpp" 5 | 6 | namespace CUDAKernel{ 7 | 8 | enum class NormType : int{ 9 | None = 0, 10 | MeanStd = 1, 11 | AlphaBeta = 2 12 | }; 13 | 14 | enum class ChannelType : int{ 15 | None = 0, 16 | Invert = 1 17 | }; 18 | 19 | struct Norm{ 20 | float mean[3]; 21 | float std[3]; 22 | float alpha, beta; 23 | NormType type = NormType::None; 24 | ChannelType channel_type = ChannelType::None; 25 | 26 | // out = (x * alpha - mean) / std 27 | static Norm mean_std(const float mean[3], const float std[3], float alpha = 1/255.0f, ChannelType channel_type=ChannelType::None); 28 | 29 | // out = x * alpha + beta 30 | static Norm alpha_beta(float alpha, float beta = 0, ChannelType channel_type=ChannelType::None); 31 | 32 | // None 33 | static Norm None(); 34 | }; 35 | 36 | void warp_affine_bilinear_and_normalize_plane( 37 | uint8_t* src, int src_line_size, int src_width, int src_height, 38 | float* dst , int dst_width, int dst_height, 39 | float* matrix_2_3, uint8_t const_value, const Norm& norm, 40 | cudaStream_t stream); 41 | 42 | void warp_affine_bilinear_and_normalize_focus( 43 | uint8_t* src, int src_line_size, int src_width, int src_height, 44 | float* dst , int dst_width, int dst_height, 45 | float* matrix_2_3, uint8_t const_value, const Norm& norm, 46 | cudaStream_t stream); 47 | 48 | void resize_bilinear_and_normalize( 49 | uint8_t* src, int src_line_size, int src_width, int src_height, float* dst, int dst_width, int dst_height, 50 | uint8_t const_value, const Norm& norm, 51 | cudaStream_t stream); 52 | 53 | void norm_feature( 54 | float* feature_array, int num_feature, int feature_length, 55 | cudaStream_t stream 56 | ); 57 | 58 | void convert_nv12_to_bgr_invoke( 59 | const uint8_t* y, const uint8_t* uv, int width, int height, 60 | int linesize, uint8_t* dst, 61 | cudaStream_t stream); 62 | }; 63 | 64 | #endif // PREPROCESS_KERNEL_CUH -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/import_lib.cpp: -------------------------------------------------------------------------------- 1 |  2 | #if defined(_WIN32) 3 | # define U_OS_WINDOWS 4 | #else 5 | # define U_OS_LINUX 6 | #endif 7 | 8 | #ifdef U_OS_WINDOWS 9 | #if defined(_DEBUG) 10 | # pragma comment(lib, "opencv_world346d.lib") 11 | #else 12 | # pragma comment(lib, "opencv_world346.lib") 13 | #endif 14 | 15 | //导入cuda 16 | #pragma comment(lib, "cuda.lib") 17 | #pragma comment(lib, "cudart.lib") 18 | #pragma comment(lib, "cublas.lib") 19 | #pragma comment(lib, "cudnn.lib") 20 | 21 | //导入tensorRT 22 | #pragma comment(lib, "nvinfer.lib") 23 | #pragma comment(lib, "nvinfer_plugin.lib") 24 | //#pragma comment(lib, "nvparsers.lib") 25 | 26 | #if defined(_DEBUG) 27 | #pragma comment(lib, "libprotobufd.lib") 28 | #else 29 | #pragma comment(lib, "libprotobuf.lib") 30 | #endif 31 | 32 | #ifdef HAS_PYTHON 33 | #pragma comment(lib, "python37.lib") 34 | #endif 35 | 36 | #endif // U_OS_WINDOWS -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/infer/trt_infer.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef TRT_INFER_HPP 4 | #define TRT_INFER_HPP 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace TRT { 13 | 14 | class Infer { 15 | public: 16 | virtual void forward(bool sync = true) = 0; 17 | virtual int get_max_batch_size() = 0; 18 | virtual void set_stream(CUStream stream) = 0; 19 | virtual CUStream get_stream() = 0; 20 | virtual void synchronize() = 0; 21 | virtual size_t get_device_memory_size() = 0; 22 | virtual std::shared_ptr get_workspace() = 0; 23 | virtual std::shared_ptr input (int index = 0) = 0; 24 | virtual std::shared_ptr output(int index = 0) = 0; 25 | virtual std::shared_ptr tensor(const std::string& name) = 0; 26 | virtual std::string get_input_name (int index = 0) = 0; 27 | virtual std::string get_output_name(int index = 0) = 0; 28 | virtual bool is_output_name(const std::string& name) = 0; 29 | virtual bool is_input_name (const std::string& name) = 0; 30 | virtual int num_output() = 0; 31 | virtual int num_input() = 0; 32 | virtual void print() = 0; 33 | virtual int device() = 0; 34 | virtual void set_input (int index, std::shared_ptr tensor) = 0; 35 | virtual void set_output(int index, std::shared_ptr tensor) = 0; 36 | virtual std::shared_ptr> serial_engine() = 0; 37 | }; 38 | 39 | struct DeviceMemorySummary { 40 | size_t total; 41 | size_t available; 42 | }; 43 | 44 | DeviceMemorySummary get_current_device_summary(); 45 | int get_device_count(); 46 | int get_device(); 47 | 48 | void set_device(int device_id); 49 | std::shared_ptr load_infer_from_memory(const void* pdata, size_t size); 50 | std::shared_ptr load_infer(const std::string& file); 51 | bool init_nv_plugins(); 52 | 53 | }; //TRTInfer 54 | 55 | 56 | #endif //TRT_INFER_HPP -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx/onnx_pb.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) ONNX Project Contributors. 2 | // Licensed under the MIT license. 3 | 4 | #ifndef ONNX_ONNX_PB_H 5 | #define ONNX_ONNX_PB_H 6 | 7 | // Defines ONNX_EXPORT and ONNX_IMPORT. On Windows, this corresponds to 8 | // different declarations (dllexport and dllimport). On Linux/Mac, it just 9 | // resolves to the same "default visibility" setting. 10 | #if defined(_MSC_VER) 11 | #if defined(ONNX_BUILD_SHARED_LIBS) || defined(ONNX_BUILD_MAIN_LIB) 12 | #define ONNX_EXPORT __declspec(dllexport) 13 | #define ONNX_IMPORT __declspec(dllimport) 14 | #else 15 | #define ONNX_EXPORT 16 | #define ONNX_IMPORT 17 | #endif 18 | #else 19 | #if defined(__GNUC__) 20 | #define ONNX_EXPORT __attribute__((__visibility__("default"))) 21 | #else 22 | #define ONNX_EXPORT 23 | #endif 24 | #define ONNX_IMPORT ONNX_EXPORT 25 | #endif 26 | 27 | // ONNX_API is a macro that, depends on whether you are building the 28 | // main ONNX library or not, resolves to either ONNX_EXPORT or 29 | // ONNX_IMPORT. 30 | // 31 | // This is used in e.g. ONNX's protobuf files: when building the main library, 32 | // it is defined as ONNX_EXPORT to fix a Windows global-variable-in-dll 33 | // issue, and for anyone dependent on ONNX it will be defined as 34 | // ONNX_IMPORT. ONNX_BUILD_MAIN_LIB can also be set when being built 35 | // statically if ONNX is being linked into a shared library that wants 36 | // to export the ONNX APIs and classes. 37 | // 38 | // More details on Windows dllimport / dllexport can be found at 39 | // https://msdn.microsoft.com/en-us/library/3y1sfaz2.aspx 40 | // 41 | // This solution is similar to 42 | // https://github.com/pytorch/pytorch/blob/master/caffe2/core/common.h 43 | #define ONNX_API 44 | #include "onnx-ml.pb.h" 45 | 46 | #endif // ! ONNX_ONNX_PB_H 47 | -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx/readme.md: -------------------------------------------------------------------------------- 1 | # ONNX 2 | - 这几个文件来自于对ONNX的编译后提取的结果,由protoc生成的cpp 3 | - https://github.com/onnx/onnx -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx_parser/LoopHelpers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #include "LoopHelpers.hpp" 6 | #include "onnx2trt_utils.hpp" 7 | 8 | namespace onnx2trt 9 | { 10 | 11 | nvinfer1::ITensor* addLoopCounter(IImporterContext* ctx, nvinfer1::ILoop* loop, int32_t initial) 12 | { 13 | nvinfer1::ITensor* initialTensor = addConstantScalar(ctx, initial, ::onnx::TensorProto::INT32, nvinfer1::Dims{1, 1})->getOutput(0); 14 | nvinfer1::ITensor* one = addConstantScalar(ctx, 1, ::onnx::TensorProto::INT32, nvinfer1::Dims{1, 1})->getOutput(0); 15 | 16 | auto counter = loop->addRecurrence(*initialTensor); 17 | nvinfer1::ITensor* addOne = ctx->network()->addElementWise(*counter->getOutput(0), *one, nvinfer1::ElementWiseOperation::kSUM)->getOutput(0); 18 | counter->setInput(1, *addOne); 19 | return counter->getOutput(0); 20 | } 21 | 22 | } // namespace onnx2trt 23 | -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx_parser/LoopHelpers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include "ImporterContext.hpp" 10 | 11 | namespace onnx2trt 12 | { 13 | 14 | nvinfer1::ITensor* addLoopCounter(IImporterContext* ctx, nvinfer1::ILoop* loop, int32_t initial = 0); 15 | 16 | } // namespace onnx2trt 17 | -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx_parser/NvOnnxParser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #include "NvOnnxParser.h" 6 | #include "ModelImporter.hpp" 7 | 8 | extern "C" void* createNvOnnxParser_INTERNAL(void* network_, void* logger_, int version, const std::vector& input_dims) 9 | { 10 | auto network = static_cast(network_); 11 | auto logger = static_cast(logger_); 12 | return new onnx2trt::ModelImporter(network, logger, input_dims); 13 | } 14 | 15 | extern "C" int getNvOnnxParserVersion() 16 | { 17 | return NV_ONNX_PARSER_VERSION; 18 | } -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx_parser/OnnxAttrs.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "ImporterContext.hpp" 13 | 14 | class OnnxAttrs 15 | { 16 | template 17 | using string_map = std::unordered_map; 18 | typedef string_map<::onnx::AttributeProto const*> AttrMap; 19 | AttrMap _attrs; 20 | onnx2trt::IImporterContext* mCtx; 21 | 22 | public: 23 | explicit OnnxAttrs(::onnx::NodeProto const& onnx_node, onnx2trt::IImporterContext* ctx) 24 | : mCtx{ctx} 25 | { 26 | for (auto const& attr : onnx_node.attribute()) 27 | { 28 | _attrs.insert({attr.name(), &attr}); 29 | } 30 | } 31 | 32 | bool count(const std::string& key) const 33 | { 34 | return _attrs.count(key); 35 | } 36 | 37 | ::onnx::AttributeProto const* at(std::string key) const 38 | { 39 | if (!_attrs.count(key)) 40 | { 41 | throw std::out_of_range("Attribute not found: " + key); 42 | } 43 | return _attrs.at(key); 44 | } 45 | 46 | ::onnx::AttributeProto::AttributeType type(const std::string& key) const 47 | { 48 | return this->at(key)->type(); 49 | } 50 | 51 | 52 | template 53 | T get(const std::string& key) const; 54 | 55 | template 56 | T get(const std::string& key, T const& default_value) const 57 | { 58 | return _attrs.count(key) ? this->get(key) : default_value; 59 | } 60 | }; 61 | -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx_parser/RNNHelpers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "TensorOrWeights.hpp" 12 | #include "ImporterContext.hpp" 13 | 14 | namespace onnx2trt 15 | { 16 | 17 | nvinfer1::ITensor* addRNNInput(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, std::vector& inputs, const std::string& direction); 18 | 19 | // Zeros out invalid timesteps in toMask. maxLen must be provided if reverse is true 20 | nvinfer1::ITensor* clearMissingSequenceElements(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, nvinfer1::ITensor* seqLens, nvinfer1::ITensor* toMask, nvinfer1::ITensor* maxLen, bool reverse = false, nvinfer1::ITensor* counter = nullptr); 21 | 22 | // Returns a bool tensor which is true during valid timesteps 23 | nvinfer1::ITensor* getRaggedMask(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, nvinfer1::ITensor* seqLens, nvinfer1::ITensor* maxLen = nullptr, bool reverse = false, nvinfer1::ITensor* counter = nullptr); 24 | 25 | // Selects between prevH and Ht to forward previous hidden state through invalid timesteps 26 | nvinfer1::ITensor* maskRNNHidden(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, nvinfer1::ITensor* seqLens, nvinfer1::ITensor* prevH, nvinfer1::ITensor* Ht, nvinfer1::ITensor* maxLen = nullptr, bool reverse = false, nvinfer1::ITensor* counter = nullptr); 27 | 28 | // Splits a bidirectional hidden state into forward and reverse passes, masks each using maskRNNHidden, then concatenates 29 | nvinfer1::ITensor* maskBidirRNNHidden(IImporterContext* ctx, const ::onnx::NodeProto& node, nvinfer1::ILoop* loop, nvinfer1::ITensor* seqLens, nvinfer1::ITensor* maxLen, nvinfer1::ITensor* Ht1, nvinfer1::ITensor* Ht, nvinfer1::ITensor* singlePassShape); 30 | 31 | } // namespace onnx2trt 32 | -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx_parser/ShapedWeights.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | namespace onnx2trt 11 | { 12 | 13 | class ShapedWeights 14 | { 15 | public: 16 | using DataType = int32_t; 17 | 18 | static ShapedWeights empty(DataType type); 19 | 20 | ShapedWeights(); 21 | 22 | explicit ShapedWeights(DataType type, void* values, nvinfer1::Dims shape_); 23 | 24 | size_t count() const; 25 | 26 | size_t size_bytes() const; 27 | 28 | const char* getName() const; 29 | 30 | void setName(const char* name); 31 | 32 | explicit operator bool() const; 33 | 34 | operator nvinfer1::Weights() const; 35 | 36 | template 37 | T& at(size_t index) 38 | { 39 | assert(index >= 0 && (index * sizeof(T)) < size_bytes()); 40 | return static_cast(values)[index]; 41 | } 42 | 43 | template 44 | const T& at(size_t index) const 45 | { 46 | assert(index >= 0 && (index * sizeof(T)) < size_bytes()); 47 | return static_cast(values)[index]; 48 | } 49 | 50 | public: 51 | DataType type; 52 | void* values; 53 | nvinfer1::Dims shape; 54 | const char* name{}; 55 | }; 56 | 57 | class IImporterContext; 58 | bool transposeWeights(ShapedWeights const& weights, nvinfer1::Permutation const& perm, ShapedWeights* result, IImporterContext* ctx); 59 | 60 | } // namespace onnx2trt 61 | -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx_parser/builtin_op_importers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "onnx2trt.hpp" 8 | #include "utils.hpp" 9 | 10 | namespace onnx2trt 11 | { 12 | 13 | string_map& getBuiltinOpImporterMap(); 14 | 15 | } // namespace onnx2trt 16 | -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx_parser/onnx2trt.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "NvOnnxParser.h" 8 | #include "ShapedWeights.hpp" 9 | #include "Status.hpp" 10 | #include "TensorOrWeights.hpp" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace onnx2trt 21 | { 22 | 23 | class IImporterContext; 24 | 25 | // TODO: Find ABI-safe alternative approach for this: 26 | // Can't use std::vector 27 | // Can't use ::onnx::NodeProto 28 | // Can't use std::function 29 | typedef ValueOrStatus> NodeImportResult; 30 | typedef std::function& inputs)> 32 | NodeImporter; 33 | 34 | template 35 | using StringMap = std::unordered_map; 36 | 37 | class IImporterContext 38 | { 39 | public: 40 | virtual nvinfer1::INetworkDefinition* network() = 0; 41 | virtual StringMap& tensors() = 0; 42 | virtual StringMap& tensorLocations() = 0; 43 | virtual StringMap& tensorRangeMins() = 0; 44 | virtual StringMap& tensorRangeMaxes() = 0; 45 | virtual StringMap& layerPrecisions() = 0; 46 | virtual std::unordered_set& unsupportedShapeTensors() = 0; 47 | virtual StringMap& loopTensors() = 0; 48 | virtual void setOnnxFileLocation(std::string location) = 0; 49 | virtual std::string getOnnxFileLocation() = 0; 50 | virtual void registerTensor(TensorOrWeights tensor, const std::string& basename) = 0; 51 | virtual void registerLayer(nvinfer1::ILayer* layer, const std::string& basename) = 0; 52 | virtual ShapedWeights createTempWeights(ShapedWeights::DataType type, nvinfer1::Dims shape, uint8_t value = 0) = 0; 53 | virtual int64_t getOpsetVersion(const char* domain = "") const = 0; 54 | virtual nvinfer1::ILogger& logger() = 0; 55 | virtual bool hasError() const = 0; 56 | virtual nvinfer1::IErrorRecorder* getErrorRecorder() const = 0; 57 | 58 | protected: 59 | virtual ~IImporterContext() 60 | { 61 | } 62 | }; 63 | 64 | } // namespace onnx2trt 65 | -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx_parser/onnx2trt_common.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | #if NV_TENSORRT_MAJOR < 4 11 | namespace nvinfer1 12 | { 13 | 14 | enum class PluginFormat : uint8_t 15 | { 16 | kNCHW = 0, //!< NCHW 17 | kNC2HW2 = 1, //!< NCHW with 2-element packed channels 18 | kNHWC8 = 2 //!< NHWC with 8-element packed channels (C 19 | //! must be a multiple of 8) 20 | }; 21 | // from NvInfer.h 22 | class IPluginExt : public IPlugin 23 | { 24 | public: 25 | virtual int getTensorRTVersion() const noexcept 26 | { 27 | return NV_TENSORRT_VERSION; 28 | } 29 | virtual bool supportsFormat(DataType type, PluginFormat format) const noexcept = 0; 30 | virtual void configureWithFormat(const Dims* inputDims, int nbInputs, const Dims* outputDims, int nbOutputs, 31 | DataType type, PluginFormat format, int maxBatchSize) noexcept 32 | = 0; 33 | 34 | protected: 35 | void configure( 36 | const Dims* inputDims, int nbInputs, const Dims* outputDims, int nbOutputs, int maxBatchSize) noexcept final 37 | { 38 | try 39 | { 40 | DataType type = nvinfer1::DataType::kFLOAT; 41 | PluginFormat format = nvinfer1::PluginFormat::kLINEAR; 42 | return this->configureWithFormat(inputDims, nbInputs, outputDims, nbOutputs, type, format, maxBatchSize); 43 | } 44 | catch (const std::exception& e) 45 | { 46 | nvinfer1::getLogger()->log(nvinfer1::ILogger::Severity::kERROR, e.what().c_str()); 47 | } 48 | } 49 | virtual ~IPluginExt() 50 | { 51 | } 52 | }; 53 | 54 | } // namespace nvinfer1 55 | #endif 56 | 57 | namespace onnx2trt 58 | { 59 | 60 | struct IOwnable 61 | { 62 | virtual void destroy() = 0; 63 | 64 | protected: 65 | virtual ~IOwnable() 66 | { 67 | } 68 | }; 69 | 70 | struct OwnableDeleter 71 | { 72 | void operator()(IOwnable* obj) const 73 | { 74 | obj->destroy(); 75 | } 76 | }; 77 | 78 | using UniqueOwnable = std::unique_ptr; 79 | class Plugin; 80 | class PluginV2; 81 | 82 | } // namespace onnx2trt 83 | -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx_parser/onnx2trt_runtime.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "onnx2trt_common.hpp" 8 | 9 | namespace onnx2trt 10 | { 11 | 12 | typedef Plugin* (*plugin_deserializer)(const void* serialData, size_t serialLength); 13 | 14 | } // namespace onnx2trt 15 | -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx_parser/readme.md: -------------------------------------------------------------------------------- 1 | # ONNX Parser 2 | - 这几个文件提取自官方的onnx-tensorrt,去掉python方面,其他都在 3 | - 另外增加了Plugin节点的支持 4 | - https://github.com/onnx/onnx-tensorrt -------------------------------------------------------------------------------- /tensorrt_code/src/tensorRT/onnx_parser/utils.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | template 10 | using string_map = std::unordered_map; 11 | -------------------------------------------------------------------------------- /tensorrt_code/tools/show.py: -------------------------------------------------------------------------------- 1 | 2 | # 配合/data/sxai/tensorRT/src/application/app_fall_recognize.cpp中的zmq remote实现远程显示服务器画面的效果 3 | # pip install zmq 4 | import zmq 5 | import sys 6 | import numpy as np 7 | import cv2 8 | 9 | context = zmq.Context() 10 | socket = context.socket(zmq.REQ) 11 | socket.connect("tcp://192.168.16.109:15556") 12 | 13 | while True: 14 | socket.send(b"a") 15 | message = socket.recv() 16 | if len(message) == 1 and message == b'x': 17 | break 18 | 19 | image = np.frombuffer(message, dtype=np.uint8) 20 | image = cv2.imdecode(image, 1) 21 | 22 | cv2.imshow("image", image) 23 | key = cv2.waitKey(1) & 0xFF 24 | 25 | if key == ord('q'): 26 | break -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/README.md: -------------------------------------------------------------------------------- 1 | EN 2 | - yolo_example is a complete example to demonstrate how the framework works. Configure it to src/application as a new app (e.g. app_tutorial) if you want to run it. pipeline.pdf and pipeline.goodnotes are resources for tutorial. Any more vivid images or notes are welcomed to make the framework better. 3 | 4 | ZH 5 | - Yolo_example是一个完整的示例,演示了框架是如何工作的。如果你想运行它,将它配置到src/application作为一个新应用(例如app_tutorial)。pipeline.pdf and pipeline.goodnotes 可以帮助大家更好的理解该框架的流程。 欢迎大家投稿自己的注释或绘画插图方便更多人使用我们的框架。 6 | -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/car.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_0.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_2.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_21.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_210.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_210.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_211.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_211.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_212.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_212.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_213.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_213.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_214.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_214.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_215.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_215.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_216.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_216.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_217.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_217.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_218.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_218.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_219.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_219.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_22.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_220.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_220.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_221.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_221.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_222.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_222.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_223.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_223.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_224.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_224.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_225.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_225.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_226.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_226.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_227.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_227.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_228.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_228.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_229.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_229.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_27.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_27.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_270.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_270.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_271.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_271.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_272.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_272.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_273.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_273.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_274.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_274.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_275.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_275.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_276.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_276.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_277.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_277.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_278.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_278.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_279.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_279.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_29.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_29.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_290.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_290.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_291.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_291.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_292.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_292.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_293.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_293.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_294.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_294.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_295.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_295.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_296.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_296.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_297.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_297.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_298.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_298.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/f3_299.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/f3_299.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/gril.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/gril.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/group.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/group.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/show.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/show.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/torch_affine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/torch_affine.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/trt_affine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/trt_affine.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/yq.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/yq.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/zand.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/zand.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/zand_copy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/zand_copy.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/inference/zgjr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/inference/zgjr.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/pipeline.goodnotes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/pipeline.goodnotes -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/pipeline.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/pipeline.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/pipeline.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/1.0framework/pipeline.pdf -------------------------------------------------------------------------------- /tensorrt_code/tutorial/1.0framework/yolo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef YOLO_HPP 2 | #define YOLO_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /** 11 | * @brief 发挥极致的性能体验 12 | * 支持YoloX和YoloV5 13 | */ 14 | 15 | 16 | 17 | 18 | namespace Yolo{ 19 | 20 | using namespace std; 21 | 22 | enum class Type : int{ 23 | V5 = 0, 24 | X = 1 25 | }; 26 | 27 | struct ObjectBox{ 28 | float left, top, right, bottom, confidence; 29 | int class_label; 30 | 31 | ObjectBox() = default; 32 | 33 | ObjectBox(float left, float top, float right, float bottom, float confidence, int class_label) 34 | :left(left), top(top), right(right), bottom(bottom), confidence(confidence), class_label(class_label){} 35 | 36 | float get_left() {return left;} 37 | void set_left(float value) {left = value;} 38 | float get_top() {return top;} 39 | void set_top(float value) {top = value;} 40 | float get_right() {return right;} 41 | void set_right(float value) {right = value;} 42 | float get_bottom() {return bottom;} 43 | void set_bottom(float value) {bottom = value;} 44 | float get_confidence() {return confidence;} 45 | void set_confidence(float value){confidence = value;} 46 | int get_class_label() {return class_label;} 47 | void set_class_label(int value) {class_label = value;} 48 | }; 49 | 50 | typedef vector ObjectBoxArray; 51 | 52 | class Infer{ 53 | public: 54 | virtual shared_future commit(const cv::Mat& image) = 0; 55 | virtual vector> commits(const vector& images) = 0; 56 | }; 57 | 58 | shared_ptr create_infer(const string& engine_file, Type type, int gpuid, float confidence_threshold=0.25f, float nms_threshold=0.5f); 59 | const char* type_name(Type type); 60 | 61 | }; // namespace Yolo 62 | 63 | #endif // YOLO_HPP -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "./src/**", 7 | "/datav/shared/wkx/tensorRT_cpp/lean/protobuf3.11.4/include/**", 8 | "/usr/local/opencv/include/opencv4/**", 9 | "/usr/local/cuda/include/**", 10 | "/datav/shared/wkx/tensorRT_cpp/lean/TensorRT-8.0.1.6/include/**", 11 | "/datav/shared/wkx/tensorRT_cpp/lean/cudnn8.2.2.26/include/**", 12 | "/root/anaconda3/include/python3.8/**" 13 | ], 14 | "defines": ["__CUDACC__", "HAS_PYTHON"], 15 | "compilerPath": "/usr/bin/gcc", 16 | "cStandard": "gnu11", 17 | "cppStandard": "gnu++11", 18 | "intelliSenseMode": "linux-gcc-x64", 19 | "configurationProvider": "ms-vscode.makefile-tools", 20 | "browse": { 21 | "limitSymbolsToIncludedHeaders": false, 22 | "databaseFilename": "" 23 | } 24 | } 25 | ], 26 | "version": 4 27 | } -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | // run c++ 9 | { 10 | "name": "(gdb) 启动", 11 | "type": "cppdbg", 12 | "request": "launch", 13 | "program": "${workspaceFolder}/workspace/pro", 14 | "args": [ 15 | "centernet", 16 | ], 17 | "stopAtEntry": false, 18 | "cwd": "${workspaceFolder}/workspace", 19 | "environment": [], 20 | "externalConsole": false, 21 | "MIMode": "gdb", 22 | "setupCommands": [ 23 | { 24 | "description": "为 gdb 启用整齐打印", 25 | "text": "-enable-pretty-printing", 26 | "ignoreFailures": true 27 | } 28 | ], 29 | "preLaunchTask": "build" 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "build", 8 | "type": "shell", 9 | "command": "make pro -j25" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/README.md: -------------------------------------------------------------------------------- 1 | - Download model1 for tutorial: https://drive.google.com/file/d/1H5TI6aiWnleYfXjY3l2-VaxXr6evRfre/view?usp=sharing 2 | - Download model2 for tutorial: https://drive.google.com/file/d/1QNsBDSlXyTtbO0VoZ4HPGnOb1mRHcciL/view?usp=sharing 3 | 4 | 5 | cd to tensorRT_cpp/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet, 6 | 7 | Copy tensorRT_cpp/src/TensorRT to /0_to_1_python_to_cuda/cpp_cuda_centernet/src/. Also remember to modify paths. 8 | 9 | Then set the workspace as /cpp_cuda_centernet by 10 | opening folder in tensorRT_cpp/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet in vscode. 11 | 12 | In app_centernet.cpp, a pure c++ implementation and a pure cuda implementation are offered for tutorial. They are not neat because I prefer to keep the draft(the commented code) for guys to learn the API operations in our framework/c++/cuda env. Some codes are hardcoded for simplicity.It is suggested that after being familiar with python, c++ and cuda version, you are free to have a try on integrating CenterNet into our framework like what we've done in /tensorRT_cpp/src/application/app_centernet. 13 | 14 |
15 | 16 | - 下载用于教程的模型1: https://pan.baidu.com/s/1Tj3EhxOOQgexPhuw74QtUA 提取码:75o3 17 | - 下载用于教程的模型2: https://pan.baidu.com/s/1UEq2n0Kn5jd2n3ahU-sn3w 提取码:aal6 18 | 19 | cd to tensorRT_cpp/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet, 20 | Copy tensorRT_cpp/src/TensorRT to /0_to_1_python_to_cuda/cpp_cuda_centernet/src/. 记住修改成自己的路径 21 | 22 | 然后将工作区设置为/cpp_cuda_centernet: 23 | 在vscode中打开tensorRT_cpp/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet文件夹。 24 | 25 | 在app_centernet.cpp中,我们提供了一个纯c++实现和一个纯cuda实现的教程。它们主要复现了一些思路,所以并非十分整洁,因为我们更希望保留草稿(例如:注释掉的代码),以便小伙伴们在阅读草稿时可以感受到我们的框架/c++/cuda 环境中API操作的各种使用可能性。为了简单起见,有些代码是硬编码的。建议您在熟悉python、c++和cuda版本之后,可以自由地尝试将CenterNet集成到我们的框架中,就像我们在/tensorRT_cpp/src/application/app_centernet中所做的那样。 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/src/comments.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/src/comments.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/src/cuda_nms.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/src/cuda_nms.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int app_centernet(); 7 | 8 | int main(){ 9 | app_centernet(); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/affined_result_cpp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/affined_result_cpp.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/car.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/final_result_cpp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/final_result_cpp.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/final_result_cuda.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/final_result_cuda.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/test.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/model_output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/model_output -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/truck_and_person.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/truck_and_person.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/5_outputs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/5_outputs.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/DCNmodule_res18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/DCNmodule_res18.png -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/README.zh-cn.md: -------------------------------------------------------------------------------- 1 | *[English](README.md), [简体中文](README.zh-cn.md).* 2 | *英文版为推荐版本* 3 | 4 | # 介绍 5 | 本教程将演示如何导出一个pytorch模型到trt模型。我们以CenterNet为例。因为DCNv2应用在CenterNet中,它演示了如何操作插件。 6 | 先预览两部分: 7 | - 1. python的部分 8 | - 2. c++的部分 9 | 10 | # PYTHON部分 11 | CenterNet repo 可从https://github.com/xingyizhou/CenterNet下载 但是由于版本兼容性问题,/CenterNet/src/lib/models/networks/DCNv2 要用这个 https://github.com/jinfagang/DCNv2_latest 来替换了。 12 | 考虑这是教程,在CenterNet中,我们只关心这两个文件(src/demo.py及其相关文件和src/export2onnx.py)。那些对CenterNet本身感兴趣的小伙伴可以参考官方的github repo。 13 | 14 | 现在让我们打开 export2onnx.py 15 | 我重写了一个导出脚本,而不是使用官方脚本,这样以后更容易适应我们的tensorRT_cpp框架。 16 | 通常当你得到一个pt模型时,你想要导出到onnx。建议采取以下步骤: 17 | - 1. 将模型结构提取到一个新的脚本,以编写一个新的onnx脚本或使用官方的导出脚本。(我自己是重新写了一个) 18 | - 2. 然后用torch.onnx.export而不是export_。在填参数之前,我们还需要修改我们的模型结构,以便更容易解码。(首先阅读3,然后回到这里)。我们用["images"]填充input_names,用["output"]填充output_names。注意,这两个名称是在tensorRT_cpp框架中预定义的。您也可以在脚本中保留其他输出,就像我在注释代码中做的,但这没有多大意义。还要记住设置enable_onnx_checker=False。 19 | 20 | 5_outputs.jpg和all_in_one_output.jpg是onnx的截图。 21 | 22 | - 3. 打开CenterNet/src/lib/model/network/resnet_dcn.py 跳到大约280行,其中'def forward(self, x): ' 23 | - /# !+表示加了的东西 24 | - 修改self.head = {"reg":2, "wh":2, "hm":80} 25 | - 并添加一个从hm head 分支出来的 pool_hm(在这里操作的话就不用用c++/cuda来写pool了) 26 | 27 | - 将所有head concat到一个输出,以便在c++ env中更容易解码 28 | - 我们也做了permute,把164(2+2+80+80)放在最后。 29 | - 4. 似乎一切都准备好了。但如果你忘了修改CenterNet/src/lib/models/networks/DCNv2/dcn_v2.py,那就不行了。你需要注释Original version 并使用ONNX CONVERSION。ONNX CONVERSION是为了兼容tensorRT_cpp框架而编写的。 30 | 如果你已经读到了这里,做得很好。现在你可能会得到一个onnx文件。将其复制到tensorRT_cpp/工作区。那么你在python部分已经大功告成了。 31 | 32 | 33 | # c++的部分 34 | DCN插件已经由我们在src/tensorRT/onnxplugin/plugins/DCNv2中实现了。你不需要为此担心。但如果你想知道细节,请参阅P5 https://www.bilibili.com/video/BV1Xw411f7FW?p=2&spm_id_from=pageDriver (现在只有中文)。 35 | 36 | 然后是整个导出过程的高潮 ---- 编写CUDA内核进行预处理和后处理。但对于CenterNet来说,它与yolo有着相同的预处理。所以几乎不需要修改。 37 | (我们还提供了详细的代码,让初学者能够体验整个过程,即使是那些对c++和cuda经验有限的人。) 38 | 39 | #### CenterNet的文件和值得注意的点 40 | centernet_decode.cu centernet.cpp centernet.hpp和app_centernet.cpp 41 | 42 | 大多数代码不需要修改,除了以下几点值得注意: 43 | - mean和std遵循CenterNet的官方回购,与yolo不同 44 | - 在yolo中使用了num_channels变量而不是num_classes。 45 | - 指定下采样率 46 | - 由于使用了Focal loss,导致confence_threshold低于yolo 47 | - 在预处理时,默认值为0,与CenterNet官方回购相同。 48 | - 应该更多地关注CenterNet的后期处理。 49 | 50 | #### CenterNet 的后期处理 51 | 打开 tensorRT_cpp/src/application/app_centernet/centernet_decode.cu 52 | 53 | 如果你是初学者,可以选择'from_python_through_c++_to_cuda_impl'的学习路径(在0_to_1_python_to_cuda文件夹中)。如果没有,请继续阅读并熟悉centernet_decode.cu。结束了,就这么多。 -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/all_in_one_output.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/all_in_one_output.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/comments.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/comments.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/cuda_nms.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/cuda_nms.jpg -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/demo.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import print_function 4 | 5 | import _init_paths 6 | 7 | import os 8 | import cv2 9 | 10 | from opts import opts 11 | from detectors.detector_factory import detector_factory 12 | 13 | image_ext = ['jpg', 'jpeg', 'png', 'webp'] 14 | video_ext = ['mp4', 'mov', 'avi', 'mkv'] 15 | time_stats = ['tot', 'load', 'pre', 'net', 'dec', 'post', 'merge'] 16 | 17 | def demo(opt): 18 | os.environ['CUDA_VISIBLE_DEVICES'] = opt.gpus_str 19 | opt.debug = max(opt.debug, 1) 20 | Detector = detector_factory[opt.task] 21 | detector = Detector(opt) 22 | 23 | ret = detector.run("images/yq.jpg") 24 | time_str = '' 25 | for stat in time_stats: 26 | time_str = time_str + '{} {:.3f}s |'.format(stat, ret[stat]) 27 | print(time_str) 28 | if __name__ == '__main__': 29 | opt = opts().init() 30 | demo(opt) 31 | -------------------------------------------------------------------------------- /tensorrt_code/tutorial/2.0CenterNet_from_torch_trt/export2onnx.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import print_function 4 | 5 | import _init_paths 6 | import torch 7 | 8 | import os 9 | import cv2 10 | 11 | from opts import opts 12 | from detectors.detector_factory import detector_factory 13 | 14 | if __name__ == '__main__': 15 | opt = opts().init() 16 | os.environ['CUDA_VISIBLE_DEVICES'] = opt.gpus_str 17 | opt.debug = max(opt.debug, 1) 18 | Detector = detector_factory[opt.task] 19 | detector = Detector(opt) 20 | 21 | model = detector.model.eval().to(opt.device) # Note that eval() should be set. 22 | 23 | dummy_input = torch.zeros((1, 3, 512, 512)).to(opt.device) 24 | 25 | """ 26 | note that if you are exporting onnx, you need to use the DCN for onnx rather than the original one(modify the dcn_v2.py). 27 | comment the original and uncomment the DU. Remember to fill in the args required. Or you can run it in debug mode where 28 | all required args have been filled in. 29 | """ 30 | torch.onnx.export( 31 | model, 32 | (dummy_input,), 33 | 'latest_ctnet_r18_dcn.onnx', 34 | input_names=["images"], 35 | # output_names=["regxy","wh","hm","pool_hm","output"], 36 | output_names=["output"], 37 | verbose=True, 38 | opset_version=11, 39 | # dynamic_axes={"images": {0:"batch"}, "regxy": {0:"batch"}, "wh": {0:"batch"}, 40 | # "hm": {0:"batch"}, "pool_hm": {0:"batch"}, 41 | # "output":{0:"batch"}}, 42 | dynamic_axes={"images": {0:"batch"}, "output":{0:"batch"}}, 43 | enable_onnx_checker=False 44 | ) 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /tensorrt_code/workspace/cvt_dbface.py: -------------------------------------------------------------------------------- 1 | import onnx 2 | 3 | # 下载的onnx的upsample节点是3个scales,需要修改为4个 4 | model = onnx.load("dbface.onnx") 5 | changed = False 6 | 7 | for n in model.graph.node: 8 | if n.op_type == "Upsample": 9 | if len(n.attribute[1].floats) == 3: 10 | changed = True 11 | n.attribute[1].floats.insert(0, 1.0) 12 | 13 | if changed: 14 | print("Change and save to dbface_cvt.onnx.") 15 | onnx.save(model, "dbface_cvt.onnx") 16 | else: 17 | print("No need change.") -------------------------------------------------------------------------------- /tensorrt_code/workspace/exp/face_tracker.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/exp/face_tracker.mp4 -------------------------------------------------------------------------------- /tensorrt_code/workspace/exp/fall_video.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/exp/fall_video.mp4 -------------------------------------------------------------------------------- /tensorrt_code/workspace/face/library/2ys2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/face/library/2ys2.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/face/recognize/2ys1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/face/recognize/2ys1.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/face/recognize/2ys3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/face/recognize/2ys3.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/face/recognize/2ys5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/face/recognize/2ys5.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference/car.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference/cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference/cat.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference/dog_cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference/dog_cat.png -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference/gril.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference/gril.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference/group.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference/group.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference/yq.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference/yq.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference/zand.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference/zand.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference/zgjr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference/zgjr.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference_fasterrcnn/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference_fasterrcnn/car.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference_fasterrcnn/cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference_fasterrcnn/cat.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference_fasterrcnn/dog_cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference_fasterrcnn/dog_cat.png -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference_fasterrcnn/gril.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference_fasterrcnn/gril.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference_fasterrcnn/group.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference_fasterrcnn/group.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference_fasterrcnn/yq.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference_fasterrcnn/yq.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference_fasterrcnn/zand.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference_fasterrcnn/zand.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/inference_fasterrcnn/zgjr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/inference_fasterrcnn/zgjr.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/lesson1.py: -------------------------------------------------------------------------------- 1 | 2 | import torch 3 | import torch.nn as nn 4 | 5 | class Model(nn.Module): 6 | def __init__(self): 7 | super().__init__() 8 | 9 | self.conv = nn.Conv2d(1, 1, 3, stride=1, padding=1, bias=True) 10 | self.conv.weight.data.fill_(0.3) 11 | self.conv.bias.data.fill_(0.2) 12 | 13 | def forward(self, x): 14 | x = self.conv(x) 15 | # return x.view(int(x.size(0)), -1) 16 | return x.view(-1, int(x.numel() // x.size(0))) 17 | 18 | model = Model().eval() 19 | 20 | x = torch.full((1, 1, 3, 3), 1.0) 21 | y = model(x) 22 | print(y) 23 | 24 | torch.onnx.export( 25 | model, (x, ), "lesson1.onnx", verbose=True 26 | ) 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /tensorrt_code/workspace/makesure_input.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def load_tensor(file): 4 | 5 | with open(file, "rb") as f: 6 | binary_data = f.read() 7 | 8 | magic_number, ndims, dtype = np.frombuffer(binary_data, np.uint32, count=3, offset=0) 9 | assert magic_number == 0xFCCFE2E2, f"{file} not a tensor file." 10 | 11 | dims = np.frombuffer(binary_data, np.uint32, count=ndims, offset=3 * 4) 12 | 13 | if dtype == 0: 14 | np_dtype = np.float32 15 | elif dtype == 1: 16 | np_dtype = np.float16 17 | else: 18 | assert False, f"Unsupport dtype = {dtype}, can not convert to numpy dtype" 19 | 20 | return np.frombuffer(binary_data, np_dtype, offset=(ndims + 3) * 4).reshape(*dims) 21 | 22 | 23 | tensor = load_tensor("demo.tensor") 24 | ts = [tensor[0, i*3:(i+1)*3].transpose(1, 2, 0) for i in range(4)] 25 | out = np.zeros((640, 640, 3)) 26 | out[::2, ::2, :] = ts[0] 27 | out[1::2, ::2, :] = ts[1] 28 | out[::2, 1::2, :] = ts[2] 29 | out[1::2, 1::2, :] = ts[3] 30 | print(out.shape) 31 | 32 | import cv2 33 | cv2.imwrite("demo.jpg", (out * 255).astype(np.uint8)) 34 | 35 | 36 | m = np.array([ 37 | [0.5, 0, -8], 38 | [0, 0.5, -2] 39 | ]) 40 | print(cv2.invertAffineTransform(m)) -------------------------------------------------------------------------------- /tensorrt_code/workspace/my-yoloxs-car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/my-yoloxs-car.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/pose.show.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/pose.show.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/test.jpg -------------------------------------------------------------------------------- /tensorrt_code/workspace/wget.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/wget.exe -------------------------------------------------------------------------------- /tensorrt_code/workspace/yq.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/tensorrt_code/workspace/yq.jpg -------------------------------------------------------------------------------- /test/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thb1314/tensorrt-onnx-fasterrcnn-fpn-roialign/b3b8fc8f5c6bf60946ed5e14520a073611cd8aa0/test/car.jpg -------------------------------------------------------------------------------- /test/x01export_FasterRCNN_onnx.py: -------------------------------------------------------------------------------- 1 | from torchvision.models.detection import fasterrcnn_resnet50_fpn 2 | import torch 3 | from torchvision import transforms 4 | import glob 5 | import cv2 6 | 7 | if __name__ == '__main__': 8 | 9 | model = fasterrcnn_resnet50_fpn(pretrained=True, box_score_thresh=0.5,box_nms_thresh=0.3) 10 | model.eval() 11 | 12 | transform_func = transforms.ToTensor() 13 | 14 | img_tensor_list = list() 15 | image_list = list() 16 | for item in glob.glob("./*.jpg"): 17 | image_list.append(cv2.resize(cv2.imread(item),dsize=None, fx=0.4, fy=0.4)) 18 | img_tensor_list.append(transform_func(cv2.cvtColor(cv2.resize(cv2.imread(item),dsize=None, fx=0.4, fy=0.4), cv2.COLOR_BGR2RGB))) 19 | break 20 | with torch.no_grad(): 21 | result = model(img_tensor_list) 22 | for i,item in enumerate(result): 23 | print(item['boxes'].shape) 24 | print(item['scores'].shape) 25 | print(item['labels'].shape) 26 | image = image_list[i].copy() 27 | for box in item['boxes']: 28 | box = box.numpy() 29 | cv2.rectangle(image, tuple(map(int,box[0:2])), tuple(map(int,box[2:4])), (0,255,0)) 30 | cv2.imshow("win", image) 31 | cv2.waitKey() 32 | cv2.destroyWindow("win") 33 | onnx_save_path = "fasterrcnn_backbone_resnet50_fpn_roialign.onnx" 34 | input_height, input_width = 600, 600 35 | torch.onnx.export(model, [torch.rand(3,input_height,input_width)], onnx_save_path, 36 | verbose=False, 37 | do_constant_folding=True, 38 | input_names=["input"], output_names=["boxes", "scores", "labels"], 39 | # dynamic_axes={"input": {0: "batch_size"}, "output": {0: "batch_size"}}, 40 | opset_version=11) 41 | 42 | import onnxsim 43 | import onnx 44 | import numpy as np 45 | model = onnx.load(onnx_save_path) 46 | # convert model 47 | 48 | model_simp, check = onnxsim.simplify(model, check_n=0,input_shapes={'input':[3,input_height,input_width]}, 49 | dynamic_input_shape=False) 50 | with open(onnx_save_path,'wb') as f: 51 | onnx.save(model_simp, f) 52 | 53 | -------------------------------------------------------------------------------- /test/x02test_FasterRCNN_onnx.py: -------------------------------------------------------------------------------- 1 | import onnxruntime as rt 2 | import numpy as np 3 | import torch 4 | import torchvision 5 | import cv2 6 | from torchvision import transforms 7 | 8 | def get_classes(filepath): 9 | with open(filepath, 'r', encoding='gbk') as f: 10 | return [item.strip() for item in f.readlines()] 11 | 12 | 13 | if __name__ == '__main__': 14 | img = cv2.imread('./car.jpg') 15 | img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) 16 | img = cv2.resize(img, dsize=(600, 600)) 17 | 18 | normalize = transforms.Compose([ 19 | transforms.ToTensor(), 20 | ]) 21 | # ori_image / 255 22 | img_tensor = normalize(img) 23 | img_input = img_tensor.numpy().astype(np.float32) 24 | 25 | sess = rt.InferenceSession('fasterrcnn_backbone_resnet50_fpn_roialign.onnx') 26 | input_name = sess.get_inputs()[0].name 27 | label_names = [sess.get_outputs()[i].name for i in range(3)] 28 | 29 | pred_onnx = sess.run(label_names, {input_name:img_input}) 30 | pred_onnx = dict(zip(label_names, pred_onnx)) 31 | 32 | image = cv2.cvtColor(img, cv2.COLOR_RGB2BGR) 33 | for box in pred_onnx['boxes']: 34 | cv2.rectangle(image, tuple(map(int,box[0:2])), tuple(map(int,box[2:4])), (0,255,0)) 35 | cv2.imshow("win", image) 36 | cv2.waitKey() 37 | cv2.destroyWindow("win") 38 | 39 | 40 | -------------------------------------------------------------------------------- /test/x03extract_RPN.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import os 3 | import sys 4 | sys.path.insert(0, os.path.abspath('..')) 5 | from model import fasterrpn_resnet50_fpn 6 | import glob 7 | from torchvision import transforms 8 | import cv2 9 | 10 | 11 | if __name__ == '__main__': 12 | model = fasterrpn_resnet50_fpn(pretrained=True) 13 | model.eval() 14 | 15 | img_tensor_list = list() 16 | 17 | transform_func = transforms.Compose([ 18 | transforms.ToTensor(), 19 | # transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), 20 | ]) 21 | input_height, input_width = (600 + 31) // 32 * 32, (800 + 31) // 32 * 32 22 | image_list = list() 23 | for item in glob.glob("./*.jpg"): 24 | image_list.append(cv2.resize(cv2.imread(item), dsize=(input_width, input_height))) 25 | img_tensor_list.append( 26 | transform_func(cv2.cvtColor(cv2.resize(cv2.imread(item), dsize=(input_width, input_height)), cv2.COLOR_BGR2RGB))) 27 | 28 | with torch.no_grad(): 29 | results = model(img_tensor_list, is_show=True) 30 | result = results[0] 31 | for i, item in enumerate(result): 32 | image = image_list[i].copy() 33 | for score_box in item: 34 | box = score_box[1:] 35 | box = box.numpy() 36 | cv2.rectangle(image, tuple(map(int, box[0:2])), tuple(map(int, box[2:4])), (0, 255, 0)) 37 | cv2.imshow("win", image) 38 | cv2.waitKey() 39 | cv2.destroyWindow("win") 40 | 41 | output_names = ["rpn_boxes", *tuple(['feature_'+item for item in results[1].keys()])] 42 | 43 | dynamic_axes = None 44 | onnx_save_path = 'rpn_backbone_resnet50.onnx' 45 | torch.onnx.export(model, torch.rand(1, 3, input_height, input_width), onnx_save_path, verbose=False, 46 | do_constant_folding=True, 47 | input_names=["input"], output_names=output_names, 48 | dynamic_axes=dynamic_axes, 49 | opset_version=11) 50 | 51 | import onnxsim 52 | import onnx 53 | model = onnx.load(onnx_save_path) 54 | # convert model 55 | model_simp, check = onnxsim.simplify(model, check_n=0,input_shapes={'input':[1,3,input_height,input_width]}, 56 | dynamic_input_shape=False) 57 | with open(onnx_save_path,'wb') as f: 58 | onnx.save(model_simp, f) 59 | 60 | -------------------------------------------------------------------------------- /test/x04testRPNonnx.py: -------------------------------------------------------------------------------- 1 | import onnxruntime as rt 2 | import numpy as np 3 | import torch 4 | import torchvision 5 | import cv2 6 | from torchvision import transforms 7 | 8 | def get_classes(filepath): 9 | with open(filepath, 'r', encoding='gbk') as f: 10 | return [item.strip() for item in f.readlines()] 11 | 12 | 13 | if __name__ == '__main__': 14 | onnx_save_path = "rpn_backbone_resnet50.onnx" 15 | img = cv2.imread('./car.jpg') 16 | img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) 17 | img = cv2.resize(img, dsize=(800, 608)) 18 | 19 | normalize = transforms.Compose([ 20 | transforms.ToTensor(), 21 | transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), 22 | ]) 23 | img_tensor = normalize(img).unsqueeze(dim=0) 24 | img_input = img_tensor.numpy().astype(np.float32) 25 | 26 | sess = rt.InferenceSession(onnx_save_path) 27 | input_name = sess.get_inputs()[0].name 28 | label_names = [sess.get_outputs()[i].name for i in range(1)] 29 | 30 | pred_onnx = sess.run(label_names, {input_name:img_input}) 31 | # output without nms 32 | pred_onnx = dict(zip(label_names, pred_onnx)) 33 | 34 | image = cv2.cvtColor(img, cv2.COLOR_RGB2BGR) 35 | for box in pred_onnx['rpn_boxes'][0]: 36 | box = box[1:] 37 | cv2.rectangle(image, tuple(map(int,box[0:2])), tuple(map(int,box[2:4])), (0,255,0)) 38 | cv2.imshow("win", image) 39 | cv2.waitKey() 40 | cv2.destroyWindow("win") 41 | 42 | 43 | -------------------------------------------------------------------------------- /test/x06reduceRpnOnnx.py: -------------------------------------------------------------------------------- 1 | 2 | import onnx_graphsurgeon as gs 3 | import onnx 4 | import numpy as np 5 | 6 | # def getElementByName(graph, ) 7 | 8 | def cutOnnx(): 9 | onnx_save_path = "rpn_backbone_resnet50.onnx" 10 | graph = gs.import_onnx(onnx.load(onnx_save_path)) 11 | print(graph.outputs) 12 | graph.outputs = graph.outputs[0:-1] 13 | print(graph.outputs) 14 | graph.cleanup() 15 | # remove feature pool 16 | onnx.save(gs.export_onnx(graph), onnx_save_path) 17 | 18 | 19 | 20 | 21 | if __name__ == '__main__': 22 | cutOnnx() -------------------------------------------------------------------------------- /test/x07reduce_header_onnx.py: -------------------------------------------------------------------------------- 1 | import onnx_graphsurgeon as gs 2 | import onnx 3 | import numpy as np 4 | 5 | 6 | def cutOnnx(): 7 | onnx_save_path = "header.onnx" 8 | graph = gs.import_onnx(onnx.load(onnx_save_path)) 9 | 10 | tensors = graph.tensors() 11 | tensor = tensors["218"] 12 | graph.inputs = [graph.inputs[-1], tensor.to_variable(dtype=np.float32, shape=('N', 256, 7, 7))] 13 | graph.inputs[-1].name = "roialigned_feature" 14 | 15 | graph.outputs = [graph.outputs[0], graph.outputs[-1]] 16 | 17 | shape_score = gs.Constant(name="shape_score", values=np.array((-1, 90), dtype=np.int64)) 18 | shape_boxes = gs.Constant(name="shape_boxes", values=np.array((-1, 90, 4), dtype=np.int64)) 19 | shape_boxes_last_node = gs.Constant(name="shape_boxes_last_node", values=np.array((-1, 91, 4), dtype=np.int64)) 20 | 21 | # 这里的Reshape_320和Reshape_322是box和score的上一个reshape节点 22 | for node in graph.nodes: 23 | if node.name == "Reshape_320": 24 | node.inputs[-1] = shape_boxes 25 | elif node.name == "Reshape_322": 26 | node.inputs[-1] = shape_score 27 | # the last second reshape node relative to box output 28 | elif node.name == "Reshape_308": 29 | node.inputs[-1] = shape_boxes_last_node 30 | 31 | # 添加N,90,4 和 N,90,1的结点 32 | for item in graph.outputs: 33 | item.shape.insert(1, 90) 34 | # print(item.shape) 35 | for graph_output in graph.outputs: 36 | graph_output.shape[0] = 'N' 37 | graph.cleanup() 38 | new_onnx_filepath = 'new_'+onnx_save_path 39 | onnx.save(gs.export_onnx(graph), new_onnx_filepath) 40 | 41 | import onnxsim 42 | model = onnx.load(new_onnx_filepath) 43 | # convert model 44 | model_simp, check = onnxsim.simplify(model, check_n=0,input_shapes={'roialigned_feature':[1,256, 7, 7],'proposals':[1,4]}, 45 | dynamic_input_shape=True) 46 | 47 | onnx.save(model_simp, new_onnx_filepath) 48 | 49 | 50 | 51 | if __name__ == '__main__': 52 | cutOnnx() -------------------------------------------------------------------------------- /test/x08test_header_onnx.py: -------------------------------------------------------------------------------- 1 | import onnxruntime as rt 2 | import numpy as np 3 | import torch 4 | import torchvision 5 | import cv2 6 | from torchvision import transforms 7 | 8 | 9 | if __name__ == '__main__': 10 | 11 | sess = rt.InferenceSession('new_header.onnx') 12 | input_names = [item.name for item in sess.get_inputs()] 13 | output_names = [item.name for item in sess.get_outputs()] 14 | 15 | # proposal = np.array([1,1,10,10], dtype=np.float32).reshape(-1, 4) 16 | b = 10 17 | input_dict = dict( 18 | proposals = np.random.randn(b, 4).astype(dtype=np.float32), 19 | roialigned_feature = np.random.randn(b, 256, 7, 7).astype(dtype=np.float32) 20 | ) 21 | pred_onnx = sess.run(output_names, input_dict) 22 | pred_onnx = dict(zip(output_names, pred_onnx)) 23 | print(pred_onnx['boxes'].shape) 24 | # print(pred_onnx['boxes']) 25 | print(pred_onnx['scores'].shape) 26 | # print(pred_onnx['scores']) 27 | 28 | --------------------------------------------------------------------------------