diff --git a/src/torchcodec/decoders/_audio_decoder.py b/src/torchcodec/decoders/_audio_decoder.py index 472a387a8..b6a373190 100644 --- a/src/torchcodec/decoders/_audio_decoder.py +++ b/src/torchcodec/decoders/_audio_decoder.py @@ -8,6 +8,7 @@ from pathlib import Path from typing import Optional, Union +import torch from torch import Tensor from torchcodec import _core as core, AudioSamples @@ -59,6 +60,7 @@ def __init__( sample_rate: Optional[int] = None, num_channels: Optional[int] = None, ): + torch._C._log_api_usage_once("torchcodec.decoders.AudioDecoder") self._decoder = create_decoder(source=source, seek_mode="approximate") core.add_audio_stream( diff --git a/src/torchcodec/decoders/_video_decoder.py b/src/torchcodec/decoders/_video_decoder.py index bb252fd6d..0a030dbd0 100644 --- a/src/torchcodec/decoders/_video_decoder.py +++ b/src/torchcodec/decoders/_video_decoder.py @@ -9,6 +9,7 @@ from pathlib import Path from typing import Literal, Optional, Tuple, Union +import torch from torch import device as torch_device, Tensor from torchcodec import _core as core, Frame, FrameBatch @@ -80,6 +81,7 @@ def __init__( device: Optional[Union[str, torch_device]] = "cpu", seek_mode: Literal["exact", "approximate"] = "exact", ): + torch._C._log_api_usage_once("torchcodec.decoders.VideoDecoder") allowed_seek_modes = ("exact", "approximate") if seek_mode not in allowed_seek_modes: raise ValueError( diff --git a/src/torchcodec/encoders/_audio_encoder.py b/src/torchcodec/encoders/_audio_encoder.py index 01e271159..8b81a9143 100644 --- a/src/torchcodec/encoders/_audio_encoder.py +++ b/src/torchcodec/encoders/_audio_encoder.py @@ -21,6 +21,7 @@ class AudioEncoder: """ def __init__(self, samples: Tensor, *, sample_rate: int): + torch._C._log_api_usage_once("torchcodec.encoders.AudioEncoder") # Some of these checks are also done in C++: it's OK, they're cheap, and # doing them here allows to surface them when the AudioEncoder is # instantiated, rather than later when the encoding methods are called. diff --git a/src/torchcodec/samplers/_index_based.py b/src/torchcodec/samplers/_index_based.py index a81fa645e..d8f107c5e 100644 --- a/src/torchcodec/samplers/_index_based.py +++ b/src/torchcodec/samplers/_index_based.py @@ -196,6 +196,7 @@ def clips_at_random_indices( policy: Literal["repeat_last", "wrap", "error"] = "repeat_last", ) -> FrameBatch: # See docstring below + torch._C._log_api_usage_once("torchcodec.samplers.clips_at_random_indices") return _generic_index_based_sampler( kind="random", decoder=decoder, @@ -219,6 +220,7 @@ def clips_at_regular_indices( policy: Literal["repeat_last", "wrap", "error"] = "repeat_last", ) -> FrameBatch: # See docstring below + torch._C._log_api_usage_once("torchcodec.samplers.clips_at_regular_indices") return _generic_index_based_sampler( kind="regular", decoder=decoder, diff --git a/src/torchcodec/samplers/_time_based.py b/src/torchcodec/samplers/_time_based.py index 03d115754..f501e0177 100644 --- a/src/torchcodec/samplers/_time_based.py +++ b/src/torchcodec/samplers/_time_based.py @@ -231,6 +231,7 @@ def clips_at_random_timestamps( policy: Literal["repeat_last", "wrap", "error"] = "repeat_last", ) -> FrameBatch: # See docstring below + torch._C._log_api_usage_once("torchcodec.samplers.clips_at_random_timestamps") return _generic_time_based_sampler( kind="random", decoder=decoder, @@ -256,6 +257,7 @@ def clips_at_regular_timestamps( policy: Literal["repeat_last", "wrap", "error"] = "repeat_last", ) -> FrameBatch: # See docstring below + torch._C._log_api_usage_once("torchcodec.samplers.clips_at_regular_timestamps") return _generic_time_based_sampler( kind="regular", decoder=decoder,