Commit bb2d49f1 authored by rusty1s's avatar rusty1s
Browse files

initial commit

parent f458a21d
__pycache__/
_ext/
build/
dist/
.eggs/
*.egg-info/
Copyright (c) 2018 Matthias Fey <matthias.fey@tu-dortmund.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
include LICENSE
# PyTorch Cluster
--------------------------------------------------------------------------------
This package consists of a small extension library of highly optimised graph cluster algorithms for the use in [PyTorch](http://pytorch.org/).
All included operations work on varying data types and are implemented both for CPU and GPU.
## Installation
Check that `nvcc` is accessible from terminal, e.g. `nvcc --version`.
If not, add cuda (`/usr/local/cuda/bin`) to your `$PATH`.
Then run:
```
pip install cffi
python setup.py install
```
## Running tests
```
python setup.py test
```
import subprocess
import torch
from torch.utils.ffi import create_extension
headers = []
sources = []
include_dirs = ['torch_cluster/src']
define_macros = []
extra_objects = []
with_cuda = False
if torch.cuda.is_available():
subprocess.call('./build.sh') # Compile kernel.
headers += ['torch_cluster/src/cuda.h']
sources += ['torch_cluster/src/cuda.c']
include_dirs += ['torch_cluster/kernel']
define_macros += [('WITH_CUDA', None)]
extra_objects += ['torch_cluster/build/kernel.so']
with_cuda = True
ffi = create_extension(
name='torch_cluster._ext.ffi',
package=True,
headers=headers,
sources=sources,
include_dirs=include_dirs,
define_macros=define_macros,
extra_objects=extra_objects,
with_cuda=with_cuda,
relative_to=__file__)
if __name__ == '__main__':
ffi.build()
#!/bin/sh
TORCH=$(python -c "import os; import torch; print(os.path.dirname(torch.__file__))")
SRC_DIR=torch_unique/kernel
BUILD_DIR=torch_unique/build
mkdir -p $BUILD_DIR
nvcc -c -o $BUILD_DIR/kernel.so $SRC_DIR/kernel.cu -arch=sm_35 -Xcompiler -fPIC -shared -I$TORCH/lib/include/TH -I$TORCH/lib/include/THC -I$SRC_DIR
[metadata]
description-file = README.md
[aliases]
test = pytest
[tool:pytest]
addopts = --capture=no --cov
from os import path as osp
from setuptools import setup, find_packages
import build # noqa
__version__ = '0.1.0'
url = 'https://github.com/rusty1s/pytorch_cluster'
install_requires = ['cffi']
setup_requires = ['pytest-runner', 'cffi']
tests_require = ['pytest', 'pytest-cov']
setup(
name='torch_unique',
version=__version__,
description='PyTorch Geometric Deep Learning Graph Cluster Algorithms',
author='Matthias Fey',
author_email='matthias.fey@tu-dortmund.de',
url=url,
download_url='{}/archive/{}.tar.gz'.format(url, __version__),
keywords=['pytorch', 'cluster', 'geometric-deep-learning', 'graph'],
install_requires=install_requires,
setup_requires=setup_requires,
tests_require=tests_require,
packages=find_packages(exclude=['build']),
ext_package='',
cffi_modules=[osp.join(osp.dirname(__file__), 'build.py:ffi')],
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment