Skip to content

Commit 5898c35

Browse files
committed
Refactor build system to use pyproject.toml
1 parent 91094b6 commit 5898c35

43 files changed

Lines changed: 118 additions & 28 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ build
88
# pip wheel directory
99
dist
1010

11-
nvfuser/version.py
12-
nvfuser/include
13-
nvfuser/lib
14-
nvfuser/share
15-
nvfuser/cmake
11+
python/nvfuser/version.py
12+
python/nvfuser/include
13+
python/nvfuser/lib
14+
python/nvfuser/share
15+
python/nvfuser/cmake
1616

1717
.hypothesis
1818
*.egg-info/
1919
**/__pycache__
2020
*/*.so
21+
python/nvfuser/*.so
2122

2223
# Editor temporaries
2324
*.swa

CMakeLists.txt

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1010

1111
set(NVFUSER_ROOT ${PROJECT_SOURCE_DIR})
1212
set(NVFUSER_SRCS_DIR "${NVFUSER_ROOT}/csrc")
13+
set(NVFUSER_PYTHON_DIR "${NVFUSER_ROOT}/python")
1314
set(NVFUSER_THIRD_PARTY_DIR "${NVFUSER_ROOT}/third_party")
1415

1516
option(NVFUSER_STANDALONE_BUILD_WITH_UCC "" OFF)
@@ -289,13 +290,13 @@ endif()
289290

290291
if(BUILD_PYTHON)
291292
list(APPEND NVFUSER_SRCS
292-
${NVFUSER_SRCS_DIR}/python_frontend/distributed_tensor.cpp
293-
${NVFUSER_SRCS_DIR}/python_frontend/fusion_cache.cpp
294-
${NVFUSER_SRCS_DIR}/python_frontend/fusion_definition.cpp
295-
${NVFUSER_SRCS_DIR}/python_frontend/fusion_state.cpp
296-
${NVFUSER_SRCS_DIR}/python_frontend/segmentation.cpp
297-
${NVFUSER_SRCS_DIR}/python_frontend/translation.cpp
298-
${NVFUSER_SRCS_DIR}/python_frontend/translation_utils.cpp
293+
${NVFUSER_PYTHON_DIR}/python_frontend/distributed_tensor.cpp
294+
${NVFUSER_PYTHON_DIR}/python_frontend/fusion_cache.cpp
295+
${NVFUSER_PYTHON_DIR}/python_frontend/fusion_definition.cpp
296+
${NVFUSER_PYTHON_DIR}/python_frontend/fusion_state.cpp
297+
${NVFUSER_PYTHON_DIR}/python_frontend/segmentation.cpp
298+
${NVFUSER_PYTHON_DIR}/python_frontend/translation.cpp
299+
${NVFUSER_PYTHON_DIR}/python_frontend/translation_utils.cpp
299300
${NVFUSER_SRCS_DIR}/serde/fusion_record.cpp
300301
)
301302
endif()
@@ -331,6 +332,7 @@ if(NOT MSVC)
331332
endif()
332333

333334
target_compile_definitions(codegen_internal PRIVATE "-DTORCH_CUDA_BUILD_MAIN_LIB")
335+
target_include_directories(codegen_internal PUBLIC ${NVFUSER_PYTHON_DIR})
334336
target_include_directories(codegen_internal SYSTEM PUBLIC
335337
${CMAKE_SOURCE_DIR}/third_party/flatbuffers/include
336338
PRIVATE
@@ -457,31 +459,32 @@ if(BUILD_PYTHON)
457459
# nvfuser python API sources
458460
set(NVFUSER_PYTHON_SRCS)
459461
list(APPEND NVFUSER_PYTHON_SRCS
460-
${NVFUSER_SRCS_DIR}/python_frontend/multidevice_bindings.cpp
461-
${NVFUSER_SRCS_DIR}/python_frontend/python_bindings.cpp
462-
${NVFUSER_SRCS_DIR}/python_frontend/python_bindings_extension.cpp
463-
${NVFUSER_SRCS_DIR}/python_frontend/schedule_bindings.cpp
462+
${NVFUSER_PYTHON_DIR}/python_frontend/multidevice_bindings.cpp
463+
${NVFUSER_PYTHON_DIR}/python_frontend/python_bindings.cpp
464+
${NVFUSER_PYTHON_DIR}/python_frontend/python_bindings_extension.cpp
465+
${NVFUSER_PYTHON_DIR}/python_frontend/schedule_bindings.cpp
464466
)
465467

466468
add_library(nvf_py_internal OBJECT ${NVFUSER_PYTHON_SRCS})
469+
target_include_directories(nvf_py_internal PUBLIC ${NVFUSER_PYTHON_DIR})
467470
target_include_directories(nvf_py_internal SYSTEM INTERFACE
468471
${CMAKE_SOURCE_DIR}/third_party/flatbuffers/include
469472
)
470473

471474
# setup python API version
472475
add_custom_command(
473-
OUTPUT ${NVFUSER_ROOT}/nvfuser/version.py
476+
OUTPUT ${NVFUSER_PYTHON_DIR}/nvfuser/version.py
474477
COMMAND
475-
"${PYTHON_EXECUTABLE}" -c \"from pathlib import Path\; Path('${NVFUSER_ROOT}/tools/gen_nvfuser_version.py') .touch() \"
478+
"${PYTHON_EXECUTABLE}" -c \"from pathlib import Path\; Path('${NVFUSER_PYTHON_DIR}/tools/gen_nvfuser_version.py') .touch() \"
476479
COMMAND
477-
"${PYTHON_EXECUTABLE}" ${NVFUSER_ROOT}/tools/gen_nvfuser_version.py
478-
DEPENDS ${NVFUSER_ROOT}/tools/gen_nvfuser_version.py
479-
DEPENDS ${NVFUSER_ROOT}/version.txt
480+
"${PYTHON_EXECUTABLE}" ${NVFUSER_PYTHON_DIR}/tools/gen_nvfuser_version.py
481+
DEPENDS ${NVFUSER_PYTHON_DIR}/tools/gen_nvfuser_version.py
482+
DEPENDS ${NVFUSER_PYTHON_DIR}/version.txt
480483
WORKING_DIRECTORY ${NVFUSER_ROOT}/tools/
481484
)
482485
add_custom_target(
483486
gen_nvfuser_version ALL
484-
DEPENDS ${NVFUSER_ROOT}/nvfuser/version.py
487+
DEPENDS ${NVFUSER_PYTHON_DIR}/nvfuser/version.py
485488
)
486489
add_dependencies(nvf_py_internal gen_nvfuser_version)
487490
@@ -738,9 +741,9 @@ if(BUILD_TEST)
738741
if(BUILD_PYTHON)
739742
set(PY_FRONTEND_TEST_SRCS)
740743
list(APPEND PY_FRONTEND_TEST_SRCS
741-
${NVFUSER_ROOT}/tests/cpp/python_frontend/test_nvfuser_fusion_cache.cpp
742-
${NVFUSER_ROOT}/tests/cpp/python_frontend/test_nvfuser_fusion_definition.cpp
743-
${NVFUSER_ROOT}/tests/cpp/python_frontend/test_nvfuser_fusion_record.cpp
744+
${NVFUSER_PYTHON_DIR}/tests/python_frontend/test_nvfuser_fusion_cache.cpp
745+
${NVFUSER_PYTHON_DIR}/tests/python_frontend/test_nvfuser_fusion_definition.cpp
746+
${NVFUSER_PYTHON_DIR}/tests/python_frontend/test_nvfuser_fusion_record.cpp
744747
)
745748
add_test(test_python_frontend "${PY_FRONTEND_TEST_SRCS}" "")
746749
list(APPEND TEST_BINARIES test_python_frontend)

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel", "ninja", "cmake>=3.18"]
3+
build-backend = "setuptools.build_meta"
4+

python/LICENSE

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
Copyright (c) 2023- NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
3+
From PyTorch:
4+
5+
Copyright (c) 2016- Facebook, Inc (Adam Paszke)
6+
Copyright (c) 2014- Facebook, Inc (Soumith Chintala)
7+
Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert)
8+
Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu)
9+
Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu)
10+
Copyright (c) 2011-2013 NYU (Clement Farabet)
11+
Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston)
12+
Copyright (c) 2006 Idiap Research Institute (Samy Bengio)
13+
Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz)
14+
15+
From Caffe2:
16+
17+
Copyright (c) 2016-present, Facebook Inc. All rights reserved.
18+
19+
All contributions by Facebook:
20+
Copyright (c) 2016 Facebook Inc.
21+
22+
All contributions by Google:
23+
Copyright (c) 2015 Google Inc.
24+
All rights reserved.
25+
26+
All contributions by Yangqing Jia:
27+
Copyright (c) 2015 Yangqing Jia
28+
All rights reserved.
29+
30+
All contributions by Kakao Brain:
31+
Copyright 2019-2020 Kakao Brain
32+
33+
All contributions by Cruise LLC:
34+
Copyright (c) 2022 Cruise LLC.
35+
All rights reserved.
36+
37+
All contributions from Caffe:
38+
Copyright(c) 2013, 2014, 2015, the respective contributors
39+
All rights reserved.
40+
41+
All other contributions:
42+
Copyright(c) 2015, 2016 the respective contributors
43+
All rights reserved.
44+
45+
Caffe2 uses a copyright model similar to Caffe: each contributor holds
46+
copyright over their contributions to Caffe2. The project versioning records
47+
all such contribution and copyright details. If a contributor wants to further
48+
mark their specific copyright on a particular contribution, they should
49+
indicate their copyright solely in the commit message of the change when it is
50+
committed.
51+
52+
All rights reserved.
53+
54+
Redistribution and use in source and binary forms, with or without
55+
modification, are permitted provided that the following conditions are met:
56+
57+
1. Redistributions of source code must retain the above copyright
58+
notice, this list of conditions and the following disclaimer.
59+
60+
2. Redistributions in binary form must reproduce the above copyright
61+
notice, this list of conditions and the following disclaimer in the
62+
documentation and/or other materials provided with the distribution.
63+
64+
3. Neither the names of Facebook, Deepmind Technologies, NYU, NEC Laboratories America
65+
and IDIAP Research Institute nor the names of its contributors may be
66+
used to endorse or promote products derived from this software without
67+
specific prior written permission.
68+
69+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
70+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
71+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
72+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
73+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
74+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
75+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
76+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
77+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
78+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
79+
POSSIBILITY OF SUCH DAMAGE.
File renamed without changes.

0 commit comments

Comments
 (0)