-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,32 @@ | ||
cmake_minimum_required(VERSION 3.12...3.18) | ||
project(kepler_jax LANGUAGES CXX) | ||
cmake_minimum_required(VERSION 3.15...3.26) | ||
project(${SKBUILD_PROJECT_NAME} LANGUAGES C CXX) | ||
message(STATUS "Using CMake version: " ${CMAKE_VERSION}) | ||
|
||
message(STATUS "Using CMake version " ${CMAKE_VERSION}) | ||
|
||
find_package(Python COMPONENTS Interpreter Development REQUIRED) | ||
# Find pybind11 | ||
set(PYBIND11_NEWPYTHON ON) | ||
find_package(pybind11 CONFIG REQUIRED) | ||
|
||
# find_package(Python COMPONENTS Interpreter Development REQUIRED) | ||
# find_package(pybind11 CONFIG REQUIRED) | ||
|
||
include_directories(${CMAKE_CURRENT_LIST_DIR}/lib) | ||
|
||
# CPU op library | ||
pybind11_add_module(cpu_ops ${CMAKE_CURRENT_LIST_DIR}/lib/cpu_ops.cc) | ||
install(TARGETS cpu_ops DESTINATION kepler_jax) | ||
install(TARGETS cpu_ops LIBRARY DESTINATION .) | ||
|
||
# Include the CUDA extensions if possible | ||
include(CheckLanguage) | ||
check_language(CUDA) | ||
|
||
if (KEPLER_JAX_CUDA) | ||
if(CMAKE_CUDA_COMPILER) | ||
enable_language(CUDA) | ||
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) | ||
pybind11_add_module( | ||
gpu_ops | ||
${CMAKE_CURRENT_LIST_DIR}/lib/kernels.cc.cu | ||
${CMAKE_CURRENT_LIST_DIR}/lib/gpu_ops.cc) | ||
install(TARGETS gpu_ops DESTINATION kepler_jax) | ||
install(TARGETS gpu_ops LIBRARY DESTINATION .) | ||
else() | ||
message(STATUS "Building without CUDA") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
[project] | ||
name = "kepler_jax" | ||
description = "A simple demonstration of how you can extend JAX with custom C++ and CUDA ops" | ||
readme = "README.md" | ||
authors = [{ name = "Dan Foreman-Mackey", email = "[email protected]" }] | ||
requires-python = ">=3.9" | ||
license = { file = "LICENSE" } | ||
urls = { Homepage = "https://github.com/dfm/extending-jax" } | ||
dependencies = ["jax>=0.4.16"] | ||
dynamic = ["version"] | ||
|
||
[project.optional-dependencies] | ||
test = ["pytest"] | ||
|
||
[build-system] | ||
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4", "pybind11>=2.6", "cmake"] | ||
build-backend = "setuptools.build_meta" | ||
requires = ["pybind11>=2.6", "scikit-build-core>=0.5"] | ||
build-backend = "scikit_build_core.build" | ||
|
||
[tool.scikit-build] | ||
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" | ||
sdist.include = ["src/kepler_jax/kepler_jax_version.py"] | ||
wheel.install-dir = "kepler_jax" | ||
minimum-version = "0.5" | ||
build-dir = "build/{wheel_tag}" | ||
|
||
[tool.setuptools_scm] | ||
write_to = "src/kepler_jax/kepler_jax_version.py" |