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 .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.vscode/
build/
*.egg-info/
*.pyc
*.so
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "torchsparse/backend/third_party/sparsehash"]
path = torchsparse/backend/third_party/sparsehash
url = https://github.com/sparsehash/sparsehash.git
1 change: 0 additions & 1 deletion cython_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"tqdm",
"typing-extensions",
"wheel",
"rootpath",
"attributedict",
],
cmdclass={"build_ext": BuildExtension},
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ tqdm
typing-extensions
wheel
attributedict
rootpath
43 changes: 31 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import glob
import os
from pathlib import Path
from subprocess import run

import torch
import torch.cuda
Expand All @@ -10,12 +12,11 @@
CppExtension,
CUDAExtension,
)
from torchsparse.version import __version__

# from torchsparse import __version__
print("torchsparse version:", __version__)

version_file = open("./torchsparse/version.py")
version = version_file.read().split("'")[1]
print("torchsparse version:", version)
build_ext = BuildExtension.with_options(no_python_abi_suffix=True, use_ninja=True)

if (torch.cuda.is_available() and CUDA_HOME is not None) or (
os.getenv("FORCE_CUDA", "0") == "1"
Expand All @@ -34,34 +35,52 @@
sources.append(fpath)

extension_type = CUDAExtension if device == "cuda" else CppExtension
current_dir = Path(__file__).parent.resolve()
sparsehash_dir = current_dir / "torchsparse" / "backend" / "third_party" / "sparsehash"
sparsehash_dir_inc = sparsehash_dir / "src"
sparseconfig_path = sparsehash_dir_inc / "sparsehash" / "internal" / "sparseconfig.h"

if not sparseconfig_path.exists():
print("Generating sparseconfig.h ...")
run(["./configure"], cwd=sparsehash_dir, check=True)
run(["make", "src/sparsehash/internal/sparseconfig.h"], cwd=sparsehash_dir, check=True)

extra_compile_args = {
"cxx": ["-g", "-O3", "-fopenmp", "-lgomp"],
"nvcc": ["-O3", "-std=c++17"],
"cxx": ["-O3", "-fopenmp", "-lgomp", f"-I{sparsehash_dir_inc}"],
"nvcc": ["-O3"],
}

setup(
name="torchsparse",
version=version,
version=__version__,
packages=find_packages(),
ext_modules=[
extension_type(
"torchsparse.backend", sources, extra_compile_args=extra_compile_args
)
],
url="https://github.com/mit-han-lab/torchsparse",
include_package_data=True,
install_requires=[
"ninja",
"numpy",
"backports.cached_property",
"tqdm",
"typing-extensions",
"wheel",
"rootpath",
"torch",
"torchvision"
],
dependency_links=[
'https://download.pytorch.org/whl/cu118'
],
cmdclass={"build_ext": BuildExtension},
cmdclass={"build_ext": build_ext},
zip_safe=False,
)

for f in [
"Makefile",
"config.log",
"config.status",
"src/config.h",
"src/sparsehash/internal/sparseconfig.h",
"src/stamp-h1",
]:
(sparsehash_dir / f).unlink(missing_ok=True)
1 change: 1 addition & 0 deletions torchsparse/backend/third_party/sparsehash
Submodule sparsehash added at 1dffea
2 changes: 0 additions & 2 deletions torchsparse/nn/functional/conv/utils/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
# IMPORT
# --------------------------------------

import rootpath

import collections

from . import compat
Expand Down
2 changes: 0 additions & 2 deletions torchsparse/nn/functional/conv/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
# DEPS
# --------------------------------------

import rootpath

# @see https://github.com/benjaminp/six/blob/master/six.py

import sys
Expand Down