├── .nav ├── packages ├── on_demand_video_decoder │ ├── examples │ │ ├── __init__.py │ │ └── index_frame.json │ ├── samples │ │ └── __init__.py │ ├── ext_impl │ │ ├── external │ │ │ └── .clang-format │ │ └── src │ │ │ ├── VideoCodecSDKUtils │ │ │ ├── .clang-format │ │ │ └── helper_classes │ │ │ │ └── Utils │ │ │ │ ├── cuvid_dlopen.h │ │ │ │ ├── cuvid_dlopen_unix.cpp │ │ │ │ ├── cuvid_dlopen_windows.cpp │ │ │ │ ├── ColorSpace.h │ │ │ │ └── BitDepth.cu │ │ │ ├── PyNvOnDemandDecoder │ │ │ ├── inc │ │ │ │ ├── Version.hpp.in │ │ │ │ ├── PyNvOnDemandDecoder.hpp │ │ │ │ ├── GPUMemoryPool.hpp │ │ │ │ ├── DLPackUtils.hpp │ │ │ │ └── ExternalBuffer.hpp │ │ │ ├── src │ │ │ │ ├── ColorConvertKernels.cuh │ │ │ │ ├── PyNvOnDemandDecoder.cpp │ │ │ │ ├── PyRGBFrame.cpp │ │ │ │ └── GPUMemoryPool.cpp │ │ │ └── __init__.py │ │ │ ├── CMakeLists.txt │ │ │ └── cmake │ │ │ └── ffmpeg.cmake │ ├── docs │ │ ├── images │ │ │ ├── overview.png │ │ │ ├── random_access.png │ │ │ ├── stream_access.png │ │ │ ├── separation_access.png │ │ │ └── demuxer_free_access.png │ │ ├── api.rst │ │ ├── index.rst │ │ └── pytorch_integration_examples │ │ │ └── index.rst │ ├── data │ │ └── sample_clip │ │ │ ├── moving_shape_rect_h265.mp4 │ │ │ ├── moving_shape_circle_h265.mp4 │ │ │ ├── moving_shape_ellipse_h265.mp4 │ │ │ ├── moving_shape_hexagon_h265.mp4 │ │ │ └── moving_shape_triangle_h265.mp4 │ ├── docu_referenced_dirs.txt │ ├── pyproject.toml │ ├── setup.py │ └── tests │ │ └── test_random_decoder.py ├── batching_helpers │ ├── requirements-optional.txt │ ├── requirements.txt │ ├── docs │ │ ├── images │ │ │ ├── Combine_ragged.png │ │ │ ├── Mapping_ragged.png │ │ │ ├── Split_ragged.png │ │ │ ├── BatchedCostMatrix.png │ │ │ ├── RaggedBatchExample.png │ │ │ ├── UnbatchedCostMatrix.png │ │ │ ├── BatchedIndexWrite_ragged.png │ │ │ ├── BatchedIndexing_ragged.png │ │ │ ├── Compactification_ragged.png │ │ │ ├── IndicesFromMask_ragged.png │ │ │ ├── MaskFromIndices_ragged.png │ │ │ ├── BatchedBoolIndexAccess_ragged.png │ │ │ ├── BatchedBoolIndexWrite_ragged.png │ │ │ ├── BatchedInverseIndexing_ragged.png │ │ │ ├── BatchedLossComputation_object_gt.png │ │ │ ├── BatchedLossComputation_object_pred.png │ │ │ ├── UnbatchedLossComputation_object_gt.png │ │ │ ├── UnbatchedLossComputation_object_pred.png │ │ │ ├── BatchedLossComputation_per_object_loss.png │ │ │ └── UnbatchedLossComputation_per_object_loss.png │ │ ├── api.rst │ │ ├── index.rst │ │ └── introduction.rst │ ├── docu_referenced_dirs.txt │ ├── pyproject.toml │ ├── accvlab │ │ └── batching_helpers │ │ │ ├── data_format │ │ │ ├── __init__.py │ │ │ └── set_padded_to.py │ │ │ ├── cpp_impl │ │ │ └── batched_indexing_access_cpu.cpp │ │ │ ├── __init__.py │ │ │ └── batched_mask_from_indices.py │ └── example │ │ └── input_data_helper.py ├── draw_heatmap │ ├── requirements-optional.txt │ ├── requirements.txt │ ├── docs │ │ ├── images │ │ │ └── bboxes_to_heatmap.png │ │ ├── index.rst │ │ ├── api.rst │ │ └── examples.rst │ ├── docu_referenced_dirs.txt │ ├── pyproject.toml │ ├── accvlab │ │ └── draw_heatmap │ │ │ ├── __init__.py │ │ │ └── funtions │ │ │ └── __init__.py │ ├── benchmark_cpp │ │ └── CMakeLists.txt │ ├── examples │ │ ├── draw_heatmap.py │ │ ├── draw_heatmap_batched.py │ │ ├── input_data.py │ │ └── draw_heatmap_batched_classwise.py │ └── setup.py ├── dali_pipeline_framework │ ├── docs │ │ ├── images │ │ │ ├── sequence_sampling.png │ │ │ ├── high_level_pipeline.png │ │ │ ├── sample_data_group_example.png │ │ │ └── nu_scenes_data_loader_design.png │ │ ├── api │ │ │ ├── inputs.rst │ │ │ ├── pipeline.rst │ │ │ ├── processing_steps.rst │ │ │ ├── internal_helpers.rst │ │ │ ├── additional_api.rst │ │ │ ├── operators_impl.rst │ │ │ └── main_api.rst │ │ ├── index.rst │ │ ├── examples │ │ │ ├── stream_petr │ │ │ │ └── index.rst │ │ │ ├── 2d_object_detection │ │ │ │ └── index.rst │ │ │ └── flexible_step │ │ │ │ ├── index.rst │ │ │ │ ├── simple_step.rst │ │ │ │ └── flexible_step.rst │ │ ├── design │ │ │ └── output.rst │ │ ├── examples.rst │ │ └── evaluation.rst │ ├── docu_referenced_dirs.txt │ ├── accvlab │ │ └── dali_pipeline_framework │ │ │ ├── operators_impl │ │ │ ├── python_operator_functions │ │ │ │ └── __init__.py │ │ │ ├── numba_operators │ │ │ │ └── __init__.py │ │ │ └── __init__.py │ │ │ ├── __init__.py │ │ │ ├── pipeline │ │ │ └── __init__.py │ │ │ ├── inputs │ │ │ └── __init__.py │ │ │ ├── internal_helpers │ │ │ ├── __init__.py │ │ │ └── mini_parser │ │ │ │ └── __init__.py │ │ │ └── processing_steps │ │ │ ├── data_group_in_path_applied_step.py │ │ │ └── data_group_array_in_path_elements_applied_step.py │ ├── examples │ │ ├── pipeline_setup │ │ │ ├── helper_funcs.py │ │ │ ├── __init__.py │ │ │ └── additional_impl │ │ │ │ └── data_loading │ │ │ │ └── __init__.py │ │ ├── input_definitions.py │ │ └── prepare_dataset.py │ ├── pyproject.toml │ ├── tests │ │ ├── internal_helpers │ │ │ └── mini_parser │ │ │ │ ├── parser_test.py │ │ │ │ └── lexer_test.py │ │ └── inputs │ │ │ └── _test_helpers.py │ ├── setup.py │ └── ext_impl │ │ └── CMakeLists.txt ├── example_package │ ├── docs │ │ ├── index.rst │ │ ├── api.rst │ │ ├── intro.rst │ │ └── examples.rst │ ├── docu_referenced_dirs.txt │ ├── pyproject.toml │ ├── examples │ │ └── basic_usage.py │ ├── ext_impl │ │ ├── include │ │ │ └── external_cuda_ops.h │ │ ├── src │ │ │ └── external_cuda_ops.cpp │ │ └── build_and_copy.sh │ ├── accvlab │ │ └── example_package │ │ │ ├── functions │ │ │ └── __init__.py │ │ │ ├── include │ │ │ └── examples.h │ │ │ └── __init__.py │ └── tests │ │ ├── test_example_package_ext.py │ │ └── test_example_package.py ├── optim_test_tools │ ├── docs │ │ ├── api.rst │ │ ├── index.rst │ │ ├── examples.rst │ │ └── examples │ │ │ ├── nvtx_range_wrapper.rst │ │ │ └── stopwatch.rst │ ├── docu_referenced_dirs.txt │ ├── pyproject.toml │ ├── setup.py │ └── accvlab │ │ └── optim_test_tools │ │ ├── __init__.py │ │ └── singleton_base.py └── example_skbuild_package │ ├── docs │ ├── index.rst │ ├── intro.rst │ └── api.rst │ ├── docu_referenced_dirs.txt │ ├── pyproject.toml │ ├── accvlab │ └── example_skbuild_package │ │ ├── functions │ │ ├── __init__.py │ │ └── functions.py │ │ └── __init__.py │ ├── ext_impl │ ├── include │ │ └── external_cuda_ops.h │ └── src │ │ └── external_cuda_ops.cpp │ ├── setup.py │ └── tests │ └── test_example_skbuild_package.py ├── docs ├── project_overview │ ├── .gitignore │ └── IMPORTANT.txt ├── requirements.txt ├── contained_package_docs_mirror │ ├── .gitignore │ └── IMPORTANT.txt ├── guides_index.rst ├── .gitignore ├── Makefile ├── _ext │ └── module_docstring.py ├── SHARED_CONFIG_GUIDE.txt ├── sync_root_readme_for_docs.py └── spelling_wordlist.txt ├── .gitignore ├── .clang-format ├── .gitmodules ├── pyproject.toml ├── scripts ├── install_local.sh └── formatting │ ├── black_format_subpackage.sh │ └── format_subpackage.sh ├── docker └── run_docker_build.sh ├── namespace_packages_config.py └── CONTRIBUTING.MD /.nav: -------------------------------------------------------------------------------- 1 | project root -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/examples/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/samples/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/project_overview/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | !IMPORTANT.txt 4 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/external/.clang-format: -------------------------------------------------------------------------------- 1 | DisableFormat: true -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/VideoCodecSDKUtils/.clang-format: -------------------------------------------------------------------------------- 1 | DisableFormat: true -------------------------------------------------------------------------------- /packages/batching_helpers/requirements-optional.txt: -------------------------------------------------------------------------------- 1 | # Optional requirements for batching_helpers 2 | pytest -------------------------------------------------------------------------------- /packages/batching_helpers/requirements.txt: -------------------------------------------------------------------------------- 1 | torch>=2.0.0 2 | numpy>=1.22.2 3 | accvlab-build-config>=0.1.0 -------------------------------------------------------------------------------- /packages/draw_heatmap/requirements-optional.txt: -------------------------------------------------------------------------------- 1 | # Optional requirements for draw_heatmap 2 | pytest 3 | shapely -------------------------------------------------------------------------------- /packages/draw_heatmap/requirements.txt: -------------------------------------------------------------------------------- 1 | torch>=2.0.0 2 | accvlab.batching_helpers>=0.1.0 3 | accvlab-build-config>=0.1.0 4 | -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/Combine_ragged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/Combine_ragged.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/Mapping_ragged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/Mapping_ragged.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/Split_ragged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/Split_ragged.png -------------------------------------------------------------------------------- /packages/draw_heatmap/docs/images/bboxes_to_heatmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/draw_heatmap/docs/images/bboxes_to_heatmap.png -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/docs/images/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/on_demand_video_decoder/docs/images/overview.png -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx>=5.0.0 2 | sphinx-rtd-theme>=1.0.0 3 | sphinx-autodoc-typehints>=1.19.0 4 | myst-parser>=0.18.0 5 | linkify-it-py>=2.0.0 6 | sphinx-autobuild -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/BatchedCostMatrix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/BatchedCostMatrix.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/RaggedBatchExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/RaggedBatchExample.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/UnbatchedCostMatrix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/UnbatchedCostMatrix.png -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/docs/images/random_access.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/on_demand_video_decoder/docs/images/random_access.png -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/docs/images/stream_access.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/on_demand_video_decoder/docs/images/stream_access.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/BatchedIndexWrite_ragged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/BatchedIndexWrite_ragged.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/BatchedIndexing_ragged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/BatchedIndexing_ragged.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/Compactification_ragged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/Compactification_ragged.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/IndicesFromMask_ragged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/IndicesFromMask_ragged.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/MaskFromIndices_ragged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/MaskFromIndices_ragged.png -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/images/sequence_sampling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/dali_pipeline_framework/docs/images/sequence_sampling.png -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/docs/images/separation_access.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/on_demand_video_decoder/docs/images/separation_access.png -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/images/high_level_pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/dali_pipeline_framework/docs/images/high_level_pipeline.png -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/docs/images/demuxer_free_access.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/on_demand_video_decoder/docs/images/demuxer_free_access.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/BatchedBoolIndexAccess_ragged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/BatchedBoolIndexAccess_ragged.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/BatchedBoolIndexWrite_ragged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/BatchedBoolIndexWrite_ragged.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/BatchedInverseIndexing_ragged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/BatchedInverseIndexing_ragged.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/BatchedLossComputation_object_gt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/BatchedLossComputation_object_gt.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/BatchedLossComputation_object_pred.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/BatchedLossComputation_object_pred.png -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/UnbatchedLossComputation_object_gt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/UnbatchedLossComputation_object_gt.png -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/images/sample_data_group_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/dali_pipeline_framework/docs/images/sample_data_group_example.png -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/data/sample_clip/moving_shape_rect_h265.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/on_demand_video_decoder/data/sample_clip/moving_shape_rect_h265.mp4 -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/UnbatchedLossComputation_object_pred.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/UnbatchedLossComputation_object_pred.png -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/images/nu_scenes_data_loader_design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/dali_pipeline_framework/docs/images/nu_scenes_data_loader_design.png -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/data/sample_clip/moving_shape_circle_h265.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/on_demand_video_decoder/data/sample_clip/moving_shape_circle_h265.mp4 -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/BatchedLossComputation_per_object_loss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/BatchedLossComputation_per_object_loss.png -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/data/sample_clip/moving_shape_ellipse_h265.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/on_demand_video_decoder/data/sample_clip/moving_shape_ellipse_h265.mp4 -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/data/sample_clip/moving_shape_hexagon_h265.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/on_demand_video_decoder/data/sample_clip/moving_shape_hexagon_h265.mp4 -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/data/sample_clip/moving_shape_triangle_h265.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/on_demand_video_decoder/data/sample_clip/moving_shape_triangle_h265.mp4 -------------------------------------------------------------------------------- /docs/contained_package_docs_mirror/.gitignore: -------------------------------------------------------------------------------- 1 | # Mirror directory of package docs (symlinks by default) 2 | # Ignore all mirrored entries; keep this file tracked 3 | * 4 | !.gitignore 5 | !IMPORTANT.txt 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/batching_helpers/docs/images/UnbatchedLossComputation_per_object_loss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVIDIA/ACCV-Lab/main/packages/batching_helpers/docs/images/UnbatchedLossComputation_per_object_loss.png -------------------------------------------------------------------------------- /packages/draw_heatmap/docs/index.rst: -------------------------------------------------------------------------------- 1 | Draw Heatmap 2 | ============ 3 | 4 | Documentation for the draw heatmap package. 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | intro 10 | api 11 | examples -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/api/inputs.rst: -------------------------------------------------------------------------------- 1 | Inputs Submodule 2 | ================ 3 | 4 | .. automodule:: accvlab.dali_pipeline_framework.inputs 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/api/pipeline.rst: -------------------------------------------------------------------------------- 1 | Pipeline Submodule 2 | ================== 3 | 4 | .. automodule:: accvlab.dali_pipeline_framework.pipeline 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: -------------------------------------------------------------------------------- /docs/project_overview/IMPORTANT.txt: -------------------------------------------------------------------------------- 1 | The other files contained ine this folder are modified copies of other files. 2 | Please do not modify them manually, as they will be overwritten when building the documentation. 3 | Instead, edit the original files. -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/api/processing_steps.rst: -------------------------------------------------------------------------------- 1 | Processing Steps Submodule 2 | ========================== 3 | 4 | .. automodule:: accvlab.dali_pipeline_framework.processing_steps 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | **/build/ 3 | **/_skbuild/ 4 | 5 | .vscode/ 6 | *.code-workspace 7 | 8 | *.egg-info/ 9 | **/*.egg-info/ 10 | 11 | *.pyc 12 | __pycache__/ 13 | .pytest_cache/ 14 | *.pyo 15 | *.pyd 16 | .Python 17 | *.so 18 | *.whl 19 | 20 | *.log 21 | 22 | -------------------------------------------------------------------------------- /packages/batching_helpers/docs/api.rst: -------------------------------------------------------------------------------- 1 | .. contents:: API 2 | 3 | 4 | API Reference 5 | ============= 6 | 7 | .. automodule:: accvlab.batching_helpers 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /packages/example_package/docs/index.rst: -------------------------------------------------------------------------------- 1 | Example Package 2 | =============== 3 | 4 | This is the documentation for the ``accvlab.example_package`` package. 5 | 6 | This documentation contains the following sections: 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | 11 | intro 12 | examples 13 | api -------------------------------------------------------------------------------- /packages/optim_test_tools/docs/api.rst: -------------------------------------------------------------------------------- 1 | API Reference 2 | ============= 3 | 4 | Complete API documentation for the optim_test_tools package. 5 | 6 | .. currentmodule:: accvlab.optim_test_tools 7 | 8 | .. automodule:: accvlab.optim_test_tools 9 | :members: 10 | :undoc-members: 11 | :show-inheritance: -------------------------------------------------------------------------------- /packages/example_skbuild_package/docs/index.rst: -------------------------------------------------------------------------------- 1 | Example Skbuild Package 2 | ======================= 3 | 4 | This is the documentation for the ``accvlab.example_skbuild_package`` package. 5 | 6 | This documentation contains the following sections: 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | 11 | intro 12 | api -------------------------------------------------------------------------------- /packages/draw_heatmap/docs/api.rst: -------------------------------------------------------------------------------- 1 | API Reference 2 | ============= 3 | 4 | Complete API documentation for the draw_heatmap package. 5 | 6 | .. currentmodule:: accvlab.draw_heatmap 7 | 8 | .. automodule:: accvlab.draw_heatmap 9 | :members: 10 | :undoc-members: 11 | :show-inheritance: 12 | :special-members: __init__ -------------------------------------------------------------------------------- /packages/batching_helpers/docu_referenced_dirs.txt: -------------------------------------------------------------------------------- 1 | # This file lists additional directories (besides docs) that are referenced by documentation 2 | # The docs directory is always mirrored automatically 3 | # Add one directory name per line, without the docs directory 4 | # Lines starting with # are comments and are ignored 5 | 6 | example -------------------------------------------------------------------------------- /packages/optim_test_tools/docu_referenced_dirs.txt: -------------------------------------------------------------------------------- 1 | # This file lists additional directories (besides docs) that are referenced by documentation 2 | # The docs directory is always mirrored automatically 3 | # Add one directory name per line, without the docs directory 4 | # Lines starting with # are comments and are ignored 5 | 6 | examples -------------------------------------------------------------------------------- /packages/optim_test_tools/docs/index.rst: -------------------------------------------------------------------------------- 1 | Optimization Testing Tools 2 | ========================== 3 | 4 | This is the documentation for the ``accvlab.optim_test_tools`` package. 5 | 6 | This documentation contains the following sections: 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | 11 | intro 12 | api 13 | examples 14 | -------------------------------------------------------------------------------- /packages/example_package/docs/api.rst: -------------------------------------------------------------------------------- 1 | API Reference 2 | ============= 3 | 4 | Complete API documentation for the example_package package. 5 | 6 | .. currentmodule:: accvlab.example_package 7 | 8 | .. automodule:: accvlab.example_package 9 | :members: 10 | :undoc-members: 11 | :show-inheritance: 12 | :special-members: __init__ -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/docs/api.rst: -------------------------------------------------------------------------------- 1 | API Reference 2 | ============= 3 | 4 | Complete API documentation for the on_demand_video_decoder package. 5 | 6 | .. currentmodule:: accvlab.on_demand_video_decoder 7 | 8 | .. automodule:: accvlab.on_demand_video_decoder 9 | :members: 10 | :imported-members: 11 | :show-inheritance: -------------------------------------------------------------------------------- /docs/guides_index.rst: -------------------------------------------------------------------------------- 1 | Guides 2 | ====== 3 | 4 | The guides are listed here in the suggested order of reading. 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | guides/INSTALLATION_GUIDE 10 | guides/DOCKER_GUIDE 11 | guides/DEVELOPMENT_GUIDE 12 | guides/FORMATTING_GUIDE 13 | guides/DOCUMENTATION_SETUP_GUIDE 14 | guides/CONTRIBUTION_GUIDE 15 | 16 | 17 | -------------------------------------------------------------------------------- /packages/example_skbuild_package/docs/intro.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | This is the documentation for the **example_skbuild_package** package. 5 | 6 | Note that this package is an example of a package that uses the skbuild build system. 7 | Please see the :doc:`../../example_package/docs/index` package for a more elaborate example for how to 8 | set up the documentation. -------------------------------------------------------------------------------- /packages/example_skbuild_package/docs/api.rst: -------------------------------------------------------------------------------- 1 | API Reference 2 | ============= 3 | 4 | Complete API documentation for the ``accvlab.example_skbuild_package`` package. 5 | 6 | .. currentmodule:: accvlab.example_skbuild_package 7 | 8 | .. automodule:: accvlab.example_skbuild_package 9 | :members: 10 | :undoc-members: 11 | :show-inheritance: 12 | :special-members: __init__ -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/index.rst: -------------------------------------------------------------------------------- 1 | DALI Pipeline Framework 2 | ======================= 3 | 4 | This is the documentation for the ``accvlab.dali_pipeline_framework`` package. 5 | 6 | This documentation contains the following sections: 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | 11 | design 12 | api/main_api 13 | api/additional_api 14 | examples 15 | evaluation -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _build/ 2 | 3 | # Ignore contents of the folder but not the folder itself 4 | # Note that this is an important distincltion and if the 5 | # folder itself is ignored (i.e. no `*` in the line below), 6 | # we cannot make exceptions for any files in the folder. 7 | autocopied_contained_packages/* 8 | # Do not ignore the IMPORTANT.txt file 9 | !autocopied_contained_packages/IMPORTANT.txt 10 | -------------------------------------------------------------------------------- /packages/batching_helpers/docs/index.rst: -------------------------------------------------------------------------------- 1 | Batching Helpers 2 | ================ 3 | 4 | This is the documentation for the ``accvlab.batching_helpers`` package. 5 | 6 | 7 | This documentation contains the following sections: 8 | 9 | .. toctree:: 10 | :maxdepth: 1 11 | 12 | introduction 13 | api 14 | example 15 | evaluation 16 | 17 | 18 | .. 19 | Index 20 | ----- 21 | * :ref:`genindex` 22 | -------------------------------------------------------------------------------- /packages/draw_heatmap/docu_referenced_dirs.txt: -------------------------------------------------------------------------------- 1 | # This file lists additional directories (besides docs) that are referenced by documentation 2 | # The docs directory is always mirrored automatically 3 | # Add one directory name per line, without the docs directory 4 | # Lines starting with # are comments and are ignored 5 | 6 | # Example: if your documentation references code in the examples directory, uncomment the lines below 7 | examples -------------------------------------------------------------------------------- /packages/example_package/docu_referenced_dirs.txt: -------------------------------------------------------------------------------- 1 | # This file lists additional directories (besides docs) that are referenced by documentation 2 | # The docs directory is always mirrored automatically 3 | # Add one directory name per line, without the docs directory 4 | # Lines starting with # are comments and are ignored 5 | 6 | # Example: if your documentation references code in the examples directory, uncomment the lines below 7 | examples -------------------------------------------------------------------------------- /packages/example_skbuild_package/docu_referenced_dirs.txt: -------------------------------------------------------------------------------- 1 | # This file lists additional directories (besides docs) that are referenced by documentation 2 | # The docs directory is always mirrored automatically 3 | # Add one directory name per line, without the docs directory 4 | # Lines starting with # are comments and are ignored 5 | 6 | # Example: if your documentation references code in the examples directory, uncomment the lines below 7 | # examples -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/docs/index.rst: -------------------------------------------------------------------------------- 1 | On Demand Video Decoder 2 | ======================= 3 | 4 | This is the documentation for the ``accvlab.on_demand_video_decoder`` package. 5 | 6 | This documentation contains the following sections: 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | 11 | intro 12 | installation 13 | dataset_preparation 14 | api 15 | sample 16 | pytorch_integration_examples/index 17 | evaluation 18 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docu_referenced_dirs.txt: -------------------------------------------------------------------------------- 1 | # This file lists additional directories (besides docs) that are referenced by documentation 2 | # The docs directory is always mirrored automatically 3 | # Add one directory name per line, without the docs directory 4 | # Lines starting with # are comments and are ignored 5 | 6 | # Example: if your documentation references code in the examples directory, uncomment the lines below 7 | examples 8 | accvlab -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/docu_referenced_dirs.txt: -------------------------------------------------------------------------------- 1 | # This file lists additional directories (besides docs) that are referenced by documentation 2 | # The docs directory is always mirrored automatically 3 | # Add one directory name per line, without the docs directory 4 | # Lines starting with # are comments and are ignored 5 | 6 | # Example: if your documentation references code in the examples directory, uncomment the lines below 7 | examples 8 | samples -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/api/internal_helpers.rst: -------------------------------------------------------------------------------- 1 | Internal Helpers Submodule 2 | =========================== 3 | 4 | .. automodule:: accvlab.dali_pipeline_framework.internal_helpers 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | 10 | Mini-Parser 11 | ----------- 12 | 13 | .. automodule:: accvlab.dali_pipeline_framework.internal_helpers.mini_parser 14 | :members: 15 | :undoc-members: 16 | :show-inheritance: -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/examples/stream_petr/index.rst: -------------------------------------------------------------------------------- 1 | StreamPETR Pipeline 2 | =================== 3 | 4 | This example consists of the following parts: 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | 9 | pipeline_setup 10 | custom_processing_step 11 | custom_post_processing 12 | 13 | .. important:: 14 | 15 | You can run the example using the script 16 | ``packages/dali_pipeline_framework/examples/example_pipeline_stream_petr.py``. -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/accvlab/dali_pipeline_framework/operators_impl/python_operator_functions/__init__.py: -------------------------------------------------------------------------------- 1 | from .python_operator_functions import ( 2 | apply_transform_to_points, 3 | add_post_transform_to_projection_matrix, 4 | apply_clipping_and_get_with_clipping_info, 5 | get_is_active, 6 | pad_to_common_size, 7 | ) 8 | 9 | __all__ = [ 10 | "apply_transform_to_points", 11 | "add_post_transform_to_projection_matrix", 12 | "apply_clipping_and_get_with_clipping_info", 13 | "get_is_active", 14 | "pad_to_common_size", 15 | ] 16 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Google 4 | # Override Google style defaults 5 | IndentWidth: 4 6 | DerivePointerAlignment: false 7 | PointerAlignment: Left 8 | ReferenceAlignment: Left 9 | ColumnLimit: 110 10 | 11 | # Do not sort includes, as they may be grouped and/or sorted (e.g. by scope 12 | # from standard libraries to local files) 13 | SortIncludes: false 14 | 15 | # This is important to not mess up lines in the comments which may be there for a reason 16 | # (e.g. retaining the original formatting of license headers etc.) 17 | ReflowComments: false 18 | 19 | #... -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "packages/on_demand_video_decoder/ext_impl/external/NVTX"] 2 | path = packages/on_demand_video_decoder/ext_impl/external/NVTX 3 | url = https://github.com/NVIDIA/NVTX.git 4 | 5 | [submodule "packages/on_demand_video_decoder/ext_impl/external/dlpack"] 6 | path = packages/on_demand_video_decoder/ext_impl/external/dlpack 7 | url = https://github.com/dmlc/dlpack.git 8 | 9 | [submodule "packages/on_demand_video_decoder/ext_impl/external/pybind11"] 10 | path = packages/on_demand_video_decoder/ext_impl/external/pybind11 11 | url = https://github.com/pybind/pybind11.git 12 | -------------------------------------------------------------------------------- /packages/example_package/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=64", "wheel", "torch>=2.0.0"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "accvlab.example_package" 7 | version = "0.1.0" 8 | description = "ACCV-Lab Example Package" 9 | requires-python = ">=3.8" 10 | dependencies = [ 11 | "torch>=2.0.0", 12 | "numpy>=1.22.2", 13 | "accvlab-build-config>=0.1.0", 14 | ] 15 | 16 | [project.optional-dependencies] 17 | optional = [ 18 | "pytest", 19 | ] 20 | 21 | [tool.setuptools.packages.find] 22 | where = ["."] 23 | include = ["accvlab.example_package*"] -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | # Tool configurations only - package metadata handled by individual package setup.py files 2 | [build-system] 3 | requires = ["setuptools>=61.0"] 4 | build-backend = "setuptools.build_meta" 5 | 6 | [tool.black] 7 | line-length = 110 8 | target-version = ['py38', 'py39', 'py310', 'py311'] 9 | include = '\.pyi?$' 10 | skip_string_normalization = true 11 | preview = true 12 | extend-exclude = ''' 13 | /( 14 | # directories 15 | \.eggs 16 | | \.git 17 | | \.hg 18 | | \.mypy_cache 19 | | \.tox 20 | | \.venv 21 | | _build 22 | | buck-out 23 | | build 24 | | dist 25 | | demos 26 | )/ 27 | ''' 28 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/api/additional_api.rst: -------------------------------------------------------------------------------- 1 | Additional API Reference 2 | ======================== 3 | 4 | .. note:: 5 | This page contains the documentation of some helpers which are used internally, and can be useful 6 | when implementing custom processing steps. For the most commonly used functionality, see the 7 | :doc:`main_api` page. 8 | 9 | 10 | .. autosummary:: 11 | 12 | accvlab.dali_pipeline_framework.internal_helpers 13 | accvlab.dali_pipeline_framework.operators_impl 14 | 15 | 16 | .. toctree:: 17 | :hidden: 18 | :maxdepth: 1 19 | 20 | internal_helpers 21 | operators_impl -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/examples/index_frame.json: -------------------------------------------------------------------------------- 1 | { 2 | "/data/nuscenes/video_samples/": { 3 | "n008-2018-08-01-15-16-36-0400": 200, 4 | "n008-2018-08-27-11-48-51-0400": 200, 5 | "n008-2018-08-28-16-43-51-0400": 200, 6 | "n008-2018-08-30-15-16-55-0400": 200, 7 | "n015-2018-07-24-11-22-45+0800": 200, 8 | "n015-2018-10-02-10-50-40+0800": 200, 9 | "n015-2018-10-08-15-36-50+0800": 200, 10 | "n015-2018-11-21-19-38-26+0800__part0": 200, 11 | "n015-2018-11-21-19-38-26+0800__part1": 200, 12 | "n015-2018-11-21-19-38-26+0800__part2": 200 13 | } 14 | } -------------------------------------------------------------------------------- /packages/batching_helpers/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=64", "wheel", "torch>=2.0.0"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "accvlab.batching_helpers" 7 | version = "0.1.0" 8 | description = "Batching Helpers Package (part of the ACCV-Lab package)." 9 | requires-python = ">=3.8" 10 | dependencies = [ 11 | "torch>=2.0.0", 12 | "numpy>=1.22.2", 13 | "accvlab-build-config>=0.1.0", 14 | ] 15 | 16 | [project.optional-dependencies] 17 | optional = [ 18 | "pytest", 19 | ] 20 | 21 | [tool.setuptools.packages.find] 22 | where = ["."] 23 | include = ["accvlab.batching_helpers*"] -------------------------------------------------------------------------------- /packages/draw_heatmap/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=61.0", "wheel", "torch>=2.0.0", "ninja"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "accvlab.draw_heatmap" 7 | version = "0.1.0" 8 | description = "Draw Heatmap Package (part of the ACCV-Lab package)." 9 | requires-python = ">=3.8" 10 | dependencies = [ 11 | "torch>=2.0.0", 12 | "accvlab.batching_helpers>=0.1.0", 13 | "accvlab-build-config>=0.1.0", 14 | ] 15 | 16 | [project.optional-dependencies] 17 | optional = [ 18 | "pytest", 19 | "shapely", 20 | ] 21 | 22 | [tool.setuptools.packages.find] 23 | where = ["."] 24 | include = ["accvlab.draw_heatmap*"] -------------------------------------------------------------------------------- /packages/example_skbuild_package/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=64", "wheel", "torch>=2.0.0", "scikit-build>=0.17.0", "pybind11>=2.10.0"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "accvlab.example_skbuild_package" 7 | version = "0.1.0" 8 | description = "ACCV-Lab SKBuild Example Package" 9 | requires-python = ">=3.8" 10 | dependencies = [ 11 | "torch>=2.0.0", 12 | "numpy>=1.22.2", 13 | "accvlab-build-config>=0.1.0", 14 | ] 15 | 16 | [project.optional-dependencies] 17 | optional = [ 18 | "pytest", 19 | ] 20 | 21 | [tool.setuptools.packages.find] 22 | where = ["."] 23 | include = ["accvlab.example_skbuild_package*"] -------------------------------------------------------------------------------- /packages/optim_test_tools/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=64", "wheel", "torch>=2.0.0"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "accvlab.optim_test_tools" 7 | version = "0.1.0" 8 | description = "Optimization Testing Tools Package (part of the ACCV-Lab package)." 9 | requires-python = ">=3.8" 10 | dependencies = [ 11 | "torch>=2.0.0", 12 | "numpy>=1.22.2", 13 | "accvlab-build-config>=0.1.0", 14 | "psutil", 15 | ] 16 | 17 | [project.optional-dependencies] 18 | optional = [ 19 | "opencv-python-headless", 20 | "pytest", 21 | ] 22 | 23 | [tool.setuptools.packages.find] 24 | where = ["."] 25 | include = ["accvlab.optim_test_tools*"] -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/api/operators_impl.rst: -------------------------------------------------------------------------------- 1 | Operators Impl Submodule 2 | ======================== 3 | 4 | Package Module 5 | -------------- 6 | 7 | .. automodule:: accvlab.dali_pipeline_framework.operators_impl 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | 12 | Numba Operators 13 | --------------- 14 | 15 | .. automodule:: accvlab.dali_pipeline_framework.operators_impl.numba_operators 16 | :members: 17 | :undoc-members: 18 | :show-inheritance: 19 | 20 | 21 | Python Operator Functions 22 | ------------------------- 23 | 24 | .. automodule:: accvlab.dali_pipeline_framework.operators_impl.python_operator_functions 25 | :members: 26 | :undoc-members: 27 | :show-inheritance: -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/examples/2d_object_detection/index.rst: -------------------------------------------------------------------------------- 1 | 2D Object Detection Pipeline 2 | ============================ 3 | 4 | This example consists of the following parts: 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | 9 | pipeline_setup 10 | 11 | .. important:: 12 | 13 | You can run the example using the script 14 | ``packages/dali_pipeline_framework/examples/example_pipeline_obj_det_2d.py``. 15 | 16 | .. important:: 17 | 18 | Before running the example, you must prepare the NuScenes 2D image annotations by executing 19 | the script ``packages/dali_pipeline_framework/examples/prepare_dataset.py``. This generates the 20 | ``image_annotations.json`` file expected by the 2D object detection pipeline. -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/examples/flexible_step/index.rst: -------------------------------------------------------------------------------- 1 | Flexible Step Implementation 2 | ============================ 3 | 4 | In this section, we will implement a simple image decoding step first and discuss the basic functionality 5 | needed for a pipeline processing step. Then, we will extend the processing step to a more generally reusable 6 | version. 7 | 8 | .. seealso:: 9 | 10 | The processing steps need to provide a fixed interface, which is defined in the base 11 | :class:`~accvlab.dali_pipeline_framework.processing_steps.PipelineStepBase` class. Please see 12 | :doc:`../../design/pipeline_processing_steps` for more details. 13 | 14 | .. toctree:: 15 | :maxdepth: 1 16 | 17 | simple_step 18 | flexible_step -------------------------------------------------------------------------------- /packages/optim_test_tools/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | from torch.utils.cpp_extension import BuildExtension 3 | import sys 4 | from pathlib import Path 5 | 6 | from accvlab_build_config import run_external_build 7 | 8 | 9 | def get_extensions(): 10 | """Return all extensions""" 11 | extensions = [] 12 | return extensions 13 | 14 | 15 | # Run external build before setup 16 | run_external_build(Path(__file__).parent) 17 | 18 | setup( 19 | name="accvlab.optim_test_tools", 20 | version="0.1.0", 21 | description="Optimization Testing Tools Package (part of the ACCV-Lab package).", 22 | ext_modules=get_extensions(), 23 | cmdclass={"build_ext": BuildExtension}, 24 | python_requires=">=3.8", 25 | zip_safe=False, 26 | ) 27 | -------------------------------------------------------------------------------- /packages/batching_helpers/accvlab/batching_helpers/data_format/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .ragged_batch import RaggedBatch 16 | 17 | __all__ = [] 18 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/docs/pytorch_integration_examples/index.rst: -------------------------------------------------------------------------------- 1 | PyTorch Integration Examples 2 | ============================ 3 | 4 | Example code locations: 5 | 6 | - Random Decode: ``packages/on_demand_video_decoder/examples/dataloader_random_decode/`` 7 | - Stream Decode: ``packages/on_demand_video_decoder/examples/dataloader_stream_decode/`` 8 | - Separation Decode: ``packages/on_demand_video_decoder/examples/dataloader_separation_decode/`` 9 | - Demuxer Free Decode: ``packages/on_demand_video_decoder/examples/demuxer_free_decode/`` 10 | 11 | This documentation contains the following sections: 12 | 13 | .. toctree:: 14 | :maxdepth: 1 15 | 16 | dataloader_random_decode.md 17 | dataloader_stream_decode.md 18 | dataloader_separation_decode.md 19 | dataloader_demuxer_free_decode.md 20 | -------------------------------------------------------------------------------- /packages/example_package/examples/basic_usage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Simple Example for ACCV-Lab Example Package. 4 | 5 | This example demonstrates basic usage of the example package functions. 6 | It's designed to show how examples can be included in documentation. 7 | """ 8 | 9 | import accvlab.example_package as example_pkg 10 | 11 | # @NOTE 12 | # This note will be highlighted in the documentation using the note-literalinclude directive (see the 13 | # Documentation Setup Guide for more details). 14 | 15 | 16 | def simple_example(): 17 | """Demonstrate simple function usage.""" 18 | print("=== Simple Example ===") 19 | 20 | # Use the hello function 21 | message = example_pkg.hello_examples() 22 | print(f"Message: {message}") 23 | 24 | 25 | if __name__ == "__main__": 26 | simple_example() 27 | -------------------------------------------------------------------------------- /packages/draw_heatmap/accvlab/draw_heatmap/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .funtions import draw_heatmap, draw_heatmap_batched 16 | 17 | __all__ = ["draw_heatmap", "draw_heatmap_batched"] 18 | -------------------------------------------------------------------------------- /packages/example_skbuild_package/accvlab/example_skbuild_package/functions/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .functions import vector_add, vector_scale 16 | 17 | __all__ = [ 18 | 'vector_add', 19 | 'vector_scale', 20 | ] 21 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/examples/pipeline_setup/helper_funcs.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import psutil 16 | 17 | 18 | def kill_subprocesses(): 19 | children = psutil.Process().children(recursive=True) 20 | for c in children: 21 | c.kill() 22 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "scikit-build", 5 | "numpy", 6 | "ninja; platform_system!='Windows'" 7 | ] 8 | build-backend = "setuptools.build_meta" 9 | 10 | [project] 11 | name = "accvlab.on_demand_video_decoder" 12 | version = "0.1.0" 13 | description = "On-demand video decoder (part of the ACCV-Lab package)." 14 | requires-python = ">=3.8" 15 | dependencies = [ 16 | "torch>=2.0.0", 17 | "numpy>=1.22.2", 18 | "accvlab-build-config>=0.1.0", 19 | ] 20 | 21 | [project.optional-dependencies] 22 | optional = [ 23 | "pytest", 24 | "pynvml", 25 | "pytest-timeout", 26 | ] 27 | 28 | [tool.skbuild] 29 | cmake.source-dir = "ext_impl" 30 | cmake.minimum-version = "3.18" 31 | cmake.install-dir = "accvlab/on_demand_video_decoder" 32 | 33 | [tool.setuptools.packages.find] 34 | where = ["."] 35 | include = ["accvlab.on_demand_video_decoder*"] -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/PyNvOnDemandDecoder/inc/Version.hpp.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define PYNOD_MAJOR_VERSION @PYNOD_MAJOR_VERSION @ 18 | #define PYNOD_MINOR_VERSION @PYNOD_MINOR_VERSION @ 19 | #define PYNOD_PATCH_VERSION @PYNOD_PATCH_VERSION @ 20 | -------------------------------------------------------------------------------- /packages/optim_test_tools/accvlab/optim_test_tools/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .stopwatch import Stopwatch 16 | from .nvtx_range_wrapper import NVTXRangeWrapper 17 | from .tensor_dumper import TensorDumper 18 | 19 | __all__ = [ 20 | "Stopwatch", 21 | "NVTXRangeWrapper", 22 | "TensorDumper", 23 | ] 24 | -------------------------------------------------------------------------------- /packages/optim_test_tools/docs/examples.rst: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | This section contains runnable examples for the tools in ``accvlab.optim_test_tools``. The examples are 5 | kept concise and highlight common usage patterns. The corresponding classes in this package are singletons, 6 | allowing them to be used in different parts of the code without the need for coordination between the parts. 7 | The stopwatch and NVTX range wrapper examples show this pattern explicitly, while the tensor dumper examples 8 | focus mainly on the actual usage of the tools. Please see the individual examples for more details. These 9 | are listed below in the recommended reading order. 10 | 11 | .. toctree:: 12 | :maxdepth: 1 13 | 14 | examples/stopwatch 15 | examples/nvtx_range_wrapper 16 | examples/tensor_dumper_comparison 17 | examples/tensor_dumper_dumping 18 | 19 | .. seealso:: 20 | 21 | The code of the examples can be found in the repository under ``packages/optim_test_tools/examples/``. 22 | -------------------------------------------------------------------------------- /packages/example_package/ext_impl/include/external_cuda_ops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | // Declare CUDA operations 23 | torch::Tensor external_vector_add_cuda(torch::Tensor a, torch::Tensor b); 24 | torch::Tensor external_vector_scale_cuda(torch::Tensor input, float scale); -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/accvlab/dali_pipeline_framework/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Import all child packages 16 | from . import inputs 17 | from . import internal_helpers 18 | from . import operators_impl 19 | from . import pipeline 20 | from . import processing_steps 21 | 22 | __all__ = ['inputs', 'internal_helpers', 'operators_impl', 'pipeline', 'processing_steps'] 23 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=64", "wheel", "torch>=2.0.0", "scikit-build>=0.17.0", "pybind11>=2.10.0"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "accvlab.dali_pipeline_framework" 7 | version = "0.1.0" 8 | description = "DALI Pipeline Framework Package (part of the ACCV-Lab package)." 9 | requires-python = ">=3.8" 10 | dependencies = [ 11 | "torch>=2.0.0", 12 | "numpy>=1.22.2", 13 | "accvlab-build-config>=0.1.0", 14 | "nvidia-dali-cuda120>=1.51.2", 15 | "numba>=0.59", 16 | ] 17 | 18 | [project.optional-dependencies] 19 | optional = [ 20 | "pytest", 21 | "opencv-python-headless", 22 | "cupy", 23 | "pyquaternion", 24 | "nuscenes-devkit", 25 | "shapely", 26 | "psutil", 27 | ] 28 | 29 | [tool.setuptools.packages.find] 30 | where = ["."] 31 | include = ["accvlab.dali_pipeline_framework*"] 32 | 33 | [tool.skbuild] 34 | cmake.source-dir = "ext_impl" 35 | cmake.minimum-version = "3.18" 36 | cmake.install-dir = "." -------------------------------------------------------------------------------- /packages/example_skbuild_package/ext_impl/include/external_cuda_ops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | // Declare CUDA operations 23 | torch::Tensor external_vector_add_cuda(torch::Tensor a, torch::Tensor b); 24 | torch::Tensor external_vector_scale_cuda(torch::Tensor input, float scale); -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/PyNvOnDemandDecoder/src/ColorConvertKernels.cuh: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #pragma once 17 | 18 | #include "../inc/PyCAIMemoryView.hpp" 19 | #include "../inc/PyRGBFrame.hpp" 20 | 21 | void convert_nv12_to_rgb(const CAIMemoryView& input_y, const CAIMemoryView& input_uv, RGBFrame& output, 22 | bool is_full_range, bool asBGR); -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/accvlab/dali_pipeline_framework/operators_impl/numba_operators/__init__.py: -------------------------------------------------------------------------------- 1 | from .numba_operators import ( 2 | pad_to_size, 3 | remove_inactive, 4 | ensure_range, 5 | replace_nans, 6 | check_bbox_visibiity, 7 | check_minimum_bbox_size, 8 | check_points_in_box, 9 | crop_coordinates, 10 | get_rot_mat_from_rot_vector, 11 | get_translation_mat_from_vector, 12 | get_scaling_mat_from_vector, 13 | apply_matrix, 14 | get_center_from_bboxes, 15 | get_radii_from_bboxes, 16 | _apply_matrix_2d_input_ensured, 17 | ) 18 | 19 | __all__ = [ 20 | "pad_to_size", 21 | "remove_inactive", 22 | "ensure_range", 23 | "replace_nans", 24 | "check_bbox_visibiity", 25 | "check_minimum_bbox_size", 26 | "check_points_in_box", 27 | "crop_coordinates", 28 | "get_rot_mat_from_rot_vector", 29 | "get_translation_mat_from_vector", 30 | "get_scaling_mat_from_vector", 31 | "apply_matrix", 32 | "get_center_from_bboxes", 33 | "get_radii_from_bboxes", 34 | "_apply_matrix_2d_input_ensured", 35 | ] 36 | -------------------------------------------------------------------------------- /docs/contained_package_docs_mirror/IMPORTANT.txt: -------------------------------------------------------------------------------- 1 | This directory is a MIRROR of documentation content from the namespace packages. 2 | 3 | - Purpose: Provide Sphinx with a unified view of each package's docs/ and any 4 | additional directories referenced by that documentation (e.g., examples/). 5 | - Mode: The mirror is created by docs/mirror_referenced_dirs.py using symlinks 6 | by default (use --mode copy to copy files instead). 7 | - Source of truth: Do NOT edit files here. Make changes in the respective 8 | package source directories under packages//... 9 | - Build behavior: This directory is re-created on each documentation build. 10 | - VCS policy: Everything in this directory is ignored by Git except this 11 | IMPORTANT.txt and .gitignore file. 12 | 13 | Structure example: 14 | - contained_package_docs_mirror/ 15 | - / 16 | - docs/ # symlink to packages//docs/ 17 | - / # symlinks to other referenced dirs (if any) 18 | 19 | If the mirror appears stale or broken, rebuild the docs: 20 | cd docs && make html 21 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/VideoCodecSDKUtils/helper_classes/Utils/cuvid_dlopen.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #ifdef _WIN32 20 | #include 21 | #define cuvid_lib HMODULE 22 | #else 23 | #define cuvid_lib void* 24 | #endif 25 | 26 | cuvid_lib cuvid_dlopen(const char* path); 27 | void* cuvid_dlsym(cuvid_lib lib, const char* symbol); 28 | char* cuvid_dlerror(void); 29 | int cuvid_dlclose(cuvid_lib lib); 30 | -------------------------------------------------------------------------------- /packages/example_package/accvlab/example_package/functions/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .functions import ( 16 | cpp_vector_sum, 17 | cpp_matrix_transpose, 18 | cpp_print_build_info, 19 | cpp_vector_multiply, 20 | cuda_vector_multiply, 21 | cuda_reduce_sum, 22 | ) 23 | 24 | __all__ = [ 25 | 'cpp_vector_sum', 26 | 'cpp_matrix_transpose', 27 | 'cpp_print_build_info', 28 | 'cpp_vector_multiply', 29 | 'cuda_vector_multiply', 30 | 'cuda_reduce_sum', 31 | ] 32 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/PyNvOnDemandDecoder/inc/PyNvOnDemandDecoder.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace py = pybind11; 32 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/VideoCodecSDKUtils/helper_classes/Utils/cuvid_dlopen_unix.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #ifndef _WIN32 19 | #include 20 | cuvid_lib cuvid_dlopen(const char* path) { return dlopen(path, RTLD_LAZY); } 21 | void* cuvid_dlsym(cuvid_lib lib, const char* symbol) { return dlsym(lib, symbol); } 22 | char* cuvid_dlerror() { return dlerror(); } 23 | int cuvid_dlclose(cuvid_lib lib) { return dlclose(lib); } 24 | #endif 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/VideoCodecSDKUtils/helper_classes/Utils/cuvid_dlopen_windows.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #ifdef _WIN32 19 | #include 20 | cuvid_lib cuvid_dlopen(const char* path) { return LoadLibraryA (path); } 21 | void* cuvid_dlsym(cuvid_lib lib, const char* symbol) { return GetProcAddress(lib, symbol); } 22 | char* cuvid_dlerror() { return (char*)"Failed"; } 23 | int cuvid_dlclose(cuvid_lib lib) { return FreeLibrary(lib); } 24 | #endif 25 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/accvlab/dali_pipeline_framework/operators_impl/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ''' 16 | Operators and utilities for use inside DALI pipelines. 17 | 18 | This module contains: 19 | - Functions to be used inside Python operators 20 | - Numba operators which can be used directly (including the needed Numba functions and the wrapping as a Numba operator) 21 | ''' 22 | 23 | from . import numba_operators 24 | from . import python_operator_functions 25 | 26 | __all__ = ["numba_operators", "python_operator_functions"] 27 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/accvlab/dali_pipeline_framework/pipeline/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ''' 16 | This module contains the pipeline definition class as well as classes which 17 | are used to structure and manage the data inside the pipeline as well as the 18 | output of the pipeline. 19 | ''' 20 | 21 | from .pipeline import PipelineDefinition 22 | from .dali_structured_output_iterator import DALIStructuredOutputIterator 23 | from .sample_data_group import SampleDataGroup 24 | 25 | __all__ = ['PipelineDefinition', 'DALIStructuredOutputIterator', 'SampleDataGroup'] 26 | -------------------------------------------------------------------------------- /packages/example_package/accvlab/example_package/include/examples.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | // Declare C++ functions 22 | double vector_sum_cpu(torch::Tensor vec); 23 | torch::Tensor matrix_transpose_cpu(torch::Tensor matrix); 24 | void print_build_info_cpu(); 25 | torch::Tensor vector_multiply_cpu(torch::Tensor a, torch::Tensor b); 26 | 27 | // Declare CUDA functions 28 | torch::Tensor vector_multiply_cuda(torch::Tensor a, torch::Tensor b); 29 | torch::Tensor reduce_sum_cuda(torch::Tensor input); -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/examples/input_definitions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import os 16 | 17 | ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) 18 | 19 | # Dataset directory as defined by docker. For local setups, set the directory. It should contain "datas" and "imgs" sub-folders. Each opf these sub-folders contains 20 | # folders with the dataset name, which in turn contain the data / folder with images respectively. 21 | 22 | nuscenes_root_dir = '/data/nuscenes' 23 | 24 | can_bus_root_dir = '/data/nuscenes' 25 | 26 | nuscenes_version = 'v1.0-mini' 27 | 28 | nuscenes_preproc_file_base_name = '{}_preproc_{}.pkl' 29 | -------------------------------------------------------------------------------- /packages/draw_heatmap/accvlab/draw_heatmap/funtions/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """ 16 | GPU-accelerated Gaussian heatmap drawing for object detection. 17 | 18 | This package provides CUDA kernels for efficiently drawing Gaussian heatmaps 19 | based on bounding box centers and radii, significantly outperforming CPU-based 20 | implementations. 21 | """ 22 | 23 | # ensure torch is available before importing `draw_heatmap_ext` 24 | import torch 25 | 26 | from accvlab.draw_heatmap.draw_heatmap_ext import draw_heatmap 27 | 28 | from .draw_heatmap_batched import draw_heatmap_batched 29 | 30 | __all__ = ["draw_heatmap", "draw_heatmap_batched"] 31 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/examples/flexible_step/simple_step.rst: -------------------------------------------------------------------------------- 1 | Simple Image Decoding Step 2 | ========================== 3 | 4 | .. seealso:: 5 | The implementation of ``SimpleExampleImageDecoder`` can be found at 6 | ``packages/dali_pipeline_framework/examples/simple_processing_step_example/simple_example_image_decoder.py``. 7 | 8 | First, let's implement a single image decoding step. Image decoding is typically the first step performed 9 | after obtaining the input data. For now, we assume that there is only one image to process and we know exactly 10 | where in the input data structure the image is located. These assumptions limit the usability of the 11 | processing step (e.g. using single-camera vs. multi-camera input, or using other images). We will lift this 12 | limitation in the next step using functionality of :class:`~accvlab.dali_pipeline_framework.pipeline.SampleDataGroup`. 13 | But first, let's have a look at ``SimpleExampleImageDecoder``. 14 | 15 | .. note-literalinclude:: ../../../examples/simple_processing_step_example/simple_example_image_decoder.py 16 | :language: python 17 | :linenos: 18 | :lineno-match: 19 | :caption: packages/dali_pipeline_framework/examples/simple_processing_step_example/simple_example_image_decoder.py 20 | :name: simple_example_image_decoder 21 | -------------------------------------------------------------------------------- /packages/example_skbuild_package/accvlab/example_skbuild_package/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """ 16 | ACCV-Lab Examples Module 17 | Demonstrates manual build configuration with C++/CUDA extensions 18 | """ 19 | 20 | from .functions import ( 21 | vector_add, 22 | vector_scale, 23 | ) 24 | 25 | # Import the external module 26 | from ._ext import external_vector_add_cuda, external_vector_scale_cuda 27 | 28 | 29 | def hello_examples(): 30 | """Simple function to test the examples module""" 31 | return "Hello from ACCV-Lab SKBuild Example Package!" 32 | 33 | 34 | __all__ = [ 35 | 'hello_examples', 36 | 'vector_add', 37 | 'vector_scale', 38 | ] 39 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/tests/internal_helpers/mini_parser/parser_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import pytest 16 | 17 | from accvlab.dali_pipeline_framework.internal_helpers.mini_parser import Parser 18 | 19 | 20 | def test_parser(): 21 | input_str = "res = d and not(a_b == -1.5 or -_b2 > 2 and (c < 3 or d > 4)) and c < 3" 22 | parser = Parser(input_str) 23 | ast_tree = parser.parse() 24 | 25 | expected_ast_tree = "'res' = <{{'d' and not [{('a_b' == -(1.5)) or {(-('_b2') > 2) and {('c' < 3) or ('d' > 4)}}}]} and ('c' < 3)}>" 26 | 27 | assert str(ast_tree) == expected_ast_tree 28 | 29 | 30 | if __name__ == "__main__": 31 | pytest.main([__file__]) 32 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/PyNvOnDemandDecoder/inc/GPUMemoryPool.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | class GPUMemoryPool { 24 | public: 25 | GPUMemoryPool() = default; 26 | 27 | GPUMemoryPool(size_t size_hint); 28 | 29 | void* AddElement(size_t num_bytes); 30 | 31 | void EnsureSizeAndSoftReset(size_t num_bytes_to_store, bool shrink_if_smaller); 32 | 33 | void SoftRelease(); 34 | 35 | void HardRelease(); 36 | 37 | ~GPUMemoryPool(); 38 | 39 | private: 40 | uint8_t* data_ = nullptr; 41 | size_t curr_size_ = 0; 42 | size_t allocated_size_ = 0; 43 | }; -------------------------------------------------------------------------------- /packages/example_skbuild_package/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from skbuild import setup 16 | from setuptools import find_namespace_packages 17 | from pathlib import Path 18 | 19 | from accvlab_build_config import build_cmake_args_from_env # type: ignore 20 | 21 | _cmake_args = build_cmake_args_from_env() 22 | 23 | 24 | setup( 25 | name="accvlab.example_skbuild_package", 26 | version="0.1.0", 27 | description="ACCV-Lab SKBuild Example Package", 28 | packages=find_namespace_packages(include=["accvlab.example_skbuild_package*"]), 29 | include_package_data=True, 30 | zip_safe=False, 31 | cmake_source_dir="ext_impl", 32 | cmake_install_dir="accvlab/example_skbuild_package", 33 | cmake_args=_cmake_args, 34 | ) 35 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from skbuild import setup 16 | from setuptools import find_namespace_packages 17 | from pathlib import Path 18 | from accvlab_build_config import build_cmake_args_from_env # type: ignore 19 | 20 | _cmake_args = build_cmake_args_from_env() 21 | 22 | 23 | setup( 24 | name="accvlab.dali_pipeline_framework", 25 | version="0.1.0", 26 | description="DALI Pipeline Framework Package (part of the ACCV-Lab package).", 27 | packages=find_namespace_packages(include=["accvlab.dali_pipeline_framework*"]), 28 | include_package_data=True, 29 | zip_safe=False, 30 | cmake_source_dir="ext_impl", 31 | cmake_install_dir="accvlab/dali_pipeline_framework", 32 | cmake_args=_cmake_args, 33 | ) 34 | -------------------------------------------------------------------------------- /scripts/install_local.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # Convenience wrapper for package_manager.sh install mode. 18 | # This script performs a single, default installation of all namespace packages 19 | # with optional dependencies enabled. It does not accept any parameters. 20 | # For any other installation mode (e.g., without optional dependencies, editable 21 | # installs, wheel building, etc.), please use scripts/package_manager.sh directly. 22 | 23 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 24 | 25 | if [[ "$#" -ne 0 ]]; then 26 | echo "Error: install_local.sh does not accept parameters." 27 | echo " For custom installation options, use scripts/package_manager.sh directly." 28 | exit 1 29 | fi 30 | 31 | "$SCRIPT_DIR/package_manager.sh" install --optional -------------------------------------------------------------------------------- /packages/optim_test_tools/accvlab/optim_test_tools/singleton_base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | class SingletonBase: 17 | """Base class for singleton classes. 18 | 19 | It is used to ensure that only a single instance of the class is created. 20 | It is e.g. used in the following classes: 21 | - Stopwatch 22 | - NVTXRangeWrapper 23 | - DecoratorSwitch 24 | """ 25 | 26 | _instances = {} 27 | 28 | def __new__(cls, *args, **kwargs): 29 | """Get instance of the class. 30 | 31 | If an instance of the class already exists, return it. 32 | Otherwise, create a new instance, store it for later use, and return it. 33 | """ 34 | if not cls in cls._instances: 35 | obj = super().__new__(cls) 36 | cls._instances[cls] = obj 37 | return cls._instances[cls] 38 | -------------------------------------------------------------------------------- /docker/run_docker_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # Set default values if not provided 18 | TAG=${TAG:-accvlab} 19 | USER_ID=${USER_ID:-$(id -u)} 20 | USER_NAME=${USER_NAME:-$(whoami)} 21 | GROUP_ID=${GROUP_ID:-$(id -g)} 22 | GROUP_NAME=${GROUP_NAME:-$(id -gn)} 23 | 24 | echo "Building Docker image with:" 25 | echo " TAG: $TAG" 26 | echo " USER_ID: $USER_ID" 27 | echo " USER_NAME: $USER_NAME" 28 | echo " GROUP_ID: $GROUP_ID" 29 | echo " GROUP_NAME: $GROUP_NAME" 30 | 31 | docker build --progress auto --build-arg USER_ID=$USER_ID \ 32 | --build-arg USER_NAME=$USER_NAME \ 33 | --build-arg GROUP_ID=$GROUP_ID \ 34 | --build-arg GROUP_NAME=$GROUP_NAME \ 35 | --file Dockerfile \ 36 | --tag $TAG .. 37 | 38 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/api/main_api.rst: -------------------------------------------------------------------------------- 1 | Main API Reference 2 | ================== 3 | 4 | .. note:: 5 | This page contains the documentation of the main API, which is the API that is used to create a DALI 6 | pipeline from a set of available processing steps, as well as the API for the data loading and data 7 | provider classes. 8 | 9 | It also contains the documentation for the base classes needed to implement custom processing steps. 10 | 11 | However, it does not contain the documentation of some helpers which are used internally, and can be useful 12 | when implementing custom processing steps. For more details on those, see the :doc:`additional_api` page. 13 | 14 | .. autosummary:: 15 | accvlab.dali_pipeline_framework.inputs 16 | accvlab.dali_pipeline_framework.pipeline 17 | accvlab.dali_pipeline_framework.processing_steps 18 | 19 | .. toctree:: 20 | :maxdepth: 2 21 | :hidden: 22 | 23 | inputs 24 | pipeline 25 | processing_steps 26 | 27 | .. seealso:: 28 | While the API documentation describes the API of the package, there are some use-case dependent helpers 29 | which are not part of the API, but are implemented as part of the examples. While these helpers are 30 | designed for a specific use-case (e.g. data-set, training implementation etc.), they can be potentially 31 | useful for similar use-cases. 32 | 33 | For the NuScenes data loader, which is used in the examples, see :doc:`../examples/use_case_specific/nuscenes_data_loader`. 34 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/accvlab/dali_pipeline_framework/inputs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ''' 16 | This module contains classes for handling the input data to the DALI pipeline. 17 | ''' 18 | 19 | from .callable_base import CallableBase 20 | from .data_provider import DataProvider 21 | from .iterable_base import IterableBase 22 | from .sampler_base import SamplerBase 23 | from .sampler_input_callable import SamplerInputCallable 24 | from .sampler_input_iterable import SamplerInputIterable 25 | from .sequence_sampler import SequenceSampler 26 | from .sfuffled_sharded_input_callable import ShuffledShardedInputCallable 27 | 28 | __all__ = [ 29 | 'CallableBase', 30 | 'DataProvider', 31 | 'IterableBase', 32 | 'SamplerBase', 33 | 'SamplerInputCallable', 34 | 'SamplerInputIterable', 35 | 'SequenceSampler', 36 | 'ShuffledShardedInputCallable', 37 | ] 38 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/accvlab/dali_pipeline_framework/internal_helpers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ''' 16 | This module contains helper functions and classes which are used internally in the package 17 | or can be useful when debugging or implementing custom functionality. 18 | 19 | For debugging, :func:`print_tensor_op` and :func:`print_tensor_size_op` can be used to print tensors 20 | from within the DALI pipeline. 21 | 22 | The other functionality is used internally, and may be useful when implementing custom processing steps. 23 | 24 | ''' 25 | 26 | from .check_type import check_type 27 | from .debug_helpers import print_tensor_op, print_tensor_size_op 28 | from .helper_functions import get_mapped, get_as_data_node 29 | from . import mini_parser 30 | 31 | __all__ = [ 32 | "check_type", 33 | "print_tensor_op", 34 | "print_tensor_size_op", 35 | "get_mapped", 36 | "get_as_data_node", 37 | "mini_parser", 38 | ] 39 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/examples/pipeline_setup/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ''' 16 | This module contains helper functions for setting up the DALI pipeline for specific use-cases. 17 | The functionality can be re-used, but is mainly intended to be used as a starting point for the user 18 | to set up their own pipeline. 19 | ''' 20 | 21 | from .helper_funcs import kill_subprocesses 22 | from .stream_petr_pipeline import setup_dali_pipeline_stream_petr_train 23 | from .stream_petr_config import ( 24 | get_default_stream_petr_pipeline_config, 25 | add_stream_petr_arguments_to_parser, 26 | add_stream_petr_config_to_arguments, 27 | ) 28 | from .object_detection_2d_pipeline import setup_dali_pipeline_2d_object_detection 29 | from .object_detection_2d_config import ( 30 | get_default_object_detection_2d_pipeline_config, 31 | add_object_detection_2d_arguments_to_parser, 32 | add_object_detection_2d_config_to_arguments, 33 | ) 34 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/examples/prepare_dataset.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import types 16 | 17 | from nuscenes.nuscenes import NuScenes 18 | 19 | # import nuscenes.scripts.export_2d_annotations_as_json as export_2d_annotations_as_json 20 | from nuscenes.scripts import export_2d_annotations_as_json 21 | 22 | import input_definitions 23 | 24 | if __name__ == "__main__": 25 | args = types.SimpleNamespace() 26 | args.dataroot = input_definitions.nuscenes_root_dir 27 | args.version = input_definitions.nuscenes_version 28 | args.filename = 'image_annotations.json' 29 | args.visibilities = ['', '1', '2', '3', '4'] 30 | args.image_limit = -1 31 | 32 | # nusc is a global variable which is set inside the module if the module is executes as __main__. Instead, 33 | # we set it manually here 34 | export_2d_annotations_as_json.nusc = NuScenes(dataroot=args.dataroot, version=args.version) 35 | export_2d_annotations_as_json.main(args) 36 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/accvlab/dali_pipeline_framework/internal_helpers/mini_parser/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """ 16 | This module contains the mini-parser for the DALI pipeline. See :class:`Parser` for more details on the parser 17 | and :class:`AST` and its subclasses for more details on the abstract syntax tree which is used as the 18 | output of the parser. 19 | 20 | The parser is used internally in the :class:`~accvlab.dali_pipeline_framework.processing_steps.AnnotationConditionEval` 21 | processing step. 22 | """ 23 | 24 | from .ast import AST, Assignment, Literal, Variable, Comparison, Or, And, Not, UnaryMinus 25 | from .parser import Parser 26 | from .lexer import Lexer, TokenType, Token 27 | 28 | __all__ = [ 29 | "Parser", 30 | "AST", 31 | "Assignment", 32 | "Literal", 33 | "Variable", 34 | "Comparison", 35 | "Or", 36 | "And", 37 | "Not", 38 | "UnaryMinus", 39 | "Lexer", 40 | "TokenType", 41 | "Token", 42 | ] 43 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """ """ 16 | 17 | import sys 18 | from setuptools import find_namespace_packages 19 | 20 | from pkg_resources import VersionConflict, require 21 | 22 | import skbuild 23 | from accvlab_build_config import build_cmake_args_from_env # type: ignore 24 | 25 | try: 26 | require("setuptools>=42") 27 | except VersionConflict: 28 | print("Error: version of setuptools is too old (<42)!") 29 | sys.exit(1) 30 | 31 | _cmake_args = build_cmake_args_from_env() 32 | 33 | skbuild.setup( 34 | name="accvlab.on_demand_video_decoder", 35 | version="0.1.0", 36 | description="On-demand video decoder (part of the ACCV-Lab package).", 37 | packages=find_namespace_packages(include=["accvlab.on_demand_video_decoder*"]), 38 | include_package_data=True, 39 | zip_safe=False, 40 | cmake_source_dir="ext_impl", 41 | cmake_install_dir="accvlab/on_demand_video_decoder", 42 | cmake_args=_cmake_args, 43 | ) 44 | -------------------------------------------------------------------------------- /packages/draw_heatmap/docs/examples.rst: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | Currently, this package provides two implementations for drawing the heatmaps in general which differs in the input format corresponding two **functions** to work efficiently. 5 | 6 | draw_heatmap 7 | ------------ 8 | This implementation is designed for the **concatenated** input format. For the details about the inputs, please refer to the `packages/draw_heatmap/examples/input_data.py` file. 9 | 10 | .. literalinclude:: ../examples/draw_heatmap.py 11 | :language: python 12 | :caption: Concatenated input example 13 | :name: draw_heatmap-example 14 | 15 | draw_heatmap_batched 16 | -------------------- 17 | This implementation is designed for the **batched** input format. For the details about the inputs, please refer to the `packages/draw_heatmap/examples/input_data.py` file. 18 | 19 | .. note:: 20 | It's general to draw all classes in one heatmap. However, another option in to have one heatmap for each class. Both are supported by this function distinguishing by feeding `labels` parameter of each bounding box or not. 21 | 22 | one-for-all classes 23 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 24 | 25 | .. literalinclude:: ../examples/draw_heatmap_batched.py 26 | :language: python 27 | :caption: Batched input, one heatmap for all classes example 28 | :name: draw_heatmap_batched-example 29 | 30 | one-for-each class 31 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 32 | 33 | .. literalinclude:: ../examples/draw_heatmap_batched_classwise.py 34 | :language: python 35 | :caption: Batched input, one heatmap for each class example 36 | :name: draw_heatmap_batched-example-each-class -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Generate namespace package documentation before building 18 | generate: 19 | python3 mirror_referenced_dirs.py 20 | python3 generate_new_namespace_package_docs.py 21 | python3 update_docs_index.py 22 | 23 | # Sync the root README into the docs tree before building 24 | sync-readme: 25 | @echo "Syncing root README into docs/project_overview..." 26 | @python3 sync_root_readme_for_docs.py 27 | 28 | # Build HTML documentation with auto-generation 29 | html: sync-readme generate 30 | @$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 31 | 32 | # Clean build directory and generated files 33 | clean: 34 | @$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 35 | rm -rf api/generated/ 36 | rm -rf ../packages/*/docs/generated/ 37 | 38 | # Auto-build documentation (watches for changes) 39 | livehtml: sync-readme generate 40 | sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)/html" $(SPHINXOPTS) $(O) 41 | 42 | # Catch-all target: route all unknown targets to Sphinx using the new 43 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 44 | %: Makefile 45 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cmake_minimum_required(VERSION 3.20) 16 | 17 | # NOTE: CMAKE_CUDA_ARCHITECTURES is inherited from parent ext_impl/CMakeLists.txt 18 | # To customize, set CUSTOM_CUDA_ARCHS environment variable before building. 19 | 20 | project(accvlab.on_demand_video_decoder) 21 | 22 | #Undef MIN & MAX & C runtime warnings for Windows 23 | if(WIN32) 24 | add_definitions(-DNOMINMAX) 25 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 26 | endif(WIN32) 27 | 28 | option(PROCESS_SYNC "Run the demuxer and decoder in synchornous" OFF) 29 | set(PROCESS_SYNC $ENV{PROCESS_SYNC}) 30 | if (PROCESS_SYNC) 31 | add_compile_definitions(PROCESS_SYNC) 32 | endif() 33 | 34 | message("PROCESS_SYNC environment variable: $ENV{PROCESS_SYNC}") 35 | 36 | option(USE_NVTX "enable nvtx support" FALSE) 37 | set(USE_NVTX $ENV{USE_NVTX}) 38 | 39 | find_package(CUDAToolkit 11.2 REQUIRED) 40 | 41 | add_subdirectory(VideoCodecSDKUtils) 42 | add_subdirectory(PyNvOnDemandDecoder) 43 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/PyNvOnDemandDecoder/inc/DLPackUtils.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DLPACKUTILS_HPP 18 | #define DLPACKUTILS_HPP 19 | 20 | #include 21 | #include 22 | 23 | namespace py = pybind11; 24 | 25 | class DLPackTensor final { 26 | public: 27 | DLPackTensor() noexcept; 28 | explicit DLPackTensor(const DLTensor& tensor); 29 | explicit DLPackTensor(DLManagedTensor&& tensor); 30 | explicit DLPackTensor(const py::buffer_info& info, const DLDevice& dev); 31 | 32 | DLPackTensor(DLPackTensor&& that) noexcept; 33 | ~DLPackTensor(); 34 | 35 | DLPackTensor& operator=(DLPackTensor&& that) noexcept; 36 | 37 | const DLTensor* operator->() const; 38 | DLTensor* operator->(); 39 | 40 | const DLTensor& operator*() const; 41 | DLTensor& operator*(); 42 | 43 | private: 44 | DLManagedTensor m_tensor; 45 | }; 46 | 47 | bool IsCudaAccessible(DLDeviceType devType); 48 | 49 | #endif // DLPACKUTILS_HPP 50 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/PyNvOnDemandDecoder/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """ """ 16 | 17 | from ast import Str 18 | import string 19 | 20 | try: 21 | # Import native module 22 | from ._PyNvOnDemandDecoder import * # noqa 23 | from enum import Enum 24 | 25 | except ImportError: 26 | import distutils.sysconfig 27 | from os.path import join, dirname 28 | 29 | raise RuntimeError( 30 | "Failed to import native module _PyNvOnDemandDecoder! " 31 | f"Please check whether \"{join(dirname(__file__), '_PyNvOnDemandDecoder' + distutils.sysconfig.get_config_var('EXT_SUFFIX'))}\"" # noqa 32 | " exists and can find all library dependencies (CUDA, ffmpeg).\n" 33 | "On Unix systems, you can use `ldd` on the file to see whether it can find all dependencies.\n" 34 | "On Windows, you can use \"dumpbin /dependents\" in a Visual Studio command prompt or\n" 35 | "https://github.com/lucasg/Dependencies/releases." 36 | ) 37 | 38 | 39 | class Codec(Enum): 40 | h264 = 4 41 | hevc = 8 42 | av1 = 11 43 | -------------------------------------------------------------------------------- /docs/_ext/module_docstring.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | import ast 3 | 4 | from docutils import nodes 5 | from docutils.statemachine import StringList 6 | from sphinx.util.docutils import SphinxDirective 7 | from sphinx.util import logging 8 | 9 | LOGGER = logging.getLogger(__name__) 10 | 11 | 12 | class ModuleDocstringInclude(SphinxDirective): 13 | required_arguments = 1 # path to file 14 | optional_arguments = 0 15 | final_argument_whitespace = False 16 | option_spec = {} 17 | 18 | def run(self): 19 | env = self.state.document.settings.env 20 | rel_filename, filename = env.relfn2path(self.arguments[0]) 21 | env.note_dependency(rel_filename) 22 | 23 | try: 24 | with open(filename, 'r', encoding='utf-8') as f: 25 | source = f.read() 26 | except Exception as exc: 27 | LOGGER.warning('module-docstring: failed to read %s: %s', filename, exc) 28 | return [] 29 | 30 | try: 31 | module = ast.parse(source) 32 | doc = ast.get_docstring(module) or '' 33 | except Exception as exc: 34 | LOGGER.warning('module-docstring: failed to parse %s: %s', filename, exc) 35 | doc = '' 36 | 37 | if not doc: 38 | return [] 39 | 40 | container = nodes.container() 41 | lines = StringList(doc.splitlines(), source=filename) 42 | self.state.nested_parse(lines, 0, container) 43 | return [container] 44 | 45 | 46 | def setup(app): # pragma: no cover - build-time only 47 | app.add_directive('module-docstring', ModuleDocstringInclude) 48 | return { 49 | 'version': '0.1', 50 | 'parallel_read_safe': True, 51 | 'parallel_write_safe': True, 52 | } 53 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/tests/test_random_decoder.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import pytest 16 | import sys 17 | 18 | import random 19 | 20 | import utils 21 | import accvlab.on_demand_video_decoder as nvc 22 | 23 | 24 | def test_random_access_single(): 25 | max_num_files_to_use = 6 26 | iter_num = 10 27 | path_base = utils.get_data_dir() 28 | 29 | nv_gop_dec = nvc.CreateGopDecoder( 30 | maxfiles=max_num_files_to_use, 31 | iGpu=0, 32 | ) 33 | 34 | frame_min = 0 35 | frame_max = 200 36 | 37 | for c in range(iter_num): 38 | files = utils.select_random_clip(path_base) 39 | assert files is not None, f"files is None for select_random_clip, path_base: {path_base}" 40 | 41 | frames = [random.randint(frame_min, frame_max) for _ in range(len(files))] 42 | print(f"Comparison: {c}, frames: {frames}") 43 | 44 | gop_decoded = utils.gop_decode_bgr(nv_gop_dec, files, frames) 45 | assert gop_decoded is not None, f"gop_decoded is None for DecodeN12ToRGB, frames: {frames}" 46 | 47 | 48 | if __name__ == "__main__": 49 | sys.exit(pytest.main([__file__, "-v"])) 50 | -------------------------------------------------------------------------------- /docs/SHARED_CONFIG_GUIDE.txt: -------------------------------------------------------------------------------- 1 | # Shared Configuration System 2 | 3 | ACCV-Lab uses a shared configuration file to keep the build system and documentation in perfect sync. 4 | 5 | ## The Configuration File: `namespace_packages_config.py` 6 | 7 | Located in the project root, this file contains the master list of namespace packages: 8 | 9 | ```python 10 | NAMESPACE_PACKAGES = [ 11 | 'accvlab.examples', 12 | # Add new namespace packages here 13 | ] 14 | ``` 15 | 16 | ## What Uses This Configuration 17 | 18 | 1. **`setup.py`** - For building and installing namespace packages 19 | 2. **`docs/conf.py`** - For Sphinx documentation configuration 20 | 3. **`docs/generate_new_namespace_package_docs.py`** - For generating documentation 21 | 22 | ## Benefits 23 | 24 | - ✅ **Single Source of Truth**: One file controls everything 25 | - ✅ **No Duplication**: Never get out of sync between build and docs 26 | - ✅ **Simple Maintenance**: Add new packages in one place 27 | - ✅ **Consistent Behavior**: Build and docs always match 28 | 29 | ## Adding a New Namespace Package 30 | 31 | 1. **Add to the list** in `namespace_packages_config.py`: 32 | ```python 33 | NAMESPACE_PACKAGES = [ 34 | 'accvlab.examples', 35 | 'accvlab.algorithms', # Add this line 36 | ] 37 | ``` 38 | 39 | 2. **Everything else is automatic**: 40 | - Build system will include it 41 | - Documentation will be generated for it 42 | - No need to update multiple files 43 | 44 | ## Usage Examples 45 | 46 | ```bash 47 | # Check current configuration 48 | python3 namespace_packages_config.py 49 | 50 | # Build with current configuration 51 | pip install -e . 52 | 53 | # Generate docs with current configuration 54 | cd docs && make html 55 | ``` 56 | 57 | This system ensures that what you build is exactly what gets documented, with no possibility of the two getting out of sync. -------------------------------------------------------------------------------- /packages/example_package/accvlab/example_package/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """ 16 | ACCV-Lab Examples Module 17 | Demonstrates manual build configuration with C++/CUDA extensions. 18 | """ 19 | 20 | from typing import Callable 21 | 22 | from torch import Tensor 23 | 24 | from .functions import ( 25 | cpp_vector_sum, 26 | cpp_matrix_transpose, 27 | cuda_vector_multiply, 28 | cuda_reduce_sum, 29 | ) 30 | 31 | # Import the external module 32 | from accvlab.example_package.accvlab_example_package_ext import ( 33 | external_vector_add_cuda, 34 | external_vector_scale_cuda, 35 | ) 36 | 37 | # Type annotations for externally provided CUDA functions 38 | external_vector_add_cuda: Callable[[Tensor, Tensor], Tensor] 39 | external_vector_scale_cuda: Callable[[Tensor, float], Tensor] 40 | 41 | 42 | def hello_examples() -> str: 43 | """Simple function to test the examples module.""" 44 | return "Hello from ACCV-Lab Example Package!" 45 | 46 | 47 | __all__ = [ 48 | 'hello_examples', 49 | 'cpp_vector_sum', 50 | 'cpp_matrix_transpose', 51 | 'cuda_vector_multiply', 52 | 'cuda_reduce_sum', 53 | 'external_vector_add_cuda', 54 | 'external_vector_scale_cuda', 55 | ] 56 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/cmake/ffmpeg.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | message(STATUS "Using FFMPEG_DIR=${FFMPEG_DIR}") 16 | set(NV_FFMPEG_LIBRARIES "") 17 | 18 | message(STATUS "Using CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}") 19 | 20 | macro(link_av_component target lib_name) 21 | find_library(${lib_name}_library 22 | NAMES ${lib_name} 23 | HINTS "${FFMPEG_DIR}/lib" 24 | ) 25 | message(STATUS "Link ${${lib_name}_library}") 26 | list(APPEND NV_FFMPEG_LIBRARIES ${${lib_name}_library}) 27 | endmacro() 28 | 29 | link_av_component(VideoCodecSDKUtils avformat) 30 | link_av_component(VideoCodecSDKUtils avcodec) 31 | link_av_component(VideoCodecSDKUtils swresample) 32 | link_av_component(VideoCodecSDKUtils avutil) 33 | 34 | find_path( 35 | BSF_INCLUDE_DIR 36 | NAMES "libavcodec/bsf.h" 37 | HINTS ${TC_FFMPEG_INCLUDE_DIR} "${FFMPEG_DIR}/include" 38 | ) 39 | if(BSF_INCLUDE_DIR) 40 | set(NV_FFMPEG_HAS_BSF TRUE) 41 | else() 42 | set(NV_FFMPEG_HAS_BSF FALSE) 43 | message(WARNING "Could not find \"libavcodec/bsf.h\" while other ffmpeg includes could be found." 44 | "This likely means that your FFMPEG installation is old. Still trying to compile VPF!") 45 | endif() 46 | -------------------------------------------------------------------------------- /packages/example_package/ext_impl/src/external_cuda_ops.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include "../include/external_cuda_ops.h" 19 | 20 | namespace { 21 | 22 | constexpr const char* DOC_EXTERNAL_VECTOR_ADD_CUDA = R"doc( 23 | Vector addition using external CUDA implementation. 24 | 25 | :gpu: 26 | 27 | Args: 28 | a: First input 1D tensor on a CUDA device. 29 | b: Second input 1D tensor on a CUDA device. 30 | 31 | Returns: 32 | Tensor on CUDA containing the element‑wise sum of ``a`` and ``b``. 33 | )doc"; 34 | 35 | constexpr const char* DOC_EXTERNAL_VECTOR_SCALE_CUDA = R"doc( 36 | Vector scaling using external CUDA implementation. 37 | 38 | :gpu: 39 | 40 | Args: 41 | a: Input 1D tensor on a CUDA device. 42 | scale: Scalar factor used to scale all elements of ``a``. 43 | 44 | Returns: 45 | Tensor on CUDA containing the scaled values of ``a``. 46 | )doc"; 47 | 48 | } // namespace 49 | 50 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 51 | m.def("external_vector_add_cuda", &external_vector_add_cuda, DOC_EXTERNAL_VECTOR_ADD_CUDA); 52 | m.def("external_vector_scale_cuda", &external_vector_scale_cuda, DOC_EXTERNAL_VECTOR_SCALE_CUDA); 53 | } -------------------------------------------------------------------------------- /packages/example_skbuild_package/ext_impl/src/external_cuda_ops.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include "../include/external_cuda_ops.h" 19 | 20 | namespace { 21 | 22 | constexpr const char* DOC_EXTERNAL_VECTOR_ADD_CUDA = R"doc( 23 | Vector addition using external CUDA implementation. 24 | 25 | :gpu: 26 | 27 | Args: 28 | a: First input 1D tensor on a CUDA device. 29 | b: Second input 1D tensor on a CUDA device. 30 | 31 | Returns: 32 | Tensor on CUDA containing the element-wise sum of ``a`` and ``b``. 33 | )doc"; 34 | 35 | constexpr const char* DOC_EXTERNAL_VECTOR_SCALE_CUDA = R"doc( 36 | Vector scaling using external CUDA implementation. 37 | 38 | :gpu: 39 | 40 | Args: 41 | a: Input 1D tensor on a CUDA device. 42 | scale: Scalar factor used to scale all elements of ``a``. 43 | 44 | Returns: 45 | Tensor on CUDA containing the scaled values of ``a``. 46 | )doc"; 47 | 48 | } // namespace 49 | 50 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 51 | m.def("external_vector_add_cuda", &external_vector_add_cuda, DOC_EXTERNAL_VECTOR_ADD_CUDA); 52 | m.def("external_vector_scale_cuda", &external_vector_scale_cuda, DOC_EXTERNAL_VECTOR_SCALE_CUDA); 53 | } -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/VideoCodecSDKUtils/helper_classes/Utils/ColorSpace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | #include 19 | #include 20 | 21 | typedef enum ColorSpaceStandard { 22 | ColorSpaceStandard_BT709 = 1, 23 | ColorSpaceStandard_Unspecified = 2, 24 | ColorSpaceStandard_Reserved = 3, 25 | ColorSpaceStandard_FCC = 4, 26 | ColorSpaceStandard_BT470 = 5, 27 | ColorSpaceStandard_BT601 = 6, 28 | ColorSpaceStandard_SMPTE240M = 7, 29 | ColorSpaceStandard_YCgCo = 8, 30 | ColorSpaceStandard_BT2020 = 9, 31 | ColorSpaceStandard_BT2020C = 10 32 | } ColorSpaceStandard; 33 | 34 | union BGRA32 { 35 | uint32_t d; 36 | uchar4 v; 37 | struct { 38 | uint8_t b, g, r, a; 39 | } c; 40 | }; 41 | 42 | union RGBA32 { 43 | uint32_t d; 44 | uchar4 v; 45 | struct { 46 | uint8_t r, g, b, a; 47 | } c; 48 | }; 49 | 50 | union BGRA64 { 51 | uint64_t d; 52 | ushort4 v; 53 | struct { 54 | uint16_t b, g, r, a; 55 | } c; 56 | }; 57 | 58 | union RGBA64 { 59 | uint64_t d; 60 | ushort4 v; 61 | struct { 62 | uint16_t r, g, b, a; 63 | } c; 64 | }; 65 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/examples/pipeline_setup/additional_impl/data_loading/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ''' 16 | This module contains helper functionality for loading the data from the NuScenes Dataset. 17 | Note that this is not part of the core functionality of the package and is only 18 | included for convenience. For other datasets (or data which is not considered here such as lidar point clouds) 19 | the user is expected to implement their own data loading functionality. 20 | ''' 21 | 22 | # Import classes from sibling files 23 | from .nuscenes_2d_detection_data_provider import Nuscenes2DDetectionDataProvider 24 | from .nuscenes_streampetr_data_provider import NuscenesStreamPETRDataProvider 25 | from .nuscenes_data_converter import NuScenesDataConverter 26 | from .nuscenes_data import NuScenesData, NuScenesDataSequence, NuScenesDataSample 27 | from .nuscenes_reader import NuScenesReader 28 | from .bbox_projector import BboxProjector 29 | 30 | # Export all classes for easy access 31 | __all__ = [ 32 | 'Nuscenes2DDetectionDataProvider', 33 | 'NuscenesStreamPETRDataProvider', 34 | 'NuScenesDataConverter', 35 | 'NuScenesData', 36 | 'NuScenesDataSequence', 37 | 'NuScenesDataSample', 38 | 'NuScenesReader', 39 | 'BboxProjector', 40 | ] 41 | -------------------------------------------------------------------------------- /packages/example_skbuild_package/tests/test_example_skbuild_package.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import pytest 16 | import torch 17 | import accvlab.example_skbuild_package 18 | 19 | 20 | def test_examples_import(): 21 | assert accvlab.example_skbuild_package is not None 22 | 23 | 24 | def test_external_module_available(): 25 | try: 26 | import accvlab.example_skbuild_package._ext 27 | 28 | assert accvlab.example_skbuild_package._ext is not None 29 | except ImportError: 30 | pytest.fail("External module _ext not found.") 31 | 32 | 33 | def test_cuda_vector_add(): 34 | a = torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32).cuda() 35 | b = torch.tensor([2.0, 3.0, 4.0], dtype=torch.float32).cuda() 36 | result = accvlab.example_skbuild_package.external_vector_add_cuda(a, b) 37 | expected = torch.tensor([3.0, 5.0, 7.0], dtype=torch.float32).cuda() 38 | assert torch.allclose(result, expected) 39 | 40 | 41 | def test_cuda_vector_scale(): 42 | a = torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32).cuda() 43 | scale = 2.5 44 | result = accvlab.example_skbuild_package.external_vector_scale_cuda(a, scale) 45 | expected = torch.tensor([2.5, 5.0, 7.5], dtype=torch.float32).cuda() 46 | assert torch.allclose(result, expected) 47 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/examples/flexible_step/flexible_step.rst: -------------------------------------------------------------------------------- 1 | Flexible Image Decoding Step 2 | ============================ 3 | 4 | .. seealso:: 5 | The implementation of :class:`~accvlab.dali_pipeline_framework.processing_steps.ImageDecoder` is the one 6 | used in the core DALI pipeline framework package. It can found in the repository at 7 | ``packages/dali_pipeline_framework/accvlab/dali_pipeline_framework/processing_steps/image_decoder.py``. 8 | 9 | Next, we will have a look at the flexible image decoding step. The functionality is similar to the 10 | :doc:`simple_step` version, but the implementation does not make any assumptions about how many images need 11 | to be processed or where in the input data they are located. Instead, it makes use of 12 | :meth:`~accvlab.dali_pipeline_framework.pipeline.SampleDataGroup.find_all_occurrences` to automatically 13 | discover all images in the input data by name. 14 | 15 | .. important:: 16 | 17 | While the discovery of the images requires additional steps in the implementation, note that these 18 | steps are performed at DALI graph construction time (as no :class:`~nvidia.dali.pipeline.DataNode` data 19 | or DALI operators are involved, only "normal" Python data). Therefore, even if elaborate discovery is 20 | needed, there will be no runtime cost during pipeline execution. 21 | 22 | For example, if the input data to this flexible image decoding step is in the format as expected by the 23 | :doc:`simple_step` version, the resulting DALI graph will be the same for both versions, and they 24 | will therefore run in the same way. 25 | 26 | 27 | .. note-literalinclude:: ../../../accvlab/dali_pipeline_framework/processing_steps/image_decoder.py 28 | :language: python 29 | :linenos: 30 | :lineno-match: 31 | :caption: packages/dali_pipeline_framework/accvlab/dali_pipeline_framework/processing_steps/image_decoder.py 32 | :name: image_decoder -------------------------------------------------------------------------------- /packages/batching_helpers/accvlab/batching_helpers/data_format/set_padded_to.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch 16 | import accvlab.batching_helpers.batched_indexing_access_cuda as batched_indexing_access_cuda 17 | import accvlab.batching_helpers.batched_indexing_access_cpu as batched_indexing_access_cpu 18 | 19 | 20 | class SetPaddedTo(torch.autograd.Function): 21 | @staticmethod 22 | def forward(ctx, data, sample_sizes, value_to_set): 23 | ctx.save_for_backward(sample_sizes) 24 | data = data.contiguous() 25 | sample_sizes = sample_sizes.to(dtype=torch.int64).contiguous() 26 | if data.device.type == "cuda": 27 | batched_indexing_access_cuda.set_ragged_batch_padded_to_filler_value_in_place( 28 | data, sample_sizes, value_to_set 29 | ) 30 | else: 31 | batched_indexing_access_cpu.set_ragged_batch_padded_to_filler_value_in_place( 32 | data, sample_sizes, value_to_set 33 | ) 34 | return data 35 | 36 | @staticmethod 37 | def backward(ctx, grad_output): 38 | if grad_output is None: 39 | return None, None, None 40 | else: 41 | grad_input = grad_output.clone() 42 | SetPaddedTo.apply(grad_input, ctx.saved_tensors[0], 0.0) 43 | return grad_input, None, None 44 | -------------------------------------------------------------------------------- /namespace_packages_config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Shared configuration for ACCV-Lab namespace packages. 4 | 5 | This file defines the list of namespace packages that should be: 6 | 1. Built and installed by individual package setup.py files 7 | 2. Documented by the Sphinx documentation system 8 | 9 | Add new namespace packages to the NAMESPACE_PACKAGES list below. 10 | """ 11 | 12 | # List of all ACCV-Lab namespace packages 13 | # Each namespace package should: 14 | # - Be a directory under the packages/ subdirectory 15 | # - Have a pyproject.toml and setup.py file for building 16 | # - Be added to this list to be included in builds and documentation 17 | # Please note that: 18 | # - Packages that are not listed here will be ignored when installing all packages, building the 19 | # documentation, running the tests, etc. 20 | # - The order in which the packages are listed here is the order in which they will be installed, and in which 21 | # they will appear in the documentation. 22 | NAMESPACE_PACKAGES = [ 23 | # The commented out packages below this line are examples (see the development guide): 24 | # 'accvlab.example_package', 25 | # 'accvlab.example_skbuild_package', 26 | 'accvlab.on_demand_video_decoder', 27 | 'accvlab.batching_helpers', 28 | 'accvlab.dali_pipeline_framework', 29 | 'accvlab.draw_heatmap', 30 | 'accvlab.optim_test_tools', 31 | # Add new namespace packages in the same way as above 32 | ] 33 | 34 | 35 | def get_namespace_packages(): 36 | """Get the list of configured namespace packages.""" 37 | return NAMESPACE_PACKAGES.copy() 38 | 39 | 40 | def get_package_names(): 41 | """Get just the package names (last part after the dot).""" 42 | return [pkg.split('.')[-1] for pkg in NAMESPACE_PACKAGES] 43 | 44 | 45 | if __name__ == "__main__": 46 | # When run directly, show the configuration 47 | print(f"Configured namespace packages: {len(NAMESPACE_PACKAGES)}") 48 | for i, pkg in enumerate(NAMESPACE_PACKAGES, 1): 49 | print(f" {i}. {pkg}") 50 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/PyNvOnDemandDecoder/inc/ExternalBuffer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef EXTERNAL_BUFFER_HPP 18 | #define EXTERNAL_BUFFER_HPP 19 | 20 | #include "DLPackUtils.hpp" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace py = pybind11; 28 | 29 | class ExternalBuffer final : public std::enable_shared_from_this { 30 | public: 31 | static void Export(py::module& m); 32 | 33 | const DLTensor& dlTensor() const; 34 | 35 | py::tuple shape() const; 36 | py::tuple strides() const; 37 | std::string dtype() const; 38 | 39 | void* data() const; 40 | 41 | //bool load(PyObject *o); 42 | explicit ExternalBuffer(DLPackTensor&& dlTensor); 43 | 44 | ExternalBuffer() = default; 45 | py::capsule dlpack(py::object stream) const; 46 | int LoadDLPack(std::vector _shape, std::vector _stride, std::string _typeStr, 47 | size_t _streamid, CUdeviceptr _data, bool _readOnly); 48 | 49 | private: 50 | friend py::detail::type_caster; 51 | 52 | DLPackTensor m_dlTensor; 53 | 54 | // __dlpack__ implementation 55 | 56 | // __dlpack_device__ implementation 57 | py::tuple dlpackDevice() const; 58 | }; 59 | 60 | #endif // EXTERNAL_BUFFER_HPP 61 | -------------------------------------------------------------------------------- /packages/batching_helpers/accvlab/batching_helpers/cpp_impl/batched_indexing_access_cpu.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | 21 | #include "batched_indexing_access_helpers.h" 22 | 23 | void set_ragged_batch_padded_to_filler_value_cpu(torch::Tensor& data, const torch::Tensor& nums_valid_entries, 24 | double filler_value); 25 | 26 | void set_ragged_batch_padded_to_filler_value_in_place(torch::Tensor& data, 27 | const torch::Tensor& nums_valid_entries, 28 | double filler_value) { 29 | CHECK_CONTIGUOUS(data); 30 | CHECK_CONTIGUOUS(nums_valid_entries); 31 | CHECK_CPU(data); 32 | CHECK_CPU(nums_valid_entries); 33 | 34 | const int64_t num_batch_dims = nums_valid_entries.dim(); 35 | 36 | CHECK_NUM_DIMS_AT_LEAST(data, num_batch_dims + 1); 37 | 38 | CHECK_SIZE_MATCH_FIRST_DIMS(data, nums_valid_entries, num_batch_dims); 39 | 40 | set_ragged_batch_padded_to_filler_value_cpu(data, nums_valid_entries, filler_value); 41 | } 42 | 43 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 44 | m.def("set_ragged_batch_padded_to_filler_value_in_place", 45 | &set_ragged_batch_padded_to_filler_value_in_place, "", py::arg("data"), 46 | py::arg("nums_valid_entries"), py::arg("filler_value")); 47 | } -------------------------------------------------------------------------------- /packages/draw_heatmap/benchmark_cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | project(draw_heatmap_benchmark_cpp) 16 | 17 | cmake_minimum_required(VERSION 3.14) 18 | 19 | set(CMAKE_CXX_STANDARD 17) 20 | set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -O3") 21 | # Find required packages 22 | find_package(CUDA REQUIRED) 23 | find_package(Python3 COMPONENTS Development REQUIRED) 24 | 25 | set(TORCH_ROOT "/usr/local/lib/python3.10/dist-packages/torch") 26 | set(CMAKE_PREFIX_PATH ${TORCH_ROOT} ${CMAKE_PREFIX_PATH}) 27 | find_package(Torch REQUIRED) 28 | 29 | include_directories(${Python3_INCLUDE_DIRS}) 30 | include_directories(${TORCH_INCLUDE_DIRS}) 31 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../accvlab/draw_heatmap/include) 32 | 33 | add_executable(bench_flattened 34 | bench_flattened.cpp 35 | ../accvlab/draw_heatmap/csrc/draw_heatmap_cuda.cu 36 | ) 37 | add_executable(bench_batched 38 | bench_batched.cpp 39 | ../accvlab/draw_heatmap/csrc/draw_heatmap_cuda.cu 40 | ) 41 | add_executable(bench_batched_classwise 42 | bench_batched_classwise.cpp 43 | ../accvlab/draw_heatmap/csrc/draw_heatmap_cuda.cu 44 | ) 45 | target_link_libraries(bench_flattened ${TORCH_LIBRARIES} ${CUDA_LIBRARIES} ${CUDA_CUDART_LIBRARY}) 46 | target_link_libraries(bench_batched ${TORCH_LIBRARIES} ${CUDA_LIBRARIES} ${CUDA_CUDART_LIBRARY}) 47 | target_link_libraries(bench_batched_classwise ${TORCH_LIBRARIES} ${CUDA_LIBRARIES} ${CUDA_CUDART_LIBRARY}) 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /packages/draw_heatmap/examples/draw_heatmap.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch 16 | from accvlab.draw_heatmap import draw_heatmap 17 | from input_data import ( 18 | device, 19 | centers_list, 20 | radii_list, 21 | HEATMAP_SIZE, 22 | diameter_to_sigma_factor, 23 | k_scale, 24 | ) 25 | 26 | 27 | def draw_heatmap_example(): 28 | """ 29 | This example shows how to draw heatmaps for concatenated inputs. 30 | 31 | Args: 32 | centers_list: List[torch.Tensor] 33 | radii_list: List[torch.Tensor] 34 | HEATMAP_SIZE: [H, W] 35 | diameter_to_sigma_factor: float 36 | k_scale: float 37 | """ 38 | num_of_heatmaps = len(centers_list) 39 | 40 | centers = torch.cat(centers_list, dim=0) 41 | radii = torch.cat(radii_list, dim=0) 42 | heatmaps = torch.zeros( 43 | (num_of_heatmaps, HEATMAP_SIZE[0], HEATMAP_SIZE[1]), dtype=torch.float32, device=device 44 | ) 45 | 46 | # because we concat all samples, we need to record the index of the heatmap for each bounding box 47 | heatmap_idxes = torch.tensor( 48 | [i for i, sublist in enumerate(centers_list) for _ in sublist], 49 | device=device, 50 | dtype=torch.int32, 51 | ) 52 | draw_heatmap(heatmaps, centers, radii, heatmap_idxes, diameter_to_sigma_factor, k_scale) 53 | return heatmaps 54 | 55 | 56 | if __name__ == "__main__": 57 | heatmaps = draw_heatmap_example() 58 | print(heatmaps.shape) 59 | -------------------------------------------------------------------------------- /packages/example_package/tests/test_example_package_ext.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import pytest 16 | import torch 17 | from accvlab.example_package import external_vector_add_cuda, external_vector_scale_cuda 18 | 19 | 20 | def test_external_vector_add(): 21 | """Test external vector addition""" 22 | # Create test tensors 23 | a = torch.tensor([1.0, 2.0, 3.0, 4.0], device='cuda', dtype=torch.float32) 24 | b = torch.tensor([5.0, 6.0, 7.0, 8.0], device='cuda', dtype=torch.float32) 25 | 26 | # Test external implementation 27 | result = external_vector_add_cuda(a, b) 28 | 29 | # Verify result 30 | expected = torch.tensor([6.0, 8.0, 10.0, 12.0], device='cuda', dtype=torch.float32) 31 | assert torch.allclose(result, expected) 32 | assert result.device == a.device 33 | assert result.dtype == torch.float32 34 | 35 | 36 | def test_external_vector_scale(): 37 | """Test external vector scaling""" 38 | # Create test tensor 39 | input_tensor = torch.tensor([1.0, 2.0, 3.0, 4.0], device='cuda', dtype=torch.float32) 40 | scale = 2.5 41 | 42 | # Test external implementation 43 | result = external_vector_scale_cuda(input_tensor, scale) 44 | 45 | # Verify result 46 | expected = torch.tensor([2.5, 5.0, 7.5, 10.0], device='cuda', dtype=torch.float32) 47 | assert torch.allclose(result, expected) 48 | assert result.device == input_tensor.device 49 | assert result.dtype == torch.float32 50 | 51 | 52 | if __name__ == "__main__": 53 | pytest.main() 54 | -------------------------------------------------------------------------------- /packages/optim_test_tools/docs/examples/nvtx_range_wrapper.rst: -------------------------------------------------------------------------------- 1 | NVTX Range Wrapper Example 2 | ========================== 3 | 4 | The NVTX range wrapper helps annotate code with NVTX ranges to profile code with Nsight Systems. 5 | It follows the same singleton pattern as the stopwatch (see :doc:`stopwatch`): enable once, then push/pop 6 | ranges from any part of your code. 7 | 8 | Compared to using nvtx ranges directly, it offers the following advantages: 9 | - It is possible to centrally configure whether CUDA synchronization is performed when pushing/popping a 10 | range. While the ranges themselves have already minimal overhead if there is no profiling, the 11 | synchronization adds an additional overhead, and otherwise needs to be handled manually. 12 | - It is possible to check for range push/pop mismatches (only use for debugging purposes and leave disabled 13 | otherwise, as it has an overhead). It can be very handy to check for unexpected range pops for some key 14 | ranges, as manual search for mismatches can be tedious for large codebases. 15 | 16 | .. seealso:: 17 | 18 | The code of this example can be found in the repository under 19 | ``packages/optim_test_tools/examples/nvtx_range_wrapper_example.py``. 20 | 21 | Overview 22 | -------- 23 | 24 | - Singleton: ``NVTXRangeWrapper()`` returns the global instance. 25 | - Call ``enable(...)`` once to activate; otherwise calls are no-ops with minimal overhead. 26 | - Push/pop named ranges; optionally verify that the popped name matches expectations. 27 | 28 | Example 29 | ------- 30 | 31 | Please see the notes in the code for more details. 32 | 33 | .. note-literalinclude:: ../../examples/nvtx_range_wrapper_example.py 34 | :language: python 35 | :caption: packages/optim_test_tools/examples/nvtx_range_wrapper_example.py 36 | :linenos: 37 | :lineno-match: 38 | 39 | Related examples 40 | ---------------- 41 | 42 | - See the :doc:`stopwatch` example for similar usage with timings and warm-up handling. 43 | - The tensor dumper examples (:doc:`tensor_dumper_comparison` and :doc:`tensor_dumper_dumping`) demonstrate 44 | another singleton tool for capturing tensors and gradients. 45 | 46 | 47 | -------------------------------------------------------------------------------- /scripts/formatting/black_format_subpackage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # Script to format a single namespace package with Black 18 | # Usage: ./black_format_subpackage.sh 19 | # Example: ./black_format_subpackage.sh examples 20 | 21 | set -e 22 | 23 | # Get script directory and project root 24 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 25 | PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" 26 | 27 | # Change to project root 28 | cd "$PROJECT_ROOT" 29 | 30 | if [ $# -eq 0 ] || [ $# -gt 1 ] || [[ "$1" == -* ]]; then 31 | echo "Usage: $0 " 32 | if [ $# -gt 1 ]; then 33 | echo "Error: Unexpected extra arguments: ${@:2}" 34 | elif [[ "$1" == -* ]]; then 35 | echo "Error: Unknown option: $1" 36 | fi 37 | echo "Available namespace packages:" 38 | python3 -c " 39 | from namespace_packages_config import get_package_names 40 | for pkg in get_package_names(): 41 | print(f' - {pkg}') 42 | " 43 | exit 1 44 | fi 45 | 46 | PACKAGE=$1 47 | 48 | # Check if package exists 49 | if [ ! -d "packages/$PACKAGE" ]; then 50 | echo "Error: Namespace package 'packages/$PACKAGE' does not exist" 51 | exit 1 52 | fi 53 | 54 | echo "Formatting namespace package: $PACKAGE" 55 | 56 | # Format Python files in packages// (includes tests/ and ext_impl/ subdirectories) 57 | echo "Formatting packages/$PACKAGE/..." 58 | if [ -d "packages/$PACKAGE" ]; then 59 | black packages/$PACKAGE/ 60 | fi 61 | 62 | echo "Formatting of namespace package '$PACKAGE' completed successfully!" -------------------------------------------------------------------------------- /packages/example_package/docs/intro.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | This is the documentation for the **example_package** package, which demonstrates how to create ACCV-Lab 5 | namespace packages with C++ and CUDA extensions. 6 | 7 | .. note:: 8 | 9 | This documentation is also used as an example for how to create documentation for a namespace package. 10 | Please refer to the :doc:`../../../guides/DOCUMENTATION_SETUP_GUIDE` for more details. 11 | details. 12 | 13 | Package Overview 14 | ---------------- 15 | 16 | The example package provides: 17 | 18 | * **C++ Extensions**: Vector and matrix operations implemented in C++ 19 | * **CUDA Extensions**: GPU-accelerated vector operations 20 | * **Python Wrappers**: Easy-to-use Python functions that wrap the extensions 21 | * **Build System**: Complete setup for building C++/CUDA extensions 22 | 23 | Key Features 24 | ------------ 25 | 26 | * Vector sum and matrix transpose using C++ extensions 27 | * Element-wise vector multiplication and reduction using CUDA 28 | * Automatic build information display 29 | * Simple hello function for testing 30 | 31 | Basic Usage 32 | ----------- 33 | 34 | Here's a quick example of how to use the package: 35 | 36 | .. code-block:: python 37 | 38 | import torch 39 | import accvlab.example_package as example_pkg 40 | 41 | # C++ extension example 42 | vector = torch.tensor([1.0, 2.0, 3.0, 4.0, 5.0]) 43 | vector_sum = example_pkg.cpp_vector_sum(vector) 44 | print(f"Vector sum: {vector_sum}") 45 | 46 | # CUDA extension example (if CUDA is available) 47 | if torch.cuda.is_available(): 48 | a = torch.tensor([1.0, 2.0, 3.0, 4.0], device='cuda') 49 | b = torch.tensor([2.0, 3.0, 4.0, 5.0], device='cuda') 50 | multiplied = example_pkg.cuda_vector_multiply(a, b) 51 | print(f"Element-wise multiplication: {multiplied}") 52 | 53 | Examples 54 | -------- 55 | 56 | For examples, see :doc:`examples`. The example makes use of ``note-literalinclude`` to include the 57 | example code in the documentation and highlight notes in the code (comment blocks starting with ``# @NOTE``). 58 | 59 | .. toctree:: 60 | :maxdepth: 2 61 | :caption: Examples 62 | 63 | examples -------------------------------------------------------------------------------- /packages/example_package/tests/test_example_package.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import pytest 16 | import torch 17 | import accvlab.example_package 18 | 19 | 20 | def test_examples_import(): 21 | assert accvlab.example_package is not None 22 | 23 | 24 | def test_external_module_available(): 25 | try: 26 | import accvlab.example_package.accvlab_example_package_ext 27 | 28 | assert accvlab.example_package.accvlab_example_package_ext is not None 29 | except ImportError: 30 | pytest.fail("External module accvlab_examples_ext not found.") 31 | 32 | 33 | def test_cpp_extension_available(): 34 | import accvlab.example_package._cpp 35 | 36 | assert hasattr(accvlab.example_package._cpp, "vector_sum") 37 | 38 | 39 | def test_cuda_extension_available(): 40 | import accvlab.example_package._cuda 41 | 42 | assert hasattr(accvlab.example_package._cuda, "vector_multiply") 43 | 44 | 45 | def test_cpp_vector_sum(): 46 | x = torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32) 47 | result = accvlab.example_package.cpp_vector_sum(x) 48 | assert result == 6.0 49 | 50 | 51 | def test_cuda_vector_multiply(): 52 | if not torch.cuda.is_available(): 53 | pytest.skip("CUDA not available") 54 | a = torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32).cuda() 55 | b = torch.tensor([2.0, 3.0, 4.0], dtype=torch.float32).cuda() 56 | result = accvlab.example_package.cuda_vector_multiply(a, b) 57 | expected = torch.tensor([2.0, 6.0, 12.0], dtype=torch.float32).cuda() 58 | assert torch.allclose(result, expected) 59 | 60 | 61 | if __name__ == "__main__": 62 | pytest.main() 63 | -------------------------------------------------------------------------------- /packages/batching_helpers/example/input_data_helper.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch 16 | 17 | 18 | def insert_gt_data_noisy( 19 | data_gt, data_pred, indices_gt, indices_pred, noise_level, data_is_bboxes, negative_only 20 | ): 21 | for s in range(len(indices_gt)): 22 | for i in range(len(indices_gt[s])): 23 | i_pred = indices_pred[s][i] 24 | i_gt = indices_gt[s][i] 25 | to_insert = data_gt[s][i_gt] 26 | # Don't use += as this will overwrite the original data 27 | to_add = torch.randn_like(to_insert) * noise_level 28 | if negative_only: 29 | to_add = -torch.abs(to_add) 30 | to_insert = to_insert + to_add 31 | if data_is_bboxes: 32 | to_insert[..., 2:4] = torch.max(to_insert[..., 0:2], to_insert[..., 2:4]) 33 | data_pred[s, i_pred, ...] = to_insert 34 | 35 | 36 | def create_one_hot(classes_gt, num_classes): 37 | batch_size = len(classes_gt) 38 | res = [] 39 | for s in range(batch_size): 40 | curr_res = torch.zeros((classes_gt[s].shape[0], num_classes), dtype=torch.float32, device="cuda:0") 41 | for i_target, target_cgt in enumerate(classes_gt[s]): 42 | curr_res[i_target, target_cgt] = 1.0 43 | res.append(curr_res) 44 | return res 45 | 46 | 47 | def insert_existence_noisy(pred_existence, indices_pred, noise_level): 48 | batch_size = pred_existence.shape[0] 49 | for s in range(batch_size): 50 | for i_p in indices_pred[s]: 51 | pred_existence[s, i_p] = 1.0 - torch.rand(1, dtype=torch.float32, device="cuda:0") * noise_level 52 | -------------------------------------------------------------------------------- /scripts/formatting/format_subpackage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # Combined script to format both Python and C++ code for a single namespace package 18 | # Usage: ./format_subpackage.sh 19 | # Example: ./format_subpackage.sh examples 20 | 21 | set -e 22 | 23 | # Get script directory and project root 24 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 25 | PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" 26 | 27 | # Change to project root 28 | cd "$PROJECT_ROOT" 29 | 30 | if [ $# -eq 0 ] || [ $# -gt 1 ] || [[ "$1" == -* ]]; then 31 | echo "Usage: $0 " 32 | if [ $# -gt 1 ]; then 33 | echo "Error: Unexpected extra arguments: ${@:2}" 34 | elif [[ "$1" == -* ]]; then 35 | echo "Error: Unknown option: $1" 36 | fi 37 | echo "Available namespace packages:" 38 | python3 -c " 39 | from namespace_packages_config import get_package_names 40 | for pkg in get_package_names(): 41 | print(f' - {pkg}') 42 | " 43 | exit 1 44 | fi 45 | 46 | PACKAGE=$1 47 | 48 | # Check if package exists 49 | if [ ! -d "packages/$PACKAGE" ]; then 50 | echo "Error: Namespace package 'packages/$PACKAGE' does not exist" 51 | exit 1 52 | fi 53 | 54 | echo "Formatting namespace package '$PACKAGE' (Python and C++ code)..." 55 | 56 | # Format Python code 57 | echo "" 58 | echo "=== Formatting Python code ===" 59 | "$SCRIPT_DIR/black_format_subpackage.sh" "$PACKAGE" 60 | 61 | # Format C++ code 62 | echo "" 63 | echo "=== Formatting C++ code ===" 64 | "$SCRIPT_DIR/clang_format_subpackage.sh" "$PACKAGE" 65 | 66 | echo "" 67 | echo "All code formatting for namespace package '$PACKAGE' completed successfully!" -------------------------------------------------------------------------------- /packages/example_package/docs/examples.rst: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | This section demonstrates how examples can be included in documentation and how the directory copying system works. 5 | 6 | Example Code 7 | ------------ 8 | 9 | The example code is located in the ``examples/`` directory and gets mirrored during the documentation build 10 | process (due to the ``examples`` directory being listed in the ``docu_referenced_dirs.txt`` file). Here's the 11 | complete example: 12 | 13 | .. note-literalinclude:: ../examples/basic_usage.py 14 | :language: python 15 | :caption: Simple usage example 16 | :name: basic-usage-example 17 | 18 | Demonstrating Directory Mirroring 19 | --------------------------------- 20 | 21 | This documentation can reference the example code because the ``examples/`` directory is mirrored to the 22 | documentation build location. The ``docu_referenced_dirs.txt`` file specifies which directories to mirror: 23 | 24 | .. code-block:: text 25 | :caption: Directory mirroring configuration 26 | :name: docu-referenced-dirs 27 | 28 | # This file lists additional directories (besides docs) that are referenced by documentation. 29 | # The docs directory is always mirrored automatically. 30 | # Add one directory name per line, without the docs directory. 31 | # Lines starting with # are comments and are ignored. 32 | 33 | # Example: if your documentation references code in the examples directory, uncomment the lines below 34 | examples 35 | 36 | How Directory Mirroring Works 37 | ----------------------------- 38 | 39 | 1. **Source Location**: The example code lives in ``packages/example_package/examples/`` 40 | 2. **Build Process**: During documentation build, the ``mirror_referenced_dirs.py`` script mirrors (symlinks 41 | by default) the ``examples/`` directory to ``docs/contained_package_docs_mirror/example_package/examples/`` 42 | 3. **Documentation References**: The documentation can then reference the mirrored files using relative paths 43 | like ``../examples/basic_usage.py`` 44 | 4. **Path Resolution**: The relative paths work because the documentation and examples are now in the same 45 | directory with the same structure as in the original source location. 46 | 47 | This ensures that documentation references to example code remain functional when mirroring. -------------------------------------------------------------------------------- /CONTRIBUTING.MD: -------------------------------------------------------------------------------- 1 | # Guidelines 2 | 3 | For contribution guidelines, please see the [Contribution Guide](docs/guides/CONTRIBUTION_GUIDE.md). 4 | 5 | 6 | # Signing Your Work 7 | 8 | * We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. 9 | 10 | * Any contribution which contains commits that are not Signed-Off will not be accepted. 11 | 12 | * To sign off on a commit you simply use the `--signoff` (or `-s`) option when committing your changes: 13 | ```bash 14 | $ git commit -s -m "Add cool feature." 15 | ``` 16 | This will append the following to your commit message: 17 | ``` 18 | Signed-off-by: Your Name 19 | ``` 20 | 21 | * Full text of the DCO: 22 | 23 | ``` 24 | Developer Certificate of Origin 25 | Version 1.1 26 | 27 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 28 | 1 Letterman Drive 29 | Suite D4700 30 | San Francisco, CA, 94129 31 | 32 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 33 | 34 | 35 | Developer's Certificate of Origin 1.1 36 | 37 | By making a contribution to this project, I certify that: 38 | 39 | (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or 40 | 41 | (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or 42 | 43 | (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. 44 | 45 | (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. 46 | ``` -------------------------------------------------------------------------------- /packages/batching_helpers/accvlab/batching_helpers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Import the relevant data type & functions directly into the top-level package 16 | from .data_format import RaggedBatch 17 | from .batched_indexing_ops import ( 18 | batched_indexing_access, 19 | batched_inverse_indexing_access, 20 | batched_indexing_write, 21 | ) 22 | from .batched_index_mapping_op import batched_index_mapping 23 | from .batched_mask_from_indices import get_mask_from_indices 24 | from .batched_bool_indexing import batched_bool_indexing, batched_bool_indexing_write 25 | from .batched_processing_py import ( 26 | average_over_targets, 27 | sum_over_targets, 28 | apply_mask_to_tensor, 29 | squeeze_except_batch_and_sample, 30 | get_compact_from_named_tuple, 31 | get_compact_lists, 32 | combine_data, 33 | get_indices_from_mask, 34 | ) 35 | 36 | # The order of the elements as defined here will be maintained by the Sphinx-generated documentation 37 | __all__ = [ 38 | 'RaggedBatch', 39 | *sorted( 40 | [ 41 | 'batched_indexing_access', 42 | 'batched_inverse_indexing_access', 43 | "batched_indexing_write", 44 | 'batched_index_mapping', 45 | 'batched_bool_indexing', 46 | 'batched_bool_indexing_write', 47 | 'average_over_targets', 48 | 'sum_over_targets', 49 | 'apply_mask_to_tensor', 50 | 'squeeze_except_batch_and_sample', 51 | 'get_mask_from_indices', 52 | 'get_indices_from_mask', 53 | 'get_compact_from_named_tuple', 54 | 'get_compact_lists', 55 | 'combine_data', 56 | ] 57 | ), 58 | ] 59 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/PyNvOnDemandDecoder/src/PyNvOnDemandDecoder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "PyNvOnDemandDecoder.hpp" 18 | 19 | using namespace std; 20 | using namespace chrono; 21 | 22 | namespace py = pybind11; 23 | 24 | static auto ThrowOnCudaError = [](CUresult res, int lineNum = -1) { 25 | if (CUDA_SUCCESS != res) { 26 | stringstream ss; 27 | 28 | if (lineNum > 0) { 29 | ss << __FILE__ << ":"; 30 | ss << lineNum << endl; 31 | } 32 | 33 | const char* errName = nullptr; 34 | if (CUDA_SUCCESS != cuGetErrorName(res, &errName)) { 35 | ss << "CUDA error with code " << res << endl; 36 | } else { 37 | ss << "CUDA error: " << errName << endl; 38 | } 39 | 40 | const char* errDesc = nullptr; 41 | cuGetErrorString(res, &errDesc); 42 | 43 | if (!errDesc) { 44 | ss << "No error string available" << endl; 45 | } else { 46 | ss << errDesc << endl; 47 | } 48 | 49 | throw runtime_error(ss.str()); 50 | } 51 | }; 52 | 53 | void Init_PyNvGopDecoder(py::module& m); 54 | void Init_PyNvVideoReader(py::module& m); 55 | void Init_PyNvSampleReader(py::module& m); 56 | PYBIND11_MODULE(_PyNvOnDemandDecoder, m) { 57 | Init_PyNvVideoReader(m); 58 | Init_PyNvGopDecoder(m); 59 | Init_PyNvSampleReader(m); 60 | 61 | m.doc() = R"pbdoc( 62 | accvlab.on_demand_video_decoder 63 | ---------- 64 | .. currentmodule:: PyNvVideoReader 65 | .. autosummary:: 66 | :toctree: _generate 67 | 68 | PyNvVideoReader 69 | 70 | )pbdoc"; 71 | } 72 | -------------------------------------------------------------------------------- /packages/example_skbuild_package/accvlab/example_skbuild_package/functions/functions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """ 16 | ACCV-Lab Examples Functions 17 | Wrapper functions for C++ and CUDA extensions 18 | """ 19 | 20 | # Import extensions (assuming they are installed correctly) 21 | # Note that torch needs to be imported for the extensions import to work 22 | import torch 23 | 24 | # Extension availability flags 25 | HAS_CPP_EXTENSIONS = False 26 | HAS_CUDA_EXTENSIONS = False 27 | 28 | try: 29 | import accvlab.example_skbuild_package._ext as _ext 30 | 31 | HAS_CUDA_EXTENSIONS = True 32 | except ImportError: 33 | # Extension not available (e.g., during development) 34 | _ext = None 35 | 36 | 37 | def vector_add(a, b): 38 | """ 39 | Element-wise vector addition using the CUDA extension. 40 | 41 | :gpu: 42 | 43 | Args: 44 | a: First input 1D tensor on a CUDA device. 45 | b: Second input 1D tensor on a CUDA device. 46 | 47 | Returns: 48 | Tensor on CUDA containing the element-wise sum of ``a`` and ``b``. 49 | """ 50 | if not HAS_CUDA_EXTENSIONS or _ext is None: 51 | raise ImportError("CUDA extension not available. Please install the package.") 52 | return _ext.external_vector_add_cuda(a, b) 53 | 54 | 55 | def vector_scale(a, scale): 56 | """ 57 | Element-wise vector scaling using the CUDA extension. 58 | 59 | :gpu: 60 | 61 | Args: 62 | a: Input 1D tensor on a CUDA device. 63 | scale: Scalar factor used to scale all elements of ``a``. 64 | 65 | Returns: 66 | Tensor on CUDA containing the scaled values of ``a``. 67 | """ 68 | if not HAS_CUDA_EXTENSIONS or _ext is None: 69 | raise ImportError("CUDA extension not available. Please install the package.") 70 | return _ext.external_vector_scale_cuda(a, scale) 71 | -------------------------------------------------------------------------------- /docs/sync_root_readme_for_docs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Sync the project root README into the docs tree with adjusted links. 5 | 6 | Canonical source: 7 | /README.md 8 | 9 | Generated target: 10 | /docs/project_overview/README.md 11 | 12 | This script rewrites guide links so they work from within the docs tree, 13 | while keeping the root README clean for GitHub and local repo usage. 14 | """ 15 | 16 | from __future__ import annotations 17 | 18 | import shutil 19 | from pathlib import Path 20 | 21 | PROJECT_ROOT = Path(__file__).resolve().parent.parent 22 | DOCS_DIR = PROJECT_ROOT / "docs" 23 | SOURCE_README = PROJECT_ROOT / "README.md" 24 | TARGET_DIR = DOCS_DIR / "project_overview" 25 | TARGET_README = TARGET_DIR / "README.md" 26 | 27 | 28 | def transform_links(text: str) -> str: 29 | """ 30 | Adjust guide links so they are correct relative to the docs tree. 31 | 32 | Root README uses: 33 | docs/guides/XYZ.md 34 | 35 | Docs-local copy should use: 36 | ../guides/XYZ.md 37 | """ 38 | return text.replace("](docs/guides/", "](../guides/") 39 | 40 | 41 | def add_quick_start_label(text: str) -> str: 42 | """ 43 | Inject a MyST section label for the Quick Start section **only** in the 44 | docs-local copy of the README. 45 | 46 | This keeps the project root README.md clean (no MyST-specific syntax), 47 | while allowing Sphinx to reference the Quick Start section via 48 | ``:ref:`project_overview-quick-start``` from within the docs. 49 | """ 50 | label = "(project_overview-quick-start)=" 51 | marker = "## Quick Start" 52 | 53 | # If the label is already present (e.g., from a previous run), do nothing. 54 | if label in text: 55 | return text 56 | 57 | # Insert the label immediately before the first "## Quick Start" heading. 58 | if marker in text: 59 | return text.replace(marker, f"{label}\n{marker}", 1) 60 | 61 | # Fallback: no Quick Start section found; return text unchanged. 62 | return text 63 | 64 | 65 | def main() -> int: 66 | if not SOURCE_README.exists(): 67 | raise SystemExit(f"Source README not found: {SOURCE_README}") 68 | 69 | TARGET_DIR.mkdir(parents=True, exist_ok=True) 70 | 71 | raw = SOURCE_README.read_text(encoding="utf-8") 72 | transformed = transform_links(raw) 73 | transformed = add_quick_start_label(transformed) 74 | 75 | TARGET_README.write_text(transformed, encoding="utf-8") 76 | return 0 77 | 78 | 79 | if __name__ == "__main__": 80 | raise SystemExit(main()) 81 | -------------------------------------------------------------------------------- /packages/draw_heatmap/examples/draw_heatmap_batched.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch 16 | from accvlab.draw_heatmap import draw_heatmap_batched 17 | from input_data import ( 18 | device, 19 | centers_list, 20 | radii_list, 21 | HEATMAP_SIZE, 22 | diameter_to_sigma_factor, 23 | k_scale, 24 | MAX_NUM_TARGET, 25 | ) 26 | from accvlab.batching_helpers import RaggedBatch 27 | 28 | 29 | def draw_heatmap_example_batch(): 30 | """ 31 | This example shows how to draw heatmaps for batched inputs. 32 | 33 | Args: 34 | centers_list: List[torch.Tensor] 35 | radii_list: List[torch.Tensor] 36 | HEATMAP_SIZE: [H, W] 37 | diameter_to_sigma_factor: float 38 | k_scale: float 39 | """ 40 | batch_size = len(centers_list) 41 | 42 | # In order to support the batched input, we need to convert the input to the format of ragged batch 43 | centers = torch.zeros((batch_size, MAX_NUM_TARGET, 2), dtype=torch.int32, device=device) 44 | radii = torch.zeros((batch_size, MAX_NUM_TARGET), dtype=torch.int32, device=device) 45 | gt_nums_targets = torch.zeros((batch_size,), dtype=torch.int32, device=device) 46 | # Copy over the valid boxes 47 | for i, sublist in enumerate(centers_list): 48 | centers[i, : len(sublist)] = centers_list[i] 49 | radii[i, : len(sublist)] = radii_list[i] 50 | gt_nums_targets[i] = len(sublist) 51 | 52 | centers_rb = RaggedBatch(centers, sample_sizes=gt_nums_targets) 53 | radii_rb = RaggedBatch(radii, sample_sizes=gt_nums_targets) 54 | heatmaps = torch.zeros((batch_size, HEATMAP_SIZE[0], HEATMAP_SIZE[1]), dtype=torch.float32, device=device) 55 | draw_heatmap_batched(heatmaps, centers_rb, radii_rb, diameter_to_sigma_factor, k_scale) 56 | return heatmaps 57 | 58 | 59 | if __name__ == "__main__": 60 | heatmaps = draw_heatmap_example_batch() 61 | print(heatmaps.shape) 62 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/design/output.rst: -------------------------------------------------------------------------------- 1 | Output -- DALI Structured Output Iterator 2 | ========================================= 3 | 4 | In general, the DALI pipeline emits a flat sequence of tensors (or DALI tensor lists). In case of our 5 | framework, these are the results obtained from calling 6 | :meth:`~accvlab.dali_pipeline_framework.pipeline.SampleDataGroup.get_data` on the 7 | :class:`~accvlab.dali_pipeline_framework.pipeline.SampleDataGroup` object used in the pipeline. 8 | 9 | For complex data formats, a flat list quickly becomes hard to manage. Therefore, we introduce the 10 | :class:`~accvlab.dali_pipeline_framework.pipeline.DALIStructuredOutputIterator` class, which re-assembles the data 11 | to its original structure. 12 | 13 | The :class:`~accvlab.dali_pipeline_framework.pipeline.DALIStructuredOutputIterator` is designed to be a drop-in 14 | replacement for a PyTorch DataLoader. Apart from the re-assembly of the data, this is achieved by: 15 | 16 | - Using the same interface as a PyTorch DataLoader (i.e. the iterator interface) 17 | - Option to auto-convert the output to a nested dictionary (using 18 | :meth:`~accvlab.dali_pipeline_framework.pipeline.SampleDataGroup.to_dictionary` internally) 19 | - Option to apply a user-defined post-processing function whenever obtaining the data (to perform 20 | light-weight steps not possible in the pipeline, e.g. convert certain fields to a type not directly 21 | supported by DALI) 22 | 23 | .. note:: 24 | 25 | The user-defined post-processing in :class:`~accvlab.dali_pipeline_framework.pipeline.DALIStructuredOutputIterator` 26 | runs in the training thread when data is requested; keep it lightweight and prefer doing work inside the 27 | DALI pipeline where possible. 28 | 29 | .. note:: 30 | While the :class:`~accvlab.dali_pipeline_framework.pipeline.DALIStructuredOutputIterator` class is designed to be a 31 | drop-in replacement for a PyTorch DataLoader, there may be issues if the training implementation 32 | contains checks in the form of ``assert isinstance(iterator_object, DataLoader)``. These checks may be 33 | inside dependencies used by the training implementation, and so cannot be changed easily in a clean way. For 34 | these cases, the :class:`~accvlab.dali_pipeline_framework.pipeline.DALIStructuredOutputIterator` provides 35 | a :meth:`~accvlab.dali_pipeline_framework.pipeline.DALIStructuredOutputIterator.CreateAsDataLoaderObject` method, 36 | which creates an iterator object masked as a PyTorch DataLoader object, so that these checks pass. 37 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/accvlab/dali_pipeline_framework/processing_steps/data_group_in_path_applied_step.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Used to enable type hints using a class type inside the implementation of that class itself. 16 | from __future__ import annotations 17 | 18 | from typing import Union, Sequence 19 | 20 | try: 21 | from typing import override 22 | except ImportError: 23 | from typing_extensions import override 24 | 25 | from ..pipeline.sample_data_group import SampleDataGroup 26 | 27 | from .group_to_apply_to_selected_step_base import GroupToApplyToSelectedStepBase 28 | from .pipeline_step_base import PipelineStepBase 29 | 30 | 31 | class DataGroupInPathAppliedStep(GroupToApplyToSelectedStepBase): 32 | '''Apply a contained processing step to the sub-tree rooted at a given path.''' 33 | 34 | def __init__( 35 | self, 36 | processing_step_to_apply: PipelineStepBase, 37 | path_to_apply_to: Union[str, int, Sequence[str, int]], 38 | ): 39 | ''' 40 | 41 | Args: 42 | processing_step_to_apply: The contained processing step 43 | path_to_apply_to: Path to the root of the sub-tree to apply `processing_step_to_apply` to 44 | ''' 45 | 46 | GroupToApplyToSelectedStepBase.__init__(self, processing_step_to_apply) 47 | self._path_to_apply_to = path_to_apply_to 48 | 49 | @override 50 | def _check_and_get_paths_to_apply_to(self, data: SampleDataGroup) -> Sequence[Sequence[str, int]]: 51 | 52 | if not data.path_exists_and_is_data_group_field(self._path_to_apply_to): 53 | raise ValueError( 54 | f"DataGroupInPathAppliedStep: Path `{self._path_to_apply_to}` does not exist or is not a data group field." 55 | ) 56 | if data.path_is_single_name(self._path_to_apply_to): 57 | path = (self._path_to_apply_to,) 58 | else: 59 | path = self._path_to_apply_to 60 | paths = (path,) 61 | return paths 62 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/examples.rst: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | The examples are provided in the ``packages/dali_pipeline_framework/examples/`` directory. 5 | 6 | Pipeline Setup Examples 7 | ----------------------- 8 | 9 | .. list-table:: 10 | :header-rows: 1 11 | :widths: 15, 55, 30 12 | :class: no-scroll 13 | 14 | * - Example 15 | - Description 16 | - Entry Point Script 17 | * - :doc:`examples/2d_object_detection/index` 18 | - Shows how to set up a pipeline for 2D object detection. This example also demonstrates the flexibility 19 | of the pipeline framework by allowing the switch between single-camera and multi-camera data (adding a 20 | hierarchy level to the input data format), where no changes are needed in the pipeline implementation. 21 | - ``packages/dali_pipeline_framework/examples/example_pipeline_obj_det_2d.py`` 22 | * - :doc:`examples/stream_petr/index` 23 | - Demonstrates a pipeline for StreamPETR, a 3D object detection model which uses multi-camera data. Note 24 | that this pipeline can be directly used as a drop-in replacement for a PyTorch DataLoader in 25 | StreamPETR training. 26 | - ``packages/dali_pipeline_framework/examples/example_pipeline_stream_petr.py`` 27 | * - :doc:`examples/flexible_step/index` 28 | - Demonstrates how to implement a flexible step which can be used to process data in a flexible way. 29 | The :class:`~accvlab.dali_pipeline_framework.processing_steps.ImageDecoder` class is implemented here, 30 | starting from a simple step with hard-coded input data format, and then modified to achieve the 31 | flexibility of automatically finding and processing all relevant images in the input data. 32 | - (No script) 33 | 34 | .. toctree:: 35 | :maxdepth: 1 36 | :hidden: 37 | 38 | examples/2d_object_detection/index 39 | examples/stream_petr/index 40 | examples/flexible_step/index 41 | 42 | Data Loaders for NuScenes 43 | ------------------------- 44 | 45 | Both of the pipeline examples above rely use the NuScenes dataset. 46 | To enable the use of the dataset in the corresponding pipelines, related data loaders are provided. 47 | These data loaders share a large part of the functionality (both load the same data from NuScenes, but 48 | process and output it in a different format). 49 | Therefore, they share a large part of the implementation by 50 | using helper classes to read the data and perform the necessary conversions. See 51 | :doc:`examples/use_case_specific/nuscenes_data_loader`. 52 | 53 | .. toctree:: 54 | :maxdepth: 1 55 | :hidden: 56 | 57 | examples/use_case_specific/nuscenes_data_loader 58 | 59 | -------------------------------------------------------------------------------- /docs/spelling_wordlist.txt: -------------------------------------------------------------------------------- 1 | namespace 2 | ACCV-Lab 3 | CMake 4 | setuptools 5 | config 6 | repo 7 | Dockerfile 8 | docstring 9 | docstrings 10 | formatter 11 | symlink 12 | symlinks 13 | Jupyter 14 | py 15 | Nsight 16 | Hungarian 17 | runtime 18 | scikit 19 | pybind 20 | changelog 21 | Makefile 22 | intersphinx 23 | autosummary 24 | autodoc 25 | petr 26 | PETR 27 | pre 28 | bbox 29 | matcher 30 | centerness 31 | heatmap 32 | IoU 33 | impl 34 | iter 35 | apis 36 | dataset 37 | optim 38 | nvtx 39 | runnable 40 | nd 41 | th 42 | JSON 43 | warmup 44 | codec 45 | codecs 46 | demux 47 | demuxer 48 | demuxers 49 | demuxing 50 | demuxes 51 | sharding 52 | gop 53 | GOP 54 | gops 55 | preprocessing 56 | numpy 57 | param 58 | PyTorch 59 | batchify 60 | lidar 61 | quaternion 62 | dali 63 | iterable 64 | callable 65 | affine 66 | extrinsics 67 | intrinsics 68 | unary 69 | Gaussian 70 | viewport 71 | photometric 72 | randomization 73 | rtype 74 | dtype 75 | uint 76 | functor 77 | prefetch 78 | prefetched 79 | prefetching 80 | numba 81 | subclass 82 | parallelized 83 | serializable 84 | compactification 85 | compactified 86 | len 87 | RaggedBatch 88 | unsqueeze 89 | formatters 90 | misconfiguration 91 | misconfigurations 92 | codebase 93 | grayscale 94 | iterative 95 | iteratively 96 | filepaths 97 | cpp 98 | classwise 99 | heatmaps 100 | datasets 101 | gaussian 102 | subtype 103 | iterables 104 | callables 105 | boolean 106 | Gaussians 107 | resampling 108 | subclassing 109 | detections 110 | num 111 | Submodule 112 | submodule 113 | subclasses 114 | parallelization 115 | async 116 | subpackage 117 | subpackages 118 | codebases 119 | Acknowledgements 120 | StreamPETR 121 | bframe 122 | precompute 123 | FFmpeg 124 | quaternions 125 | accvlab 126 | downscaling 127 | upscaling 128 | parametrization 129 | Functors 130 | Functor 131 | bool 132 | broadcasted 133 | unsqueezing 134 | dimensionality 135 | mmdet 136 | randomizations 137 | concat 138 | Rodrigues 139 | ints 140 | subdirectory 141 | overriden 142 | override 143 | parametrize 144 | parametrized 145 | BBox 146 | subdirectories 147 | filesystem 148 | NVMe 149 | filepath 150 | vals 151 | dst 152 | idxs 153 | idxes 154 | planeIdx 155 | clipA 156 | denormalize 157 | Kaggle 158 | Probabilistically 159 | probabilistically 160 | reproducibility 161 | dev 162 | Lustre 163 | matchers 164 | Demux 165 | keyframe 166 | Keyframe 167 | toolchains 168 | NVCC 169 | CMake 170 | Submodules 171 | submodules 172 | blockquotes 173 | blockquoted 174 | dockerfile 175 | hardcoding 176 | hardcode 177 | hardcoded 178 | Nvidia 179 | Xeon 180 | dataloader 181 | args 182 | doesn 183 | literalinclude 184 | blockquote 185 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/ext_impl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cmake_minimum_required(VERSION 3.10) 16 | include(CMakePrintHelpers) 17 | 18 | if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) 19 | if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24") 20 | set(CMAKE_CUDA_ARCHITECTURES native) 21 | else() 22 | # Fallback list for older CMake versions without 'native' 23 | set(CMAKE_CUDA_ARCHITECTURES "75;80;86") 24 | endif() 25 | endif() 26 | 27 | project(get_affine_transform_plugin LANGUAGES CUDA CXX C) 28 | 29 | if(NOT DEFINED CMAKE_CXX_STANDARD) 30 | set(CMAKE_CXX_STANDARD 17) 31 | endif() 32 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 33 | set(CMAKE_CXX_EXTENSIONS OFF) 34 | set(CMAKE_C_STANDARD 11) 35 | 36 | set(CMAKE_CUDA_STANDARD 17) 37 | set(CMAKE_CUDA_STANDARD_REQUIRED ON) 38 | 39 | cmake_print_variables(lapack_libraries) 40 | include_directories(SYSTEM "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}") 41 | 42 | execute_process( 43 | COMMAND python3 -c "import nvidia.dali as dali; print(dali.sysconfig.get_lib_dir())" 44 | OUTPUT_VARIABLE DALI_LIB_DIR) 45 | string(STRIP "${DALI_LIB_DIR}" DALI_LIB_DIR) 46 | 47 | execute_process( 48 | COMMAND python3 -c "import nvidia.dali as dali; print(dali.sysconfig.get_include_dir())" 49 | OUTPUT_VARIABLE DALI_INCLUDE_DIR) 50 | string(STRIP "${DALI_INCLUDE_DIR}" DALI_INCLUDE_DIR) 51 | 52 | execute_process( 53 | COMMAND python3 -c "import nvidia.dali as dali; print(\" \".join(dali.sysconfig.get_compile_flags()))" 54 | OUTPUT_VARIABLE DALI_COMPILE_FLAGS) 55 | string(STRIP "${DALI_COMPILE_FLAGS}" DALI_COMPILE_FLAGS) 56 | 57 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DALI_COMPILE_FLAGS} ") 58 | set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} ${DALI_COMPILE_FLAGS} ") 59 | include_directories("${DALI_INCLUDE_DIR}") 60 | link_directories("${DALI_LIB_DIR}") 61 | 62 | add_library(_draw_gaussians SHARED DrawGaussians.cc) 63 | target_link_libraries(_draw_gaussians dali) 64 | 65 | install(TARGETS _draw_gaussians 66 | LIBRARY DESTINATION . 67 | RUNTIME DESTINATION . 68 | ) 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /packages/draw_heatmap/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from setuptools import setup 16 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension 17 | import sys 18 | from pathlib import Path 19 | from accvlab_build_config import ( 20 | load_config, 21 | detect_cuda_info, 22 | get_compile_flags, 23 | get_abs_setup_dir, 24 | ) 25 | 26 | from accvlab_build_config import run_external_build 27 | 28 | 29 | def get_extensions(): 30 | """Return all extensions""" 31 | config = load_config() 32 | cuda_info = detect_cuda_info() 33 | 34 | compile_flags = get_compile_flags(config, cuda_info) 35 | 36 | # Source directory is relative to setup.py 37 | source_dir = 'accvlab/draw_heatmap' 38 | # Note that include directories need to be global, while source directories are relative 39 | include_dirs = [str(get_abs_setup_dir(__file__) / source_dir / 'include')] 40 | 41 | extensions = [] 42 | 43 | # CUDA extension 44 | cuda_sources = [ 45 | str(Path(source_dir) / 'csrc' / 'draw_heatmap.cpp'), 46 | str(Path(source_dir) / 'csrc' / 'draw_heatmap_cuda.cu'), 47 | ] 48 | cu_ext = CUDAExtension( 49 | name='accvlab.draw_heatmap.draw_heatmap_ext', 50 | sources=cuda_sources, 51 | include_dirs=include_dirs, 52 | extra_compile_args={ 53 | 'cxx': compile_flags['cxx'], 54 | 'nvcc': compile_flags['nvcc'], 55 | }, 56 | language='c++', 57 | verbose=config['VERBOSE_BUILD'], 58 | ) 59 | extensions.append(cu_ext) 60 | 61 | return extensions 62 | 63 | 64 | # Run external build before setup 65 | run_external_build(str(Path(__file__).parent)) 66 | 67 | setup( 68 | name="accvlab.draw_heatmap", 69 | version="0.1.0", 70 | description="Draw Heatmap Package (part of the ACCV-Lab package).", 71 | ext_modules=get_extensions(), 72 | cmdclass={"build_ext": BuildExtension}, 73 | python_requires=">=3.8", 74 | zip_safe=False, 75 | options={ 76 | 'build_ext': { 77 | 'use_ninja': True, # Use Ninja for faster builds 78 | } 79 | }, 80 | ) 81 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/VideoCodecSDKUtils/helper_classes/Utils/BitDepth.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | static __global__ void ConvertUInt8ToUInt16Kernel(uint8_t *dpUInt8, uint16_t *dpUInt16, int nSrcPitch, int nDestPitch, int nWidth, int nHeight) 22 | { 23 | int x = blockIdx.x * blockDim.x + threadIdx.x, 24 | y = blockIdx.y * blockDim.y + threadIdx.y; 25 | 26 | if (x >= nWidth || y >= nHeight) 27 | { 28 | return; 29 | } 30 | int destStrideInPixels = nDestPitch / (sizeof(uint16_t)); 31 | *(uchar2 *)&dpUInt16[y * destStrideInPixels + x] = uchar2{ 0, dpUInt8[y * nSrcPitch + x] }; 32 | } 33 | 34 | static __global__ void ConvertUInt16ToUInt8Kernel(uint16_t *dpUInt16, uint8_t *dpUInt8, int nSrcPitch, int nDestPitch, int nWidth, int nHeight) 35 | { 36 | int x = blockIdx.x * blockDim.x + threadIdx.x, 37 | y = blockIdx.y * blockDim.y + threadIdx.y; 38 | 39 | if (x >= nWidth || y >= nHeight) 40 | { 41 | return; 42 | } 43 | int srcStrideInPixels = nSrcPitch / (sizeof(uint16_t)); 44 | dpUInt8[y * nDestPitch + x] = ((uchar2 *)&dpUInt16[y * srcStrideInPixels + x])->y; 45 | } 46 | 47 | void ConvertUInt8ToUInt16(uint8_t *dpUInt8, uint16_t *dpUInt16, int nSrcPitch, int nDestPitch, int nWidth, int nHeight) 48 | { 49 | dim3 blockSize(16, 16, 1); 50 | dim3 gridSize(((uint32_t)nWidth + blockSize.x - 1) / blockSize.x, ((uint32_t)nHeight + blockSize.y - 1) / blockSize.y, 1); 51 | ConvertUInt8ToUInt16Kernel <<< gridSize, blockSize >>>(dpUInt8, dpUInt16, nSrcPitch, nDestPitch, nWidth, nHeight); 52 | } 53 | 54 | void ConvertUInt16ToUInt8(uint16_t *dpUInt16, uint8_t *dpUInt8, int nSrcPitch, int nDestPitch, int nWidth, int nHeight) 55 | { 56 | dim3 blockSize(16, 16, 1); 57 | dim3 gridSize(((uint32_t)nWidth + blockSize.x - 1) / blockSize.x, ((uint32_t)nHeight + blockSize.y - 1) / blockSize.y, 1); 58 | ConvertUInt16ToUInt8Kernel <<>>(dpUInt16, dpUInt8, nSrcPitch, nDestPitch, nWidth, nHeight); 59 | } 60 | -------------------------------------------------------------------------------- /packages/optim_test_tools/docs/examples/stopwatch.rst: -------------------------------------------------------------------------------- 1 | Stopwatch Example 2 | ================= 3 | 4 | 5 | Overview 6 | -------- 7 | 8 | .. module-docstring:: ../../examples/stopwatch_example.py 9 | 10 | .. seealso:: 11 | 12 | The code of this example can be found in the repository under 13 | ``packages/optim_test_tools/examples/stopwatch_example.py``. 14 | 15 | Example 16 | ------- 17 | 18 | Example Implementation 19 | ^^^^^^^^^^^^^^^^^^^^^^^ 20 | 21 | Please see the notes in the code for more details. 22 | 23 | .. note-literalinclude:: ../../examples/stopwatch_example.py 24 | :language: python 25 | :caption: packages/optim_test_tools/examples/stopwatch_example.py 26 | :linenos: 27 | :lineno-match: 28 | 29 | Resulting Output 30 | ^^^^^^^^^^^^^^^^ 31 | 32 | Here, we show an example output for the last time that the stopwatch was used to print the results. Note 33 | that the actual result will vary depending on the actual runtime of the code parts. Note that for 34 | ``meas2`` and ``meas3``, the average runtime per iteration is different from the average runtime per measured 35 | interval. This is because these measurements were performed multiple times per iteration / only in some 36 | of the iterations, respectively. 37 | 38 | .. code-block:: text 39 | 40 | ######################### Stopwatch ######################### 41 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 42 | Num. measured iterations: 11 43 | . . . . . . . . . . . . . . . . . . . . . . . . . 44 | Average runtime per iteration: 45 | `meas1`: 0.16802375966852362 46 | `meas2`: 0.060098127885298294 47 | `meas3`: 0.0036563439802689986 48 | . . . . . . . . . . . . . . . . . . . . . . . . . 49 | Average runtime per measured interval: 50 | `meas1`: 0.16802375966852362 51 | `meas2`: 0.030049063942649147 52 | `meas3`: 0.010054945945739746 53 | . . . . . . . . . . . . . . . . . . . . . . . . . 54 | Total runtime: 55 | `meas1`: 1.8482613563537598 56 | `meas2`: 0.6610794067382812 57 | `meas3`: 0.040219783782958984 58 | . . . . . . . . . . . . . . . . . . . . . . . . . 59 | Mean CPU usage during `meas1`: 2.655618891226586 60 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 61 | One-time measurements: 62 | `complete_run`: 3.0058188438415527 63 | `preparation`: 0.10008645057678223 64 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 65 | ############################################################# 66 | 67 | Related examples 68 | ---------------- 69 | 70 | - See the :doc:`nvtx_range_wrapper` example for a similar singleton pattern applied to NVTX ranges. 71 | - The tensor dumper examples (:doc:`tensor_dumper_comparison` and :doc:`tensor_dumper_dumping`) also follow 72 | the singleton pattern and can be enabled once and used across multiple code parts. 73 | 74 | 75 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/tests/internal_helpers/mini_parser/lexer_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import pytest 16 | 17 | from accvlab.dali_pipeline_framework.internal_helpers.mini_parser import Lexer, TokenType, Token 18 | 19 | 20 | def test_lexer(): 21 | input_str = "res = d and not(a_b == -1.5 or -_b2 > 2 and (c < 3 or d > 4)) and c < 3" 22 | lexer = Lexer(input_str) 23 | tokens = [] 24 | expected_tokens = [ 25 | Token(TokenType.VARIABLE, "res"), 26 | Token(TokenType.ASSIGNMENT, "="), 27 | Token(TokenType.VARIABLE, "d"), 28 | Token(TokenType.LOGICAL_AND, "and"), 29 | Token(TokenType.LOGICAL_NOT, "not"), 30 | Token(TokenType.PARENTHESIS_OPEN, "("), 31 | Token(TokenType.VARIABLE, "a_b"), 32 | Token(TokenType.COMPARISON, "=="), 33 | Token(TokenType.MINUS, "-"), 34 | Token(TokenType.LITERAL, "1.5"), 35 | Token(TokenType.LOGICAL_OR, "or"), 36 | Token(TokenType.MINUS, "-"), 37 | Token(TokenType.VARIABLE, "_b2"), 38 | Token(TokenType.COMPARISON, ">"), 39 | Token(TokenType.LITERAL, "2"), 40 | Token(TokenType.LOGICAL_AND, "and"), 41 | Token(TokenType.PARENTHESIS_OPEN, "("), 42 | Token(TokenType.VARIABLE, "c"), 43 | Token(TokenType.COMPARISON, "<"), 44 | Token(TokenType.LITERAL, "3"), 45 | Token(TokenType.LOGICAL_OR, "or"), 46 | Token(TokenType.VARIABLE, "d"), 47 | Token(TokenType.COMPARISON, ">"), 48 | Token(TokenType.LITERAL, "4"), 49 | Token(TokenType.PARENTHESIS_CLOSE, ")"), 50 | Token(TokenType.PARENTHESIS_CLOSE, ")"), 51 | Token(TokenType.LOGICAL_AND, "and"), 52 | Token(TokenType.VARIABLE, "c"), 53 | Token(TokenType.COMPARISON, "<"), 54 | Token(TokenType.LITERAL, "3"), 55 | Token(TokenType.EOL, ""), 56 | ] 57 | 58 | for _ in range(len(expected_tokens)): 59 | token = lexer.next_token() 60 | tokens.append(token) 61 | 62 | for token, expected_token in zip(tokens, expected_tokens): 63 | assert token.type == expected_token.type 64 | assert token.value == expected_token.value 65 | 66 | 67 | if __name__ == "__main__": 68 | pytest.main([__file__]) 69 | -------------------------------------------------------------------------------- /packages/draw_heatmap/examples/input_data.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """ 16 | This file contains the input data for the draw_heatmap example. 17 | """ 18 | 19 | import torch 20 | 21 | device = "cuda:0" 22 | 23 | HEATMAP_SIZE = [100, 100] 24 | diameter_to_sigma_factor = 6 25 | k_scale = 1 26 | 27 | MAX_NUM_TARGET = 10 # max number of bounding boxes across a batch 28 | MAX_NUM_CLASSES = 20 # max number of classes in the dataset 29 | 30 | # The number of bounding boxes in across a batch is not the same 31 | # So put each sample into a list, each list element is a tensor of shape (num_boxes, 2) containing the center coordinates (x, y) of the bounding boxes 32 | # make sure the centers are in the range of the heatmap size 33 | 34 | # 4 samples in this batch 35 | centers_list = [ 36 | torch.tensor([[2, 3], [67, 50], [21, 10]], dtype=torch.int32, device=device), # 3 boxes in this sample 37 | torch.tensor([[4, 65], [54, 1]], dtype=torch.int32, device=device), # 2 boxes in this sample 38 | torch.tensor([[5, 76]], dtype=torch.int32, device=device), # 1 box in this sample 39 | torch.tensor([[76, 13]], dtype=torch.int32, device=device), # 1 box in this sample 40 | ] 41 | # The radius of the bounding boxes, each list element is a tensor of shape (num_boxes,) containing the radius of the gaussian corresponding to each bounding box 42 | # The length of the radii_list is the same as the centers_list 43 | # 4 samples in this batch 44 | radii_list = [ 45 | torch.tensor([4, 1, 5], dtype=torch.int32, device=device), 46 | torch.tensor([1, 10], dtype=torch.int32, device=device), 47 | torch.tensor([5], dtype=torch.int32, device=device), 48 | torch.tensor([9], dtype=torch.int32, device=device), 49 | ] 50 | 51 | # The labels of the bounding boxes, each list element is a tensor of shape (num_boxes,) containing the class index of the gaussian corresponding to each bounding box 52 | # The length of the labels_list is the same as the centers_list 53 | # 4 samples in this batch 54 | labels_list = [ 55 | torch.tensor([4, 10, 2], dtype=torch.int32, device=device), 56 | torch.tensor([3, 1], dtype=torch.int32, device=device), 57 | torch.tensor([0], dtype=torch.int32, device=device), 58 | torch.tensor([7], dtype=torch.int32, device=device), 59 | ] 60 | -------------------------------------------------------------------------------- /packages/batching_helpers/docs/introduction.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | The goal of the `batching-helpers` package is to enable an efficient and easy-to-use batching in case 5 | of non-uniform batch sizes in order to speed up loss computation on the GPU. To achieve this, the 6 | package defines a custom data type (:class:`~accvlab.batching_helpers.RaggedBatch`) and provides helper functions which 7 | enable/simplify batched operations on the data. 8 | In object detection and autonomous driving training tasks, a common challenge arises from non-uniform batch sizes. 9 | This occurs because: 10 | 11 | 1. The number of ground truth (GT) objects varies per sample 12 | 2. While the number of predictions is typically fixed, not all predictions correspond to actual objects (e.g. some predictions are background) 13 | 14 | This non-uniformity affects: 15 | 16 | - Ground truth data 17 | - Predictions used in loss computation (if e.g. only matched predictions are processed) 18 | - Correspondences between predictions and GT objects (e.g. index pairs linking predictions to GT objects) 19 | 20 | The `batching-helpers` package addresses these challenges through: 21 | 22 | 1. :class:`~accvlab.batching_helpers.RaggedBatch`: An efficient data format for storing and processing non-uniform batches 23 | 2. Specialized operations for common loss computation tasks that are difficult to implement efficiently with standard PyTorch operators in a batched manner 24 | 25 | A key example of a specialized operation is selecting matched objects from both ground truth data and predictions based on index pairs established by the matching 26 | algorithm. While PyTorch's built-in indexing works well for single-sample processing, batch processing with varying indices and numbers of indices per sample 27 | requires specialized handling. The package provides efficient helper functions for this and other common operations. 28 | 29 | Note that some specialized operations are GPU-only (denoted as such in the API documentation), while others support both CPU and GPU execution. 30 | As the goal of the package is to improve efficiency on the GPU through batching, many operations are implemented for the GPU only. 31 | However, for some of the operations, a CPU implementation is provided. This includes operations which are potentially more efficient on the CPU (e.g. due to processing 32 | of many small tensors, such as in the case of :func:`~accvlab.batching_helpers.combine_data`) or allow for more efficient CPU-GPU memory 33 | transfers (e.g. by first performing :func:`~accvlab.batching_helpers.combine_data` on CPU tensors, followed by a transfer of the batch as a whole onto the GPU). 34 | 35 | .. seealso:: 36 | 37 | Please refer to the :doc:`api` for details on the provided functionality and the :doc:`example` for a 38 | practical example and a short discussion about why using the approach implemented in this package leads to 39 | performance gains. 40 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/PyNvOnDemandDecoder/src/PyRGBFrame.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "../inc/PyRGBFrame.hpp" 18 | 19 | RGBFrame::RGBFrame(const std::vector& _shape, const std::vector& _stride, 20 | const std::string& _typeStr, size_t _streamid, CUdeviceptr _data, bool _readOnly, 21 | bool _isBRG) { 22 | assert(_shape.size() == 3 && _stride.size() == 3 && "_shape and _stride need to have size of 3"); 23 | assert(_shape[2] == 3 && "IMage has to have 3 chaneels, i.e. _shape[2] has to be 3"); 24 | shape = {_shape[0], _shape[1], 3}; 25 | stride = {_stride[0], _stride[1], _stride[2]}; 26 | typestr = _typeStr; 27 | data = _data; 28 | readOnly = _readOnly; 29 | stream = reinterpret_cast(_streamid); 30 | isBGR = isBGR; 31 | } 32 | 33 | RGBFrame::RGBFrame(const CAIMemoryView& to_convert, bool _isBRG) { 34 | assert(to_convert.shape.size() == 3 && to_convert.stride.size() == 3 && 35 | "CAIMemoryView need to have 3 dimensions to be converted to RGBFrame"); 36 | assert(to_convert.shape[2] == 3 && 37 | "CAIMemoryView need to have 3 channel (i.e. size of 3 in dimension 2)"); 38 | shape = {to_convert.shape[0], to_convert.shape[1], 3}; 39 | stride = {to_convert.stride[0], to_convert.stride[1], to_convert.stride[2]}; 40 | typestr = to_convert.typestr; 41 | data = to_convert.data; 42 | readOnly = to_convert.readOnly; 43 | stream = to_convert.stream; 44 | isBGR = isBGR; 45 | } 46 | 47 | RGBFrame::RGBFrame() { 48 | shape = {0, 0, 0}; 49 | stride = {1, 1, 1}; 50 | typestr = "|u1"; 51 | data = reinterpret_cast(nullptr); 52 | readOnly = true; 53 | // RS TODO: Is "2" correct? It is the same as used in CAIMemoryView and 54 | // coerceToCudaArrayView, but why 2? 55 | stream = (CUstream)2; 56 | isBGR = false; 57 | } 58 | 59 | void RGBFrame::release_data() { 60 | CUDA_DRVAPI_CALL(cuMemFree(data)); 61 | data = reinterpret_cast(nullptr); 62 | } 63 | 64 | bool RGBFrame::is_of_size(size_t height, size_t width) { 65 | const bool shape_correct = (height == std::get<0>(shape)) && (width == std::get<1>(shape)); 66 | return shape_correct; 67 | } -------------------------------------------------------------------------------- /packages/batching_helpers/accvlab/batching_helpers/batched_mask_from_indices.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch 16 | from accvlab.batching_helpers.batched_processing_py import RaggedBatch 17 | import accvlab.batching_helpers.batched_indexing_access_cuda as batched_indexing_access_cuda 18 | 19 | 20 | def get_mask_from_indices(mask_num_targets: int, indices: RaggedBatch) -> torch.Tensor: 21 | """Get a mask from indices, where the indices indicate which elements in the mask should be ``True``. 22 | 23 | :gpu: 24 | 25 | The indices for each sample define the ``True`` values in the mask for that sample 26 | (i.e. the corresponding row in the mask). 27 | 28 | For each sample ``i``, the operation performed by this function is equivalent to: 29 | ``mask[i, indices.tensor[i, :indices.sample_sizes[i]]] = True`` 30 | 31 | Please also see the documentation of :class:`RaggedBatch` for more details on the format of the indices, 32 | including the ``tensor`` and ``sample_sizes`` attributes. 33 | 34 | Note: 35 | 36 | This function is not the inverse of :func:`get_indices_from_mask`, as the index order is not 37 | preserved when converting from indices to a mask. 38 | 39 | Args: 40 | mask_num_targets: The number of targets in the mask, i.e. the ``mask.shape[1]`` to use 41 | indices: For each sample (element along the batch dimension), the indices of elements to set to ``True``. 42 | Shape: (batch_size, max_num_indices) 43 | 44 | Returns: 45 | Resulting mask. Shape: (batch_size, ``num_targets_in_mask``) 46 | 47 | Example: 48 | 49 | In the illustration below, '*' indicates invalid indices, i.e. padding to make the tensor uniform for 50 | samples where the number of indices is smaller than ``max_num_indices``. Note that the index order 51 | does not matter for the resulting mask. 52 | 53 | .. image:: images/MaskFromIndices_ragged.png 54 | :alt: Illustration of the mask from indices operation 55 | :align: center 56 | 57 | """ 58 | data = indices.tensor.contiguous() 59 | sample_sizes = indices.sample_sizes.contiguous() 60 | res = batched_indexing_access_cuda.get_mask_from_indices(data, sample_sizes, mask_num_targets) 61 | return res 62 | -------------------------------------------------------------------------------- /packages/draw_heatmap/examples/draw_heatmap_batched_classwise.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import torch 16 | from accvlab.draw_heatmap import draw_heatmap_batched 17 | from input_data import ( 18 | device, 19 | centers_list, 20 | radii_list, 21 | labels_list, 22 | HEATMAP_SIZE, 23 | diameter_to_sigma_factor, 24 | k_scale, 25 | MAX_NUM_TARGET, 26 | MAX_NUM_CLASSES, 27 | ) 28 | from accvlab.batching_helpers import RaggedBatch 29 | 30 | 31 | def draw_heatmap_classwise_example_batch(): 32 | """ 33 | This example shows how to draw class-wise heatmaps for batched inputs. 34 | 35 | Args: 36 | centers_list: List[torch.Tensor] 37 | radii_list: List[torch.Tensor] 38 | labels_list: List[torch.Tensor] 39 | HEATMAP_SIZE: [H, W] 40 | diameter_to_sigma_factor: float 41 | k_scale: float 42 | """ 43 | batch_size = len(centers_list) 44 | 45 | # In order to support the batched input, we need to convert the input to the format of ragged batch 46 | centers = torch.zeros((batch_size, MAX_NUM_TARGET, 2), dtype=torch.int32, device=device) 47 | radii = torch.zeros((batch_size, MAX_NUM_TARGET), dtype=torch.int32, device=device) 48 | labels = torch.zeros((batch_size, MAX_NUM_TARGET), dtype=torch.int32, device=device) 49 | gt_nums_targets = torch.zeros((batch_size,), dtype=torch.int32, device=device) 50 | # Copy over the valid boxes 51 | for i, sublist in enumerate(centers_list): 52 | centers[i, : len(sublist)] = centers_list[i] 53 | radii[i, : len(sublist)] = radii_list[i] 54 | labels[i, : len(sublist)] = labels_list[i] 55 | gt_nums_targets[i] = len(sublist) 56 | 57 | centers_rb = RaggedBatch(centers, sample_sizes=gt_nums_targets) 58 | radii_rb = RaggedBatch(radii, sample_sizes=gt_nums_targets) 59 | labels_rb = RaggedBatch(labels, sample_sizes=gt_nums_targets) 60 | heatmaps = torch.zeros( 61 | (batch_size, MAX_NUM_CLASSES, HEATMAP_SIZE[0], HEATMAP_SIZE[1]), dtype=torch.float32, device=device 62 | ) 63 | draw_heatmap_batched(heatmaps, centers_rb, radii_rb, diameter_to_sigma_factor, k_scale, labels=labels_rb) 64 | return heatmaps 65 | 66 | 67 | if __name__ == "__main__": 68 | heatmaps = draw_heatmap_classwise_example_batch() 69 | print(heatmaps.shape) 70 | -------------------------------------------------------------------------------- /packages/on_demand_video_decoder/ext_impl/src/PyNvOnDemandDecoder/src/GPUMemoryPool.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "GPUMemoryPool.hpp" 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include "NvCodecUtils.h" 25 | 26 | static void cuda_err_check() { 27 | const cudaError last_error = cudaGetLastError(); 28 | if (last_error != cudaError::cudaSuccess) { 29 | throw std::runtime_error("Cuda error encountered; Error code: " + std::to_string(last_error)); 30 | } 31 | } 32 | 33 | GPUMemoryPool::GPUMemoryPool(size_t num_bytes_to_store) { EnsureSizeAndSoftReset(num_bytes_to_store, false); } 34 | 35 | void* GPUMemoryPool::AddElement(size_t num_bytes) { 36 | const size_t size_needed = curr_size_ + num_bytes; 37 | if (size_needed > allocated_size_) { 38 | throw std::out_of_range( 39 | "Memory pool does not have enough allocated " 40 | "memory. Allow re-allocating when calling this " 41 | "method or pre-allocate enough memory."); 42 | } 43 | uint8_t* pointer_to_new_element = data_ + curr_size_; 44 | curr_size_ += num_bytes; 45 | return static_cast(pointer_to_new_element); 46 | } 47 | 48 | void GPUMemoryPool::EnsureSizeAndSoftReset(size_t num_bytes_to_store, bool shrink_if_smaller) { 49 | const bool curr_too_small = curr_size_ < num_bytes_to_store; 50 | if (curr_too_small || shrink_if_smaller) { 51 | if (data_ != nullptr) { 52 | cuMemFree(reinterpret_cast(data_)); 53 | cuda_err_check(); 54 | } 55 | CUDA_DRVAPI_CALL(cuMemAlloc(reinterpret_cast(&data_), num_bytes_to_store)); 56 | cuda_err_check(); 57 | 58 | allocated_size_ = num_bytes_to_store; 59 | } 60 | curr_size_ = 0; 61 | } 62 | 63 | void GPUMemoryPool::SoftRelease() { curr_size_ = 0; } 64 | 65 | void GPUMemoryPool::HardRelease() { 66 | // Only free if memory was actually allocated 67 | // cuMemFree(0) is undefined behavior, unlike free(NULL) in C 68 | if (data_ != nullptr) { 69 | cuMemFree(reinterpret_cast(data_)); 70 | } 71 | data_ = nullptr; 72 | curr_size_ = 0; 73 | allocated_size_ = 0; 74 | } 75 | 76 | GPUMemoryPool::~GPUMemoryPool() { HardRelease(); } 77 | -------------------------------------------------------------------------------- /packages/example_package/ext_impl/build_and_copy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -euo pipefail 18 | 19 | echo "Building external CUDA implementation for example_package..." 20 | 21 | # Get the directory of this script 22 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 23 | cd "$SCRIPT_DIR" 24 | 25 | # Set up build directory 26 | BUILD_DIR="build" 27 | rm -rf "$BUILD_DIR" 28 | mkdir -p "$BUILD_DIR" 29 | cd "$BUILD_DIR" 30 | 31 | # Get PyTorch cmake config path 32 | TORCH_CMAKE_PREFIX_PATH=$(python -c "import torch; print(torch.utils.cmake_prefix_path)") 33 | 34 | echo "Computing CMake arguments from environment..." 35 | # Ensure helper is available; instruct user if not installed 36 | if ! python - <<'PY' 37 | from accvlab_build_config.helpers.cmake_args import build_cmake_args_from_env # noqa: F401 38 | PY 39 | then 40 | echo "Error: Python package 'accvlab_build_config' not found." >&2 41 | echo "Please install it first, e.g.:" >&2 42 | echo " pip install -e build_config # from repo root" >&2 43 | exit 1 44 | fi 45 | # Read helper-produced cmake -D args into array 46 | readarray -t CMAKE_ARGS < <(python -c "from accvlab_build_config.helpers.cmake_args import build_cmake_args_from_env; print('\n'.join(build_cmake_args_from_env()))") 47 | 48 | # Configure CMake 49 | echo "Configuring CMake..." 50 | cmake .. \ 51 | -DCMAKE_PREFIX_PATH="$TORCH_CMAKE_PREFIX_PATH" \ 52 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ 53 | "${CMAKE_ARGS[@]}" 54 | 55 | # Build the library 56 | echo "Building library..." 57 | make -j$(nproc) 58 | 59 | # Find the built library (Python module) - pybind11 creates files with platform-specific names 60 | LIB_FILE=$(find . -name "accvlab_example_package_ext*.so" | head -1) 61 | if [ ! -f "$LIB_FILE" ]; then 62 | echo "Error: Could not find built library accvlab_example_package_ext*.so" 63 | echo "Available files:" 64 | ls -la 65 | exit 1 66 | fi 67 | 68 | # Create destination directory 69 | DEST_DIR="../../accvlab/example_package" 70 | mkdir -p "$DEST_DIR" 71 | 72 | # Copy the library to the examples package with the correct Python module name 73 | echo "Copying library to example_package package..." 74 | cp "$LIB_FILE" "$DEST_DIR/" 75 | 76 | echo "External build completed successfully!" 77 | echo "Library copied to: $DEST_DIR/$(basename "$LIB_FILE")" -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/accvlab/dali_pipeline_framework/processing_steps/data_group_array_in_path_elements_applied_step.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Used to enable type hints using a class type inside the implementation of that class itself. 16 | from __future__ import annotations 17 | 18 | from typing import Union, Sequence 19 | 20 | try: 21 | from typing import override 22 | except ImportError: 23 | from typing_extensions import override 24 | 25 | from ..pipeline.sample_data_group import SampleDataGroup 26 | 27 | from .data_group_in_path_applied_step import DataGroupInPathAppliedStep 28 | from .pipeline_step_base import PipelineStepBase 29 | 30 | 31 | class DataGroupArrayInPathElementsAppliedStep(DataGroupInPathAppliedStep): 32 | '''Apply a contained processing step independently to each element of an array data group field at a path. 33 | 34 | The path of the array data group field is defined at construction. Each element of that array is processed 35 | independently by the contained step. 36 | ''' 37 | 38 | def __init__( 39 | self, 40 | processing_step_to_apply: PipelineStepBase, 41 | path_to_array_to_apply_to: Union[str, int, Sequence[str, int]], 42 | ): 43 | ''' 44 | 45 | Args: 46 | processing_step_to_apply: Contained processing step to apply. 47 | path_to_array_to_apply_to: Path to the array data group field whose children should be processed. 48 | 49 | ''' 50 | DataGroupInPathAppliedStep.__init__(self, processing_step_to_apply, path_to_array_to_apply_to) 51 | 52 | @override 53 | def _check_and_get_paths_to_apply_to(self, data: SampleDataGroup) -> Sequence[Sequence[str, int]]: 54 | 55 | array_paths = DataGroupInPathAppliedStep._check_and_get_paths_to_apply_to(self, data) 56 | array_element_paths = [] 57 | for ap in array_paths: 58 | array_field = data.get_item_in_path(ap) 59 | if not array_field.is_data_group_field_array(): 60 | raise ValueError( 61 | f"DataGroupArraysWithNameElementsAppliedStep: item in path `{ap}` is not a data group field array." 62 | ) 63 | for i in range(len(array_field)): 64 | path_to_element = ap + (i,) 65 | array_element_paths.append(path_to_element) 66 | return array_element_paths 67 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/docs/evaluation.rst: -------------------------------------------------------------------------------- 1 | Evaluation 2 | ========== 3 | 4 | This page summarizes the performance impact of using the DALI Pipeline Framework 5 | as a replacement for a conventional PyTorch ``Dataset`` + ``DataLoader`` when training 6 | StreamPETR on NuScenes mini. 7 | 8 | Experiment Setup 9 | ---------------- 10 | 11 | Configuration 12 | ~~~~~~~~~~~~~ 13 | 14 | The training is performed for the NuScenes mini dataset, using the StreamPETR model. In order to evaluate 15 | a realistic setup with a high pre-processing overhead, we increase both the image resolution and the batch 16 | size compared to the original configuration. We use the following configuration: 17 | 18 | - Image size: 1024 × 372 19 | - Batch size: 8 per GPU 20 | 21 | Data 22 | ~~~~ 23 | 24 | - NuScenes mini 25 | - For the multi‑GPU training, each GPU re‑uses the whole dataset instead of sharding 26 | (NuScenes mini is otherwise too small) 27 | 28 | Adaptation to DALI 29 | ~~~~~~~~~~~~~~~~~~ 30 | 31 | - Replace the PyTorch ``DataLoader`` by a DALI pipeline 32 | - Code changes are limited to the pipeline setup vs. PyTorch ``Dataset`` and ``DataLoader`` 33 | - The training loop implementation remains unchanged 34 | 35 | .. note:: 36 | 37 | We are planning to add a demo for the DALI Pipeline Framework package in the future, including the 38 | implementation of the experiments performed in this evaluation. 39 | 40 | Hardware Setup 41 | ~~~~~~~~~~~~~~ 42 | 43 | .. list-table:: Test Device 44 | :header-rows: 1 45 | 46 | * - GPU 47 | - CPU 48 | * - 8 × NVIDIA A100‑SXM4‑80GB 49 | - 2 × AMD EPYC 7742 64‑Core Processors 50 | 51 | Results & Discussion 52 | -------------------- 53 | 54 | Results 55 | ~~~~~~~~ 56 | 57 | The numbers report average run time per batch after the warm‑up phase. 58 | 59 | .. list-table:: Runtime and CPU Usage 60 | :header-rows: 1 61 | 62 | * - Method 63 | - Runtime [ms] (2‑GPU) 64 | - CPU usage [%] (2‑GPU) 65 | - Runtime [ms] (8‑GPU) 66 | - CPU usage [%] (8‑GPU) 67 | * - **Reference (PyTorch DataLoader)** 68 | - 935 69 | - 3.3 70 | - 1110 71 | - 12.3 72 | * - **DALI pipeline** 73 | - 829 74 | - 1.5 75 | - 868 76 | - 5.4 77 | * - **Speedup / Savings** 78 | - × 1.13 79 | - 55% 80 | - × 1.28 81 | - 56% 82 | 83 | Discussion 84 | ~~~~~~~~~~ 85 | 86 | The results show that the DALI pipeline framework leads to a speedup of **× 1.13** for the 2-GPU configuration 87 | and **× 1.28** for the 8-GPU configuration, with the speedup being larger for the 8-GPU configuration. 88 | The CPU usage is reduced by around **55%** in both configurations. Note that for both DALI And the reference 89 | implementation, the runtime increases for the 8-GPU configuration compared to the 2-GPU configuration. 90 | However, the increase is much smaller for the DALI pipeline, indicating that while the CPU is not fully 91 | utilized in the reference approach, there are already bottlenecks present which can be overcome by the DALI 92 | pipeline. 93 | 94 | -------------------------------------------------------------------------------- /packages/dali_pipeline_framework/tests/inputs/_test_helpers.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from nvidia.dali import types as dali_types 16 | 17 | from accvlab.dali_pipeline_framework.pipeline import ( 18 | PipelineDefinition, 19 | DALIStructuredOutputIterator, 20 | SampleDataGroup, 21 | ) 22 | from accvlab.dali_pipeline_framework.inputs import DataProvider 23 | 24 | try: 25 | from typing import override 26 | except ImportError: 27 | from typing_extensions import override 28 | 29 | 30 | def build_pipeline_and_iterator(input_obj, batch_size: int, num_batches: int): 31 | pipeline_def = PipelineDefinition(data_loading_callable_iterable=input_obj, preprocess_functors=[]) 32 | pipe = pipeline_def.get_dali_pipeline( 33 | enable_conditionals=True, 34 | batch_size=batch_size, 35 | prefetch_queue_depth=1, 36 | num_threads=1, 37 | py_start_method="spawn", 38 | ) 39 | iterator = DALIStructuredOutputIterator( 40 | num_batches, pipe, pipeline_def.check_and_get_output_data_structure() 41 | ) 42 | return pipeline_def, pipe, iterator 43 | 44 | 45 | def next_ids(iterator_iter): 46 | out = next(iterator_iter) 47 | return out["id"].tolist() 48 | 49 | 50 | class SimpleDataProvider(DataProvider): 51 | def __init__(self): 52 | # Blueprint with a single INT32 field 'id' and some additional (constant) fields 53 | self._blueprint = SampleDataGroup() 54 | self._blueprint.add_data_field("id", dali_types.DALIDataType.INT32) 55 | additional = SampleDataGroup() 56 | additional.add_data_field("some_data", dali_types.DALIDataType.INT32) 57 | additional.add_data_field("some_other_data", dali_types.DALIDataType.FLOAT) 58 | self._blueprint.add_data_group_field("additional", additional) 59 | 60 | @override 61 | def get_data(self, sample_id: int) -> SampleDataGroup: 62 | s = self.sample_data_structure 63 | s["id"] = int(sample_id) 64 | s["additional"]["some_data"] = [1, 2, 3] 65 | s["additional"]["some_other_data"] = [4.0, 5.0, 6.0] 66 | return s 67 | 68 | @override 69 | def get_number_of_samples(self) -> int: 70 | return 10000 71 | 72 | @property 73 | @override 74 | def sample_data_structure(self) -> SampleDataGroup: 75 | # Return an empty-like blueprint each time to avoid sharing state 76 | return self._blueprint.get_empty_like_self() 77 | --------------------------------------------------------------------------------