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
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
cmake_minimum_required(VERSION 3.17.0)
cmake_minimum_required(VERSION 3.21...4.0)

project(implicit)

find_package(
Python
COMPONENTS Interpreter Development.Module
REQUIRED)
include(UseCython)

enable_testing()

find_package(PythonExtensions REQUIRED)
find_package(Cython REQUIRED)
find_package(OpenMP)

include_directories(.)
Expand Down
3 changes: 1 addition & 2 deletions ci/install_cuda_13.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ dnf install -y \
cuda-nvcc-13-0 \
cuda-cudart-devel-13-0 \
libcurand-devel-13-0 \
libcublas-devel-13-0 \
ninja-build
libcublas-devel-13-0

ln -s cuda-13.0 /usr/local/cuda
14 changes: 6 additions & 8 deletions implicit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ if(NOT CYTHON_FLAGS)
)
endif()

add_cython_target(_nearest_neighbours CXX)
add_library(_nearest_neighbours MODULE ${_nearest_neighbours})
python_extension_module(_nearest_neighbours)
cython_transpile(_nearest_neighbours.pyx LANGUAGE CXX)
python_add_library(_nearest_neighbours MODULE _nearest_neighbours.cxx)
install(TARGETS _nearest_neighbours LIBRARY DESTINATION implicit)

add_cython_target(evaluation CXX)
add_library(evaluation MODULE ${evaluation})
python_extension_module(evaluation)
cython_transpile(evaluation.pyx LANGUAGE CXX)
python_add_library(evaluation MODULE evaluation.cxx)
install(TARGETS evaluation LIBRARY DESTINATION implicit)

if(OpenMP_CXX_FOUND)
target_link_libraries(_nearest_neighbours OpenMP::OpenMP_CXX)
target_link_libraries(evaluation OpenMP::OpenMP_CXX)
target_link_libraries(_nearest_neighbours PUBLIC OpenMP::OpenMP_CXX)
target_link_libraries(evaluation PUBLIC OpenMP::OpenMP_CXX)
endif()

add_subdirectory(cpu)
Expand Down
28 changes: 12 additions & 16 deletions implicit/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
add_cython_target(_als CXX)
add_library(_als MODULE ${_als})
python_extension_module(_als)
cython_transpile(_als.pyx LANGUAGE CXX)
python_add_library(_als MODULE _als.cxx)
install(TARGETS _als LIBRARY DESTINATION implicit/cpu)

add_cython_target(bpr CXX)
add_library(bpr MODULE ${bpr})
python_extension_module(bpr)
cython_transpile(bpr.pyx LANGUAGE CXX)
python_add_library(bpr MODULE bpr.cxx)
install(TARGETS bpr LIBRARY DESTINATION implicit/cpu)

add_cython_target(topk CXX)
add_library(topk MODULE ${topk})
python_extension_module(topk)
cython_transpile(topk.pyx LANGUAGE CXX)
python_add_library(topk MODULE topk.cxx)
install(TARGETS topk LIBRARY DESTINATION implicit/cpu)

add_cython_target(lmf CXX)
add_library(lmf MODULE ${lmf})
python_extension_module(lmf)
cython_transpile(lmf.pyx LANGUAGE CXX)
python_add_library(lmf MODULE lmf.cxx)
install(TARGETS lmf LIBRARY DESTINATION implicit/cpu)

if(OpenMP_CXX_FOUND)
target_link_libraries(_als OpenMP::OpenMP_CXX)
target_link_libraries(bpr OpenMP::OpenMP_CXX)
target_link_libraries(topk OpenMP::OpenMP_CXX)
target_link_libraries(lmf OpenMP::OpenMP_CXX)
target_link_libraries(_als PUBLIC OpenMP::OpenMP_CXX)
target_link_libraries(bpr PUBLIC OpenMP::OpenMP_CXX)
target_link_libraries(topk PUBLIC OpenMP::OpenMP_CXX)
target_link_libraries(lmf PUBLIC OpenMP::OpenMP_CXX)
endif()

FILE(GLOB cpu_python_files *.py)
Expand Down
14 changes: 5 additions & 9 deletions implicit/gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ elseif(DEFINED ENV{IMPLICIT_DISABLE_CUDA})

else()
enable_language(CUDA)
add_cython_target(_cuda CXX)
cython_transpile(_cuda.pyx LANGUAGE CXX)

add_compile_options(-DCCCL_IGNORE_DEPRECATED_STREAM_REF_HEADER)

Expand All @@ -31,16 +31,14 @@ else()

# We must find CCCL ourselves before raft so that we get the right version.
include(${rapids-cmake-dir}/cpm/cccl.cmake)
rapids_cpm_cccl(BUILD_EXPORT_SET implicit-exports INSTALL_EXPORT_SET implicit-exports)
rapids_cpm_cccl()

# get rmm
include(${rapids-cmake-dir}/cpm/rmm.cmake)
rapids_cpm_rmm(BUILD_EXPORT_SET implicit-exports INSTALL_EXPORT_SET implicit-exports)
rapids_cpm_rmm()

rapids_cpm_find(raft 26.02
GLOBAL_TARGETS raft::raft
BUILD_EXPORT_SET implicit-exports
INSTALL_EXPORT_SET implicit-exports
CPM_ARGS
GIT_REPOSITORY https://github.com/rapidsai/raft.git
GIT_TAG v26.02.00
Expand All @@ -52,16 +50,14 @@ else()
)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda -Wno-deprecated-gpu-targets -Xfatbin=-compress-all --expt-relaxed-constexpr")

add_library(_cuda MODULE ${_cuda}
python_add_library(_cuda MODULE _cuda.cxx
als.cu
bpr.cu
matrix.cu
random.cu
knn.cu
)

python_extension_module(_cuda)

if(DEFINED ENV{IMPLICIT_CUDA_ARCH})
message("using cuda arch $ENV{IMPLICIT_CUDA_ARCH}")
set_target_properties(_cuda PROPERTIES CUDA_ARCHITECTURES $ENV{IMPLICIT_CUDA_ARCH})
Expand All @@ -78,7 +74,7 @@ else()
get_target_property(CUDA_ARCH _cuda CUDA_ARCHITECTURES)
message("using cuda architectures ${CUDA_ARCH} for cuda version ${CUDAToolkit_VERSION}")
endif()
target_link_libraries(_cuda CUDA::cublas CUDA::curand rmm::rmm raft::raft)
target_link_libraries(_cuda PRIVATE CUDA::cublas CUDA::curand raft::raft)

install(TARGETS _cuda LIBRARY DESTINATION implicit/gpu)
endif()
Expand Down
38 changes: 32 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"scikit-build>=0.13.1",
"Cython>=0.24",
"scikit-build-core>=0.11",
"cython",
"cython-cmake",
"scipy>=0.16",
"cmake>=3.18",
"ninja"
]
build-backend = "setuptools.build_meta"
build-backend = "scikit_build_core.build"

[project]
name = "implicit"
version = "0.7.2"
description = "Collaborative Filtering for Implicit Feedback Datasets"
readme = "README.md"
authors = [
{ name = "Ben Frederickson", email = "ben@benfrederickson.com" },
]
requires-python = ">=3.8"
license = "MIT"
license-files = ["LICENSE"]
classifiers = [
"Development Status :: 4 - Beta",
"Natural Language :: English",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Cython",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = ["numpy>=1.17.0", "scipy>=0.16", "tqdm>=4.27", "threadpoolctl"]

[tool.scikit-build]
wheel.exclude = ["**.pyx", "**.cmake", "**.cuh", "**.hpp", "**.h", "**.hpp.in"]
cmake.version = ">=3.21.0"
ninja.version = ">=1.10"

[tool.cibuildwheel]
# skip testing in the cibuildwheel phase, will install the wheels later
Expand Down
49 changes: 0 additions & 49 deletions setup.py

This file was deleted.

Loading