Skip to content

Commit d444567

Browse files
authored
Refactor C++ library names (#768)
1 parent 86e952f commit d444567

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

src/torchcodec/_core/CMakeLists.txt

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,55 +48,53 @@ function(make_torchcodec_libraries
4848
# We create three shared libraries per version of FFmpeg, where the version
4949
# is denoted by N:
5050
#
51-
# 1. libtorchcodec_decoderN.{ext}: Base library which contains the
51+
# 1. libtorchcodec_coreN.{ext}: Base library which contains the
5252
# implementation of VideoDecoder and everything VideoDecoder needs. On
5353
# Linux, {ext} is so. On Mac, it is dylib.
5454
#
5555
# 2. libtorchcodec_custom_opsN.{ext}: Implementation of the PyTorch custom
56-
# ops. Depends on libtorchcodec_decoderN.{ext}. On Linux, {ext} is so.
56+
# ops. Depends on libtorchcodec_coreN.{ext}. On Linux, {ext} is so.
5757
# On Mac, it is dylib.
5858
#
5959
# 3. libtorchcodec_pybind_opsN.{ext}: Implementation of the pybind11 ops. We
6060
# keep these separate from the PyTorch custom ops because we have to
6161
# load these libraries separately on the Python side. Depends on
62-
# libtorchcodec_decoderN.{ext}. On BOTH Linux and Mac {ext} is so.
62+
# libtorchcodec_coreN.{ext}. On BOTH Linux and Mac {ext} is so.
6363

64-
# 1. Create libtorchcodec_decoderN.{ext}.
65-
set(decoder_library_name "libtorchcodec_decoder${ffmpeg_major_version}")
66-
set(decoder_sources
64+
# 1. Create libtorchcodec_coreN.{ext}.
65+
set(core_library_name "libtorchcodec_core${ffmpeg_major_version}")
66+
set(core_sources
6767
AVIOContextHolder.cpp
6868
AVIOTensorContext.cpp
6969
FFMPEGCommon.cpp
7070
Frame.cpp
7171
DeviceInterface.cpp
7272
CpuDeviceInterface.cpp
7373
SingleStreamDecoder.cpp
74-
# TODO: lib name should probably not be "*_decoder*" now that it also
75-
# contains an encoder
7674
Encoder.cpp
7775
)
7876

7977
if(ENABLE_CUDA)
80-
list(APPEND decoder_sources CudaDeviceInterface.cpp)
78+
list(APPEND core_sources CudaDeviceInterface.cpp)
8179
endif()
8280

83-
set(decoder_library_dependencies
81+
set(core_library_dependencies
8482
${ffmpeg_target}
8583
${TORCH_LIBRARIES}
8684
)
8785

8886
if(ENABLE_CUDA)
89-
list(APPEND decoder_library_dependencies
87+
list(APPEND core_library_dependencies
9088
${CUDA_nppi_LIBRARY}
9189
${CUDA_nppicc_LIBRARY}
9290
)
9391
endif()
9492

9593
make_torchcodec_sublibrary(
96-
"${decoder_library_name}"
94+
"${core_library_name}"
9795
SHARED
98-
"${decoder_sources}"
99-
"${decoder_library_dependencies}"
96+
"${core_sources}"
97+
"${core_library_dependencies}"
10098
)
10199

102100
# 2. Create libtorchcodec_custom_opsN.{ext}.
@@ -106,7 +104,7 @@ function(make_torchcodec_libraries
106104
custom_ops.cpp
107105
)
108106
set(custom_ops_dependencies
109-
${decoder_library_name}
107+
${core_library_name}
110108
${Python3_LIBRARIES}
111109
)
112110
make_torchcodec_sublibrary(
@@ -123,7 +121,7 @@ function(make_torchcodec_libraries
123121
pybind_ops.cpp
124122
)
125123
set(pybind_ops_dependencies
126-
${decoder_library_name}
124+
${core_library_name}
127125
pybind11::module # This library dependency makes sure we have the right
128126
# Python libraries included as well as all of the right
129127
# settings so that we can successfully load the shared
@@ -158,7 +156,7 @@ function(make_torchcodec_libraries
158156
target_compile_definitions(
159157
${pybind_ops_library_name}
160158
PRIVATE
161-
PYBIND_OPS_MODULE_NAME=decoder_core_pybind_ops
159+
PYBIND_OPS_MODULE_NAME=core_pybind_ops
162160
)
163161
# If we don't make sure this flag is set, we run into segfauls at import
164162
# time on Mac. See:
@@ -172,7 +170,7 @@ function(make_torchcodec_libraries
172170
# Install all libraries.
173171
set(
174172
all_libraries
175-
${decoder_library_name}
173+
${core_library_name}
176174
${custom_ops_library_name}
177175
${pybind_ops_library_name}
178176
)
@@ -249,7 +247,7 @@ else()
249247
# Expose these values updwards so that the test compilation does not need
250248
# to re-figure it out. FIXME: it's not great that we just copy-paste the
251249
# library names.
252-
set(libtorchcodec_library_name "libtorchcodec_decoder${ffmpeg_major_version}" PARENT_SCOPE)
250+
set(libtorchcodec_library_name "libtorchcodec_core${ffmpeg_major_version}" PARENT_SCOPE)
253251
set(libtorchcodec_custom_ops_name "libtorchcodec_custom_ops${ffmpeg_major_version}" PARENT_SCOPE)
254252
set(libav_include_dirs ${LIBAV_INCLUDE_DIRS} PARENT_SCOPE)
255253
endif()

src/torchcodec/_core/ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def load_torchcodec_shared_libraries():
4646
exceptions = []
4747
for ffmpeg_major_version in (7, 6, 5, 4):
4848
pybind_ops_module_name = _get_pybind_ops_module_name(ffmpeg_major_version)
49-
decoder_library_name = f"libtorchcodec_decoder{ffmpeg_major_version}"
49+
decoder_library_name = f"libtorchcodec_core{ffmpeg_major_version}"
5050
custom_ops_library_name = f"libtorchcodec_custom_ops{ffmpeg_major_version}"
5151
pybind_ops_library_name = f"libtorchcodec_pybind_ops{ffmpeg_major_version}"
5252
try:

src/torchcodec/_internally_replaced_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ def _get_pybind_ops_module_name(ffmpeg_major_version: str) -> str:
6161
#
6262
# The parameter ffmpeg_major_version is unused externally, but used
6363
# internally.
64-
return "decoder_core_pybind_ops"
64+
return "core_pybind_ops"

0 commit comments

Comments
 (0)