Skip to content

Commit ffcb7ab

Browse files
authored
Add internal usage logging (#818)
1 parent 97bf7cc commit ffcb7ab

File tree

5 files changed

+9
-0
lines changed

5 files changed

+9
-0
lines changed

src/torchcodec/decoders/_audio_decoder.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pathlib import Path
99
from typing import Optional, Union
1010

11+
import torch
1112
from torch import Tensor
1213

1314
from torchcodec import _core as core, AudioSamples
@@ -59,6 +60,7 @@ def __init__(
5960
sample_rate: Optional[int] = None,
6061
num_channels: Optional[int] = None,
6162
):
63+
torch._C._log_api_usage_once("torchcodec.decoders.AudioDecoder")
6264
self._decoder = create_decoder(source=source, seek_mode="approximate")
6365

6466
core.add_audio_stream(

src/torchcodec/decoders/_video_decoder.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from pathlib import Path
1010
from typing import Literal, Optional, Tuple, Union
1111

12+
import torch
1213
from torch import device as torch_device, Tensor
1314

1415
from torchcodec import _core as core, Frame, FrameBatch
@@ -80,6 +81,7 @@ def __init__(
8081
device: Optional[Union[str, torch_device]] = "cpu",
8182
seek_mode: Literal["exact", "approximate"] = "exact",
8283
):
84+
torch._C._log_api_usage_once("torchcodec.decoders.VideoDecoder")
8385
allowed_seek_modes = ("exact", "approximate")
8486
if seek_mode not in allowed_seek_modes:
8587
raise ValueError(

src/torchcodec/encoders/_audio_encoder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class AudioEncoder:
2121
"""
2222

2323
def __init__(self, samples: Tensor, *, sample_rate: int):
24+
torch._C._log_api_usage_once("torchcodec.encoders.AudioEncoder")
2425
# Some of these checks are also done in C++: it's OK, they're cheap, and
2526
# doing them here allows to surface them when the AudioEncoder is
2627
# instantiated, rather than later when the encoding methods are called.

src/torchcodec/samplers/_index_based.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def clips_at_random_indices(
196196
policy: Literal["repeat_last", "wrap", "error"] = "repeat_last",
197197
) -> FrameBatch:
198198
# See docstring below
199+
torch._C._log_api_usage_once("torchcodec.samplers.clips_at_random_indices")
199200
return _generic_index_based_sampler(
200201
kind="random",
201202
decoder=decoder,
@@ -219,6 +220,7 @@ def clips_at_regular_indices(
219220
policy: Literal["repeat_last", "wrap", "error"] = "repeat_last",
220221
) -> FrameBatch:
221222
# See docstring below
223+
torch._C._log_api_usage_once("torchcodec.samplers.clips_at_regular_indices")
222224
return _generic_index_based_sampler(
223225
kind="regular",
224226
decoder=decoder,

src/torchcodec/samplers/_time_based.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ def clips_at_random_timestamps(
231231
policy: Literal["repeat_last", "wrap", "error"] = "repeat_last",
232232
) -> FrameBatch:
233233
# See docstring below
234+
torch._C._log_api_usage_once("torchcodec.samplers.clips_at_random_timestamps")
234235
return _generic_time_based_sampler(
235236
kind="random",
236237
decoder=decoder,
@@ -256,6 +257,7 @@ def clips_at_regular_timestamps(
256257
policy: Literal["repeat_last", "wrap", "error"] = "repeat_last",
257258
) -> FrameBatch:
258259
# See docstring below
260+
torch._C._log_api_usage_once("torchcodec.samplers.clips_at_regular_timestamps")
259261
return _generic_time_based_sampler(
260262
kind="regular",
261263
decoder=decoder,

0 commit comments

Comments
 (0)