From 96faf8ce60d4427b721bc7a0abad99ee34eaa6cd Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 1 Apr 2025 16:42:26 +0100 Subject: [PATCH 1/7] Move src/torchcodec/decoders/_core/ into src/torchcodec/ --- src/torchcodec/{decoders => }/_core/AVIOBytesContext.cpp | 0 src/torchcodec/{decoders => }/_core/AVIOBytesContext.h | 0 src/torchcodec/{decoders => }/_core/AVIOContextHolder.cpp | 0 src/torchcodec/{decoders => }/_core/AVIOContextHolder.h | 0 src/torchcodec/{decoders => }/_core/AVIOFileLikeContext.cpp | 0 src/torchcodec/{decoders => }/_core/AVIOFileLikeContext.h | 0 src/torchcodec/{decoders => }/_core/CMakeLists.txt | 0 src/torchcodec/{decoders => }/_core/CPUOnlyDevice.cpp | 0 src/torchcodec/{decoders => }/_core/CudaDevice.cpp | 0 src/torchcodec/{decoders => }/_core/DeviceInterface.h | 0 src/torchcodec/{decoders => }/_core/FFMPEGCommon.cpp | 0 src/torchcodec/{decoders => }/_core/FFMPEGCommon.h | 0 src/torchcodec/{decoders => }/_core/VideoDecoder.cpp | 0 src/torchcodec/{decoders => }/_core/VideoDecoder.h | 0 src/torchcodec/{decoders => }/_core/__init__.py | 0 src/torchcodec/{decoders => }/_core/_metadata.py | 0 src/torchcodec/{decoders => }/_core/custom_ops.cpp | 0 .../_core/fetch_and_expose_non_gpl_ffmpeg_libs.cmake | 0 src/torchcodec/{decoders => }/_core/ops.py | 0 src/torchcodec/{decoders => }/_core/pybind_ops.cpp | 0 20 files changed, 0 insertions(+), 0 deletions(-) rename src/torchcodec/{decoders => }/_core/AVIOBytesContext.cpp (100%) rename src/torchcodec/{decoders => }/_core/AVIOBytesContext.h (100%) rename src/torchcodec/{decoders => }/_core/AVIOContextHolder.cpp (100%) rename src/torchcodec/{decoders => }/_core/AVIOContextHolder.h (100%) rename src/torchcodec/{decoders => }/_core/AVIOFileLikeContext.cpp (100%) rename src/torchcodec/{decoders => }/_core/AVIOFileLikeContext.h (100%) rename src/torchcodec/{decoders => }/_core/CMakeLists.txt (100%) rename src/torchcodec/{decoders => }/_core/CPUOnlyDevice.cpp (100%) rename src/torchcodec/{decoders => }/_core/CudaDevice.cpp (100%) rename src/torchcodec/{decoders => }/_core/DeviceInterface.h (100%) rename src/torchcodec/{decoders => }/_core/FFMPEGCommon.cpp (100%) rename src/torchcodec/{decoders => }/_core/FFMPEGCommon.h (100%) rename src/torchcodec/{decoders => }/_core/VideoDecoder.cpp (100%) rename src/torchcodec/{decoders => }/_core/VideoDecoder.h (100%) rename src/torchcodec/{decoders => }/_core/__init__.py (100%) rename src/torchcodec/{decoders => }/_core/_metadata.py (100%) rename src/torchcodec/{decoders => }/_core/custom_ops.cpp (100%) rename src/torchcodec/{decoders => }/_core/fetch_and_expose_non_gpl_ffmpeg_libs.cmake (100%) rename src/torchcodec/{decoders => }/_core/ops.py (100%) rename src/torchcodec/{decoders => }/_core/pybind_ops.cpp (100%) diff --git a/src/torchcodec/decoders/_core/AVIOBytesContext.cpp b/src/torchcodec/_core/AVIOBytesContext.cpp similarity index 100% rename from src/torchcodec/decoders/_core/AVIOBytesContext.cpp rename to src/torchcodec/_core/AVIOBytesContext.cpp diff --git a/src/torchcodec/decoders/_core/AVIOBytesContext.h b/src/torchcodec/_core/AVIOBytesContext.h similarity index 100% rename from src/torchcodec/decoders/_core/AVIOBytesContext.h rename to src/torchcodec/_core/AVIOBytesContext.h diff --git a/src/torchcodec/decoders/_core/AVIOContextHolder.cpp b/src/torchcodec/_core/AVIOContextHolder.cpp similarity index 100% rename from src/torchcodec/decoders/_core/AVIOContextHolder.cpp rename to src/torchcodec/_core/AVIOContextHolder.cpp diff --git a/src/torchcodec/decoders/_core/AVIOContextHolder.h b/src/torchcodec/_core/AVIOContextHolder.h similarity index 100% rename from src/torchcodec/decoders/_core/AVIOContextHolder.h rename to src/torchcodec/_core/AVIOContextHolder.h diff --git a/src/torchcodec/decoders/_core/AVIOFileLikeContext.cpp b/src/torchcodec/_core/AVIOFileLikeContext.cpp similarity index 100% rename from src/torchcodec/decoders/_core/AVIOFileLikeContext.cpp rename to src/torchcodec/_core/AVIOFileLikeContext.cpp diff --git a/src/torchcodec/decoders/_core/AVIOFileLikeContext.h b/src/torchcodec/_core/AVIOFileLikeContext.h similarity index 100% rename from src/torchcodec/decoders/_core/AVIOFileLikeContext.h rename to src/torchcodec/_core/AVIOFileLikeContext.h diff --git a/src/torchcodec/decoders/_core/CMakeLists.txt b/src/torchcodec/_core/CMakeLists.txt similarity index 100% rename from src/torchcodec/decoders/_core/CMakeLists.txt rename to src/torchcodec/_core/CMakeLists.txt diff --git a/src/torchcodec/decoders/_core/CPUOnlyDevice.cpp b/src/torchcodec/_core/CPUOnlyDevice.cpp similarity index 100% rename from src/torchcodec/decoders/_core/CPUOnlyDevice.cpp rename to src/torchcodec/_core/CPUOnlyDevice.cpp diff --git a/src/torchcodec/decoders/_core/CudaDevice.cpp b/src/torchcodec/_core/CudaDevice.cpp similarity index 100% rename from src/torchcodec/decoders/_core/CudaDevice.cpp rename to src/torchcodec/_core/CudaDevice.cpp diff --git a/src/torchcodec/decoders/_core/DeviceInterface.h b/src/torchcodec/_core/DeviceInterface.h similarity index 100% rename from src/torchcodec/decoders/_core/DeviceInterface.h rename to src/torchcodec/_core/DeviceInterface.h diff --git a/src/torchcodec/decoders/_core/FFMPEGCommon.cpp b/src/torchcodec/_core/FFMPEGCommon.cpp similarity index 100% rename from src/torchcodec/decoders/_core/FFMPEGCommon.cpp rename to src/torchcodec/_core/FFMPEGCommon.cpp diff --git a/src/torchcodec/decoders/_core/FFMPEGCommon.h b/src/torchcodec/_core/FFMPEGCommon.h similarity index 100% rename from src/torchcodec/decoders/_core/FFMPEGCommon.h rename to src/torchcodec/_core/FFMPEGCommon.h diff --git a/src/torchcodec/decoders/_core/VideoDecoder.cpp b/src/torchcodec/_core/VideoDecoder.cpp similarity index 100% rename from src/torchcodec/decoders/_core/VideoDecoder.cpp rename to src/torchcodec/_core/VideoDecoder.cpp diff --git a/src/torchcodec/decoders/_core/VideoDecoder.h b/src/torchcodec/_core/VideoDecoder.h similarity index 100% rename from src/torchcodec/decoders/_core/VideoDecoder.h rename to src/torchcodec/_core/VideoDecoder.h diff --git a/src/torchcodec/decoders/_core/__init__.py b/src/torchcodec/_core/__init__.py similarity index 100% rename from src/torchcodec/decoders/_core/__init__.py rename to src/torchcodec/_core/__init__.py diff --git a/src/torchcodec/decoders/_core/_metadata.py b/src/torchcodec/_core/_metadata.py similarity index 100% rename from src/torchcodec/decoders/_core/_metadata.py rename to src/torchcodec/_core/_metadata.py diff --git a/src/torchcodec/decoders/_core/custom_ops.cpp b/src/torchcodec/_core/custom_ops.cpp similarity index 100% rename from src/torchcodec/decoders/_core/custom_ops.cpp rename to src/torchcodec/_core/custom_ops.cpp diff --git a/src/torchcodec/decoders/_core/fetch_and_expose_non_gpl_ffmpeg_libs.cmake b/src/torchcodec/_core/fetch_and_expose_non_gpl_ffmpeg_libs.cmake similarity index 100% rename from src/torchcodec/decoders/_core/fetch_and_expose_non_gpl_ffmpeg_libs.cmake rename to src/torchcodec/_core/fetch_and_expose_non_gpl_ffmpeg_libs.cmake diff --git a/src/torchcodec/decoders/_core/ops.py b/src/torchcodec/_core/ops.py similarity index 100% rename from src/torchcodec/decoders/_core/ops.py rename to src/torchcodec/_core/ops.py diff --git a/src/torchcodec/decoders/_core/pybind_ops.cpp b/src/torchcodec/_core/pybind_ops.cpp similarity index 100% rename from src/torchcodec/decoders/_core/pybind_ops.cpp rename to src/torchcodec/_core/pybind_ops.cpp From 31e806e9d2569ed99617889d0284e804571b7b81 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 1 Apr 2025 16:44:40 +0100 Subject: [PATCH 2/7] src/torchcodec/_core/_metadata.py -> src/torchcodec/decoders/_metadata.py --- src/torchcodec/{_core => decoders}/_metadata.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/torchcodec/{_core => decoders}/_metadata.py (100%) diff --git a/src/torchcodec/_core/_metadata.py b/src/torchcodec/decoders/_metadata.py similarity index 100% rename from src/torchcodec/_core/_metadata.py rename to src/torchcodec/decoders/_metadata.py From 0eb2be90a80e65d2c1dde02a9143d373d894a3c0 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 1 Apr 2025 16:46:37 +0100 Subject: [PATCH 3/7] find . -type f | xargs sed -i "s/torchcodec\.decoders\._core/torchcodec._core/g" --- benchmarks/decoders/benchmark_decoders_library.py | 2 +- benchmarks/decoders/gpu_benchmark.py | 6 +++--- benchmarks/decoders/memprofile_decoders.py | 2 +- src/torchcodec/_core/custom_ops.cpp | 2 +- src/torchcodec/_samplers/video_clip_sampler.py | 2 +- src/torchcodec/decoders/_metadata.py | 2 +- test/decoders/manual_smoke_test.py | 8 ++++---- test/decoders/test_decoders.py | 2 +- test/decoders/test_metadata.py | 2 +- test/decoders/test_ops.py | 2 +- test/utils.py | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/benchmarks/decoders/benchmark_decoders_library.py b/benchmarks/decoders/benchmark_decoders_library.py index b0b69dfd..27145deb 100644 --- a/benchmarks/decoders/benchmark_decoders_library.py +++ b/benchmarks/decoders/benchmark_decoders_library.py @@ -15,7 +15,7 @@ import torch.utils.benchmark as benchmark from torchcodec.decoders import VideoDecoder, VideoStreamMetadata -from torchcodec.decoders._core import ( +from torchcodec._core import ( _add_video_stream, create_from_file, get_frames_at_indices, diff --git a/benchmarks/decoders/gpu_benchmark.py b/benchmarks/decoders/gpu_benchmark.py index e5edc6fb..a2269188 100644 --- a/benchmarks/decoders/gpu_benchmark.py +++ b/benchmarks/decoders/gpu_benchmark.py @@ -25,7 +25,7 @@ def decode_full_video(video_path, decode_device_string, resize_device_string): # We use the core API instead of SimpleVideoDecoder because the core API # allows us to natively resize as part of the decode step. print(f"{decode_device_string=} {resize_device_string=}") - decoder = torchcodec.decoders._core.create_from_file(video_path) + decoder = torchcodec._core.create_from_file(video_path) num_threads = None if "cuda" in decode_device_string: num_threads = 1 @@ -34,7 +34,7 @@ def decode_full_video(video_path, decode_device_string, resize_device_string): if "native" in resize_device_string: width = RESIZED_WIDTH height = RESIZED_HEIGHT - torchcodec.decoders._core._add_video_stream( + torchcodec._core._add_video_stream( decoder, stream_index=-1, device=decode_device_string, @@ -47,7 +47,7 @@ def decode_full_video(video_path, decode_device_string, resize_device_string): frame_count = 0 while True: try: - frame, *_ = torchcodec.decoders._core.get_next_frame(decoder) + frame, *_ = torchcodec._core.get_next_frame(decoder) if resize_device_string != "none" and "native" not in resize_device_string: frame = transfer_and_resize_frame(frame, resize_device_string) diff --git a/benchmarks/decoders/memprofile_decoders.py b/benchmarks/decoders/memprofile_decoders.py index ac59ed9a..16bc42dc 100644 --- a/benchmarks/decoders/memprofile_decoders.py +++ b/benchmarks/decoders/memprofile_decoders.py @@ -9,7 +9,7 @@ import torch from memory_profiler import profile -from torchcodec.decoders._core import add_video_stream, create_from_file, get_next_frame +from torchcodec._core import add_video_stream, create_from_file, get_next_frame torch._dynamo.config.cache_size_limit = 100 torch._dynamo.config.capture_dynamic_output_shape_ops = True diff --git a/src/torchcodec/_core/custom_ops.cpp b/src/torchcodec/_core/custom_ops.cpp index c0689937..c56755d2 100644 --- a/src/torchcodec/_core/custom_ops.cpp +++ b/src/torchcodec/_core/custom_ops.cpp @@ -25,7 +25,7 @@ namespace facebook::torchcodec { // https://github.com/pytorch/pytorch/tree/main/aten/src/ATen/native#readme TORCH_LIBRARY(torchcodec_ns, m) { m.impl_abstract_pystub( - "torchcodec.decoders._core.ops", "//pytorch/torchcodec:torchcodec"); + "torchcodec._core.ops", "//pytorch/torchcodec:torchcodec"); m.def("create_from_file(str filename, str? seek_mode=None) -> Tensor"); m.def( "create_from_tensor(Tensor video_tensor, str? seek_mode=None) -> Tensor"); diff --git a/src/torchcodec/_samplers/video_clip_sampler.py b/src/torchcodec/_samplers/video_clip_sampler.py index 7f3521d1..8a92400f 100644 --- a/src/torchcodec/_samplers/video_clip_sampler.py +++ b/src/torchcodec/_samplers/video_clip_sampler.py @@ -13,7 +13,7 @@ import torch from torch import nn, Tensor -from torchcodec.decoders._core import ( +from torchcodec._core import ( add_video_stream, create_from_tensor, get_frames_at_indices, diff --git a/src/torchcodec/decoders/_metadata.py b/src/torchcodec/decoders/_metadata.py index 44f91bfb..93c4448c 100644 --- a/src/torchcodec/decoders/_metadata.py +++ b/src/torchcodec/decoders/_metadata.py @@ -12,7 +12,7 @@ import torch -from torchcodec.decoders._core.ops import ( +from torchcodec._core.ops import ( _get_container_json_metadata, _get_stream_json_metadata, create_from_file, diff --git a/test/decoders/manual_smoke_test.py b/test/decoders/manual_smoke_test.py index 16344ec5..53701520 100644 --- a/test/decoders/manual_smoke_test.py +++ b/test/decoders/manual_smoke_test.py @@ -11,10 +11,10 @@ print(f"{torchcodec.__version__ = }") -decoder = torchcodec.decoders._core.create_from_file( +decoder = torchcodec._core.create_from_file( str(Path(__file__).parent / "../resources/nasa_13013.mp4") ) -torchcodec.decoders._core.scan_all_streams_to_update_metadata(decoder) -torchcodec.decoders._core.add_video_stream(decoder, stream_index=3) -frame, _, _ = torchcodec.decoders._core.get_frame_at_index(decoder, frame_index=180) +torchcodec._core.scan_all_streams_to_update_metadata(decoder) +torchcodec._core.add_video_stream(decoder, stream_index=3) +frame, _, _ = torchcodec._core.get_frame_at_index(decoder, frame_index=180) write_png(frame, "frame180.png") diff --git a/test/decoders/test_decoders.py b/test/decoders/test_decoders.py index cc47e116..f97fc3fa 100644 --- a/test/decoders/test_decoders.py +++ b/test/decoders/test_decoders.py @@ -13,7 +13,7 @@ from torchcodec.decoders import _core, VideoDecoder, VideoStreamMetadata from torchcodec.decoders._audio_decoder import AudioDecoder -from torchcodec.decoders._core._metadata import AudioStreamMetadata +from torchcodec._core._metadata import AudioStreamMetadata from ..utils import ( assert_frames_equal, diff --git a/test/decoders/test_metadata.py b/test/decoders/test_metadata.py index e4e64d6b..c5a772f4 100644 --- a/test/decoders/test_metadata.py +++ b/test/decoders/test_metadata.py @@ -9,7 +9,7 @@ import pytest from torchcodec.decoders import AudioDecoder, VideoDecoder -from torchcodec.decoders._core import ( +from torchcodec._core import ( AudioStreamMetadata, create_from_file, get_container_metadata, diff --git a/test/decoders/test_ops.py b/test/decoders/test_ops.py index 9efb33f3..643b7e14 100644 --- a/test/decoders/test_ops.py +++ b/test/decoders/test_ops.py @@ -16,7 +16,7 @@ import torch -from torchcodec.decoders._core import ( +from torchcodec._core import ( _add_video_stream, _test_frame_pts_equality, add_audio_stream, diff --git a/test/utils.py b/test/utils.py index 70f32bfb..ea3e96c6 100644 --- a/test/utils.py +++ b/test/utils.py @@ -12,7 +12,7 @@ import torch -from torchcodec.decoders._core import get_ffmpeg_library_versions +from torchcodec._core import get_ffmpeg_library_versions # Decorator for skipping CUDA tests when CUDA isn't available. The tests are From e2d9997acacc164b27f47bf3192d92f6fd5700e0 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 1 Apr 2025 16:47:46 +0100 Subject: [PATCH 4/7] find . -type f | xargs sed -i "s/torchcodec\/decoders\/_core/torchcodec\/_core/g" --- CMakeLists.txt | 2 +- src/torchcodec/_core/AVIOBytesContext.cpp | 2 +- src/torchcodec/_core/AVIOBytesContext.h | 2 +- src/torchcodec/_core/AVIOContextHolder.cpp | 2 +- src/torchcodec/_core/AVIOContextHolder.h | 2 +- src/torchcodec/_core/AVIOFileLikeContext.cpp | 2 +- src/torchcodec/_core/AVIOFileLikeContext.h | 2 +- src/torchcodec/_core/CPUOnlyDevice.cpp | 2 +- src/torchcodec/_core/CudaDevice.cpp | 6 +++--- src/torchcodec/_core/DeviceInterface.h | 2 +- src/torchcodec/_core/FFMPEGCommon.cpp | 2 +- src/torchcodec/_core/VideoDecoder.cpp | 4 ++-- src/torchcodec/_core/VideoDecoder.h | 4 ++-- src/torchcodec/_core/custom_ops.cpp | 4 ++-- src/torchcodec/_core/pybind_ops.cpp | 4 ++-- test/decoders/VideoDecoderTest.cpp | 4 ++-- 16 files changed, 23 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dfeb060..8757d7f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.18) project(TorchCodec) -add_subdirectory(src/torchcodec/decoders/_core) +add_subdirectory(src/torchcodec/_core) option(BUILD_TESTS "Build tests" OFF) diff --git a/src/torchcodec/_core/AVIOBytesContext.cpp b/src/torchcodec/_core/AVIOBytesContext.cpp index 0d1e9d41..3e1481be 100644 --- a/src/torchcodec/_core/AVIOBytesContext.cpp +++ b/src/torchcodec/_core/AVIOBytesContext.cpp @@ -4,7 +4,7 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. -#include "src/torchcodec/decoders/_core/AVIOBytesContext.h" +#include "src/torchcodec/_core/AVIOBytesContext.h" #include namespace facebook::torchcodec { diff --git a/src/torchcodec/_core/AVIOBytesContext.h b/src/torchcodec/_core/AVIOBytesContext.h index 411866dc..c4fb7185 100644 --- a/src/torchcodec/_core/AVIOBytesContext.h +++ b/src/torchcodec/_core/AVIOBytesContext.h @@ -6,7 +6,7 @@ #pragma once -#include "src/torchcodec/decoders/_core/AVIOContextHolder.h" +#include "src/torchcodec/_core/AVIOContextHolder.h" namespace facebook::torchcodec { diff --git a/src/torchcodec/_core/AVIOContextHolder.cpp b/src/torchcodec/_core/AVIOContextHolder.cpp index 1fc4f5ec..f0ef095f 100644 --- a/src/torchcodec/_core/AVIOContextHolder.cpp +++ b/src/torchcodec/_core/AVIOContextHolder.cpp @@ -4,7 +4,7 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. -#include "src/torchcodec/decoders/_core/AVIOContextHolder.h" +#include "src/torchcodec/_core/AVIOContextHolder.h" #include namespace facebook::torchcodec { diff --git a/src/torchcodec/_core/AVIOContextHolder.h b/src/torchcodec/_core/AVIOContextHolder.h index 26bb06f0..69b32f29 100644 --- a/src/torchcodec/_core/AVIOContextHolder.h +++ b/src/torchcodec/_core/AVIOContextHolder.h @@ -6,7 +6,7 @@ #pragma once -#include "src/torchcodec/decoders/_core/FFMPEGCommon.h" +#include "src/torchcodec/_core/FFMPEGCommon.h" namespace facebook::torchcodec { diff --git a/src/torchcodec/_core/AVIOFileLikeContext.cpp b/src/torchcodec/_core/AVIOFileLikeContext.cpp index 60d1503a..4a905b93 100644 --- a/src/torchcodec/_core/AVIOFileLikeContext.cpp +++ b/src/torchcodec/_core/AVIOFileLikeContext.cpp @@ -4,7 +4,7 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. -#include "src/torchcodec/decoders/_core/AVIOFileLikeContext.h" +#include "src/torchcodec/_core/AVIOFileLikeContext.h" #include namespace facebook::torchcodec { diff --git a/src/torchcodec/_core/AVIOFileLikeContext.h b/src/torchcodec/_core/AVIOFileLikeContext.h index 7be07f2b..3e80f1c6 100644 --- a/src/torchcodec/_core/AVIOFileLikeContext.h +++ b/src/torchcodec/_core/AVIOFileLikeContext.h @@ -9,7 +9,7 @@ #include #include -#include "src/torchcodec/decoders/_core/AVIOContextHolder.h" +#include "src/torchcodec/_core/AVIOContextHolder.h" namespace py = pybind11; diff --git a/src/torchcodec/_core/CPUOnlyDevice.cpp b/src/torchcodec/_core/CPUOnlyDevice.cpp index 81746109..ad913171 100644 --- a/src/torchcodec/_core/CPUOnlyDevice.cpp +++ b/src/torchcodec/_core/CPUOnlyDevice.cpp @@ -1,5 +1,5 @@ #include -#include "src/torchcodec/decoders/_core/DeviceInterface.h" +#include "src/torchcodec/_core/DeviceInterface.h" namespace facebook::torchcodec { diff --git a/src/torchcodec/_core/CudaDevice.cpp b/src/torchcodec/_core/CudaDevice.cpp index 7ef7b82c..41596cb8 100644 --- a/src/torchcodec/_core/CudaDevice.cpp +++ b/src/torchcodec/_core/CudaDevice.cpp @@ -4,9 +4,9 @@ #include #include -#include "src/torchcodec/decoders/_core/DeviceInterface.h" -#include "src/torchcodec/decoders/_core/FFMPEGCommon.h" -#include "src/torchcodec/decoders/_core/VideoDecoder.h" +#include "src/torchcodec/_core/DeviceInterface.h" +#include "src/torchcodec/_core/FFMPEGCommon.h" +#include "src/torchcodec/_core/VideoDecoder.h" extern "C" { #include diff --git a/src/torchcodec/_core/DeviceInterface.h b/src/torchcodec/_core/DeviceInterface.h index 49aea802..d2f5940c 100644 --- a/src/torchcodec/_core/DeviceInterface.h +++ b/src/torchcodec/_core/DeviceInterface.h @@ -11,7 +11,7 @@ #include #include #include "FFMPEGCommon.h" -#include "src/torchcodec/decoders/_core/VideoDecoder.h" +#include "src/torchcodec/_core/VideoDecoder.h" namespace facebook::torchcodec { diff --git a/src/torchcodec/_core/FFMPEGCommon.cpp b/src/torchcodec/_core/FFMPEGCommon.cpp index 8bb41a85..33c8b484 100644 --- a/src/torchcodec/_core/FFMPEGCommon.cpp +++ b/src/torchcodec/_core/FFMPEGCommon.cpp @@ -4,7 +4,7 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. -#include "src/torchcodec/decoders/_core/FFMPEGCommon.h" +#include "src/torchcodec/_core/FFMPEGCommon.h" #include diff --git a/src/torchcodec/_core/VideoDecoder.cpp b/src/torchcodec/_core/VideoDecoder.cpp index 654e9a2e..08954342 100644 --- a/src/torchcodec/_core/VideoDecoder.cpp +++ b/src/torchcodec/_core/VideoDecoder.cpp @@ -4,7 +4,7 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. -#include "src/torchcodec/decoders/_core/VideoDecoder.h" +#include "src/torchcodec/_core/VideoDecoder.h" #include #include #include @@ -13,7 +13,7 @@ #include #include #include -#include "src/torchcodec/decoders/_core/DeviceInterface.h" +#include "src/torchcodec/_core/DeviceInterface.h" #include "torch/types.h" extern "C" { diff --git a/src/torchcodec/_core/VideoDecoder.h b/src/torchcodec/_core/VideoDecoder.h index 29007a1e..dacd09f3 100644 --- a/src/torchcodec/_core/VideoDecoder.h +++ b/src/torchcodec/_core/VideoDecoder.h @@ -12,8 +12,8 @@ #include #include -#include "src/torchcodec/decoders/_core/AVIOContextHolder.h" -#include "src/torchcodec/decoders/_core/FFMPEGCommon.h" +#include "src/torchcodec/_core/AVIOContextHolder.h" +#include "src/torchcodec/_core/FFMPEGCommon.h" namespace facebook::torchcodec { diff --git a/src/torchcodec/_core/custom_ops.cpp b/src/torchcodec/_core/custom_ops.cpp index c56755d2..af9602e0 100644 --- a/src/torchcodec/_core/custom_ops.cpp +++ b/src/torchcodec/_core/custom_ops.cpp @@ -10,8 +10,8 @@ #include #include "c10/core/SymIntArrayRef.h" #include "c10/util/Exception.h" -#include "src/torchcodec/decoders/_core/AVIOBytesContext.h" -#include "src/torchcodec/decoders/_core/VideoDecoder.h" +#include "src/torchcodec/_core/AVIOBytesContext.h" +#include "src/torchcodec/_core/VideoDecoder.h" namespace facebook::torchcodec { diff --git a/src/torchcodec/_core/pybind_ops.cpp b/src/torchcodec/_core/pybind_ops.cpp index 0b0f6f17..8c2f0c77 100644 --- a/src/torchcodec/_core/pybind_ops.cpp +++ b/src/torchcodec/_core/pybind_ops.cpp @@ -9,8 +9,8 @@ #include #include -#include "src/torchcodec/decoders/_core/AVIOFileLikeContext.h" -#include "src/torchcodec/decoders/_core/VideoDecoder.h" +#include "src/torchcodec/_core/AVIOFileLikeContext.h" +#include "src/torchcodec/_core/VideoDecoder.h" namespace py = pybind11; diff --git a/test/decoders/VideoDecoderTest.cpp b/test/decoders/VideoDecoderTest.cpp index dabe70cd..e617afc7 100644 --- a/test/decoders/VideoDecoderTest.cpp +++ b/test/decoders/VideoDecoderTest.cpp @@ -4,8 +4,8 @@ // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. -#include "src/torchcodec/decoders/_core/VideoDecoder.h" -#include "src/torchcodec/decoders/_core/AVIOBytesContext.h" +#include "src/torchcodec/_core/VideoDecoder.h" +#include "src/torchcodec/_core/AVIOBytesContext.h" #include #include From 962a4dc96c8b0bc2c2b8b0dda6f654a4e19f637e Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 1 Apr 2025 16:52:57 +0100 Subject: [PATCH 5/7] Revert "src/torchcodec/_core/_metadata.py -> src/torchcodec/decoders/_metadata.py" This reverts commit 31e806e9d2569ed99617889d0284e804571b7b81. --- src/torchcodec/{decoders => _core}/_metadata.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/torchcodec/{decoders => _core}/_metadata.py (100%) diff --git a/src/torchcodec/decoders/_metadata.py b/src/torchcodec/_core/_metadata.py similarity index 100% rename from src/torchcodec/decoders/_metadata.py rename to src/torchcodec/_core/_metadata.py From 7679d88b757ee46aa78b2ca7c11e7ef86618697c Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 1 Apr 2025 16:55:54 +0100 Subject: [PATCH 6/7] Fix some imports --- src/torchcodec/_core/CMakeLists.txt | 2 +- src/torchcodec/decoders/__init__.py | 2 +- src/torchcodec/decoders/_audio_decoder.py | 2 +- src/torchcodec/decoders/_decoder_utils.py | 2 +- src/torchcodec/decoders/_video_decoder.py | 2 +- test/decoders/test_decoders.py | 5 ++--- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/torchcodec/_core/CMakeLists.txt b/src/torchcodec/_core/CMakeLists.txt index 23ef2ca6..bb8f9660 100644 --- a/src/torchcodec/_core/CMakeLists.txt +++ b/src/torchcodec/_core/CMakeLists.txt @@ -20,7 +20,7 @@ function(make_torchcodec_sublibrary set_target_properties(${library_name} PROPERTIES CXX_STANDARD 17) target_include_directories(${library_name} PRIVATE - ./../../../../ + ./../../../ "${TORCH_INSTALL_PREFIX}/include" ${Python3_INCLUDE_DIRS} ) diff --git a/src/torchcodec/decoders/__init__.py b/src/torchcodec/decoders/__init__.py index 4bb09f4d..92695239 100644 --- a/src/torchcodec/decoders/__init__.py +++ b/src/torchcodec/decoders/__init__.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from ._audio_decoder import AudioDecoder # noqa -from ._core import AudioStreamMetadata, VideoStreamMetadata +from .._core import AudioStreamMetadata, VideoStreamMetadata from ._video_decoder import VideoDecoder # noqa SimpleVideoDecoder = VideoDecoder diff --git a/src/torchcodec/decoders/_audio_decoder.py b/src/torchcodec/decoders/_audio_decoder.py index 80fd87e5..225f69fe 100644 --- a/src/torchcodec/decoders/_audio_decoder.py +++ b/src/torchcodec/decoders/_audio_decoder.py @@ -10,7 +10,7 @@ from torch import Tensor from torchcodec import AudioSamples -from torchcodec.decoders import _core as core +from torchcodec import _core as core from torchcodec.decoders._decoder_utils import ( create_decoder, ERROR_REPORTING_INSTRUCTIONS, diff --git a/src/torchcodec/decoders/_decoder_utils.py b/src/torchcodec/decoders/_decoder_utils.py index bb882fbf..c5534711 100644 --- a/src/torchcodec/decoders/_decoder_utils.py +++ b/src/torchcodec/decoders/_decoder_utils.py @@ -9,7 +9,7 @@ from typing import Union from torch import Tensor -from torchcodec.decoders import _core as core +from torchcodec import _core as core ERROR_REPORTING_INSTRUCTIONS = """ This should never happen. Please report an issue following the steps in diff --git a/src/torchcodec/decoders/_video_decoder.py b/src/torchcodec/decoders/_video_decoder.py index 081f332b..c1672a94 100644 --- a/src/torchcodec/decoders/_video_decoder.py +++ b/src/torchcodec/decoders/_video_decoder.py @@ -11,7 +11,7 @@ from torch import device, Tensor from torchcodec import Frame, FrameBatch -from torchcodec.decoders import _core as core +from torchcodec import _core as core from torchcodec.decoders._decoder_utils import ( create_decoder, ERROR_REPORTING_INSTRUCTIONS, diff --git a/test/decoders/test_decoders.py b/test/decoders/test_decoders.py index f97fc3fa..7493c34f 100644 --- a/test/decoders/test_decoders.py +++ b/test/decoders/test_decoders.py @@ -11,9 +11,8 @@ import torch from torchcodec import FrameBatch -from torchcodec.decoders import _core, VideoDecoder, VideoStreamMetadata -from torchcodec.decoders._audio_decoder import AudioDecoder -from torchcodec._core._metadata import AudioStreamMetadata +from torchcodec import _core +from torchcodec.decoders import VideoDecoder, VideoStreamMetadata, AudioDecoder, AudioStreamMetadata from ..utils import ( assert_frames_equal, From 21149c86732347704da181309780db1257818a21 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 1 Apr 2025 16:56:06 +0100 Subject: [PATCH 7/7] Linter --- benchmarks/decoders/benchmark_decoders_library.py | 2 +- src/torchcodec/decoders/__init__.py | 2 +- src/torchcodec/decoders/_audio_decoder.py | 3 +-- src/torchcodec/decoders/_video_decoder.py | 3 +-- test/decoders/test_decoders.py | 10 +++++++--- test/decoders/test_metadata.py | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/benchmarks/decoders/benchmark_decoders_library.py b/benchmarks/decoders/benchmark_decoders_library.py index 27145deb..9b25c6fe 100644 --- a/benchmarks/decoders/benchmark_decoders_library.py +++ b/benchmarks/decoders/benchmark_decoders_library.py @@ -13,7 +13,6 @@ import torch import torch.utils.benchmark as benchmark -from torchcodec.decoders import VideoDecoder, VideoStreamMetadata from torchcodec._core import ( _add_video_stream, @@ -24,6 +23,7 @@ get_next_frame, seek_to_pts, ) +from torchcodec.decoders import VideoDecoder, VideoStreamMetadata torch._dynamo.config.cache_size_limit = 100 torch._dynamo.config.capture_dynamic_output_shape_ops = True diff --git a/src/torchcodec/decoders/__init__.py b/src/torchcodec/decoders/__init__.py index 92695239..7b27a3bf 100644 --- a/src/torchcodec/decoders/__init__.py +++ b/src/torchcodec/decoders/__init__.py @@ -4,8 +4,8 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -from ._audio_decoder import AudioDecoder # noqa from .._core import AudioStreamMetadata, VideoStreamMetadata +from ._audio_decoder import AudioDecoder # noqa from ._video_decoder import VideoDecoder # noqa SimpleVideoDecoder = VideoDecoder diff --git a/src/torchcodec/decoders/_audio_decoder.py b/src/torchcodec/decoders/_audio_decoder.py index 225f69fe..002743ff 100644 --- a/src/torchcodec/decoders/_audio_decoder.py +++ b/src/torchcodec/decoders/_audio_decoder.py @@ -9,8 +9,7 @@ from torch import Tensor -from torchcodec import AudioSamples -from torchcodec import _core as core +from torchcodec import _core as core, AudioSamples from torchcodec.decoders._decoder_utils import ( create_decoder, ERROR_REPORTING_INSTRUCTIONS, diff --git a/src/torchcodec/decoders/_video_decoder.py b/src/torchcodec/decoders/_video_decoder.py index c1672a94..accc070c 100644 --- a/src/torchcodec/decoders/_video_decoder.py +++ b/src/torchcodec/decoders/_video_decoder.py @@ -10,8 +10,7 @@ from torch import device, Tensor -from torchcodec import Frame, FrameBatch -from torchcodec import _core as core +from torchcodec import _core as core, Frame, FrameBatch from torchcodec.decoders._decoder_utils import ( create_decoder, ERROR_REPORTING_INSTRUCTIONS, diff --git a/test/decoders/test_decoders.py b/test/decoders/test_decoders.py index 7493c34f..b824c202 100644 --- a/test/decoders/test_decoders.py +++ b/test/decoders/test_decoders.py @@ -9,10 +9,14 @@ import numpy import pytest import torch -from torchcodec import FrameBatch -from torchcodec import _core -from torchcodec.decoders import VideoDecoder, VideoStreamMetadata, AudioDecoder, AudioStreamMetadata +from torchcodec import _core, FrameBatch +from torchcodec.decoders import ( + AudioDecoder, + AudioStreamMetadata, + VideoDecoder, + VideoStreamMetadata, +) from ..utils import ( assert_frames_equal, diff --git a/test/decoders/test_metadata.py b/test/decoders/test_metadata.py index c5a772f4..6e401879 100644 --- a/test/decoders/test_metadata.py +++ b/test/decoders/test_metadata.py @@ -7,7 +7,6 @@ import functools import pytest -from torchcodec.decoders import AudioDecoder, VideoDecoder from torchcodec._core import ( AudioStreamMetadata, @@ -17,6 +16,7 @@ get_ffmpeg_library_versions, VideoStreamMetadata, ) +from torchcodec.decoders import AudioDecoder, VideoDecoder from ..utils import NASA_AUDIO_MP3, NASA_VIDEO