Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def _build_all_extensions_with_cmake(self):
torch_dir = Path(torch.utils.cmake_prefix_path) / "Torch"
cmake_build_type = os.environ.get("CMAKE_BUILD_TYPE", "Release")
enable_cuda = os.environ.get("ENABLE_CUDA", "")
enable_xpu = os.environ.get("ENABLE_XPU", "")
torchcodec_disable_compile_warning_as_error = os.environ.get(
"TORCHCODEC_DISABLE_COMPILE_WARNING_AS_ERROR", "OFF"
)
Expand All @@ -123,6 +124,7 @@ def _build_all_extensions_with_cmake(self):
f"-DCMAKE_BUILD_TYPE={cmake_build_type}",
f"-DPYTHON_VERSION={python_version.major}.{python_version.minor}",
f"-DENABLE_CUDA={enable_cuda}",
f"-DENABLE_XPU={enable_xpu}",
f"-DTORCHCODEC_DISABLE_COMPILE_WARNING_AS_ERROR={torchcodec_disable_compile_warning_as_error}",
]

Expand Down
20 changes: 19 additions & 1 deletion src/torchcodec/_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic ${TORCHCODEC_WERROR_OPTION} ${TORCH_CXX_FLAGS}")
endif()

if(ENABLE_CUDA)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_CUDA")
endif()
if(ENABLE_XPU)
find_package(PkgConfig REQUIRED)
pkg_check_modules(L0 REQUIRED IMPORTED_TARGET level-zero)
pkg_check_modules(LIBVA REQUIRED IMPORTED_TARGET libva)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_XPU")
endif()

function(make_torchcodec_sublibrary
library_name
Expand Down Expand Up @@ -109,7 +118,11 @@ function(make_torchcodec_libraries
)

if(ENABLE_CUDA)
list(APPEND core_sources CudaDeviceInterface.cpp)
list(APPEND core_sources CudaDeviceInterface.cpp)
endif()

if(ENABLE_XPU)
list(APPEND core_sources XpuDeviceInterface.cpp)
endif()

set(core_library_dependencies
Expand All @@ -124,6 +137,11 @@ function(make_torchcodec_libraries
)
endif()

if(ENABLE_XPU)
list(APPEND core_library_dependencies
PkgConfig::L0 PkgConfig::LIBVA)
endif()

make_torchcodec_sublibrary(
"${core_library_name}"
SHARED
Expand Down
Loading
Loading