Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torch-scatter
Commits
06192594
Commit
06192594
authored
Dec 21, 2017
by
rusty1s
Browse files
beginning of docs
parent
f013eb53
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
265 additions
and
65 deletions
+265
-65
README.md
README.md
+18
-0
docs/Makefile
docs/Makefile
+14
-0
docs/source/conf.py
docs/source/conf.py
+150
-0
docs/source/index.rst
docs/source/index.rst
+15
-0
setup.py
setup.py
+1
-1
torch_scatter/functions/__init__.py
torch_scatter/functions/__init__.py
+1
-64
torch_scatter/functions/add.py
torch_scatter/functions/add.py
+66
-0
No files found.
README.md
View file @
06192594
# PyTorch Scatter
# PyTorch Scatter
```
sh
pip
install
torch_scatter
```
```
py
from
torch_scatter
import
scatter_max
input
=
torch
.
Tensor
([[
2
,
0
,
1
,
4
,
3
],
[
0
,
2
,
1
,
3
,
4
]])
torch
.
LongTensor
([[
4
,
5
,
2
,
3
],
[
0
,
0
,
2
,
2
,
1
]])
max
,
arg
=
scatter_max_
(
index
,
input
,
dim
=
1
)
```
## Features
*
CPU and Cuda implementation
*
Backward implementation
docs/Makefile
0 → 100644
View file @
06192594
SPHINXOPTS
=
SPHINXBUILD
=
sphinx-build
SPHINXPROJ
=
pytorch_scatter
SOURCEDIR
=
source
BUILDDIR
=
build
# Put it first so that `make` without argument is like `make help`.
help
:
@
$(SPHINXBUILD)
-M
help
"
$(SOURCEDIR)
"
"
$(BUILDDIR)
"
$(SPHINXOPTS)
$(O)
.PHONY
:
help Makefile
%
:
Makefile
@
$(SPHINXBUILD)
-M
$@
"
$(SOURCEDIR)
"
"
$(BUILDDIR)
"
$(SPHINXOPTS)
$(O)
docs/source/conf.py
0 → 100644
View file @
06192594
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import
os
import
sys
import
datetime
import
sphinx_rtd_theme
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
'../..'
))
# -- General configuration ------------------------------------------------
extensions
=
[
'sphinx.ext.autodoc'
,
'sphinx.ext.autosummary'
,
'sphinx.ext.doctest'
,
'sphinx.ext.intersphinx'
,
'sphinx.ext.todo'
,
'sphinx.ext.coverage'
,
'sphinx.ext.mathjax'
,
'sphinx.ext.napoleon'
,
'sphinx.ext.viewcode'
,
'sphinx.ext.githubpages'
,
]
templates_path
=
[
'_templates'
]
source_suffix
=
'.rst'
master_doc
=
'index'
# General information about the project.
project
=
'pytorch_scatter'
copyright
=
'{}, Matthias Fey'
.
format
(
datetime
.
datetime
.
now
().
year
)
author
=
'Matthias Fey'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version
=
'0.1.0'
# The full version, including alpha/beta/rc tags.
release
=
'0.1.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language
=
None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns
=
[]
# The name of the Pygments (syntax highlighting) style to use.
pygments_style
=
'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos
=
True
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme
=
'sphinx_rtd_theme'
html_theme_path
=
[
sphinx_rtd_theme
.
get_html_theme_path
()]
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options
=
{
'collapse_navigation'
:
False
,
'display_version'
:
True
,
'logo_only'
:
True
,
}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_logo = '_static/img/logo.svg'
# html_static_path = ['_static']
# html_context = {'css_files': ['_static/css/custom.css']}
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars
=
{
'**'
:
[
'relations.html'
,
# needs 'show_related': True theme option to display
'searchbox.html'
,
]
}
# -- Options for HTMLHelp output ------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename
=
'pytorch_scatter_doc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements
=
{
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents
=
[
(
master_doc
,
'pytorch_scatter.tex'
,
'pytorch
\\
_scatter Documentation'
,
'Matthias Fey'
,
'manual'
),
]
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages
=
[(
master_doc
,
'pytorch_scatter'
,
'pytorch_scatter Documentation'
,
[
author
],
1
)]
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents
=
[
(
master_doc
,
'pytorch_scatter'
,
'pytorch_scatter Documentation'
,
author
,
'pytorch_scatter'
,
'One line description of project.'
,
'Miscellaneous'
),
]
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping
=
{
'https://docs.python.org/'
:
None
}
docs/source/index.rst
0 → 100644
View file @
06192594
:github_url: https://github.com/rusty1s/pytorch_scatter
PyTorch Scatter documentation
===============================
.. toctree::
:glob:
:maxdepth: 1
:caption: PackageReference
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
setup.py
View file @
06192594
...
@@ -17,7 +17,7 @@ setup(
...
@@ -17,7 +17,7 @@ setup(
author_email
=
'matthias.fey@tu-dortmund.de'
,
author_email
=
'matthias.fey@tu-dortmund.de'
,
install_requires
=
install_requires
,
install_requires
=
install_requires
,
setup_requires
=
setup_requires
,
setup_requires
=
setup_requires
,
tests_require
=
tests_require
,
tests_require
=
tests_require
+
docs_require
,
packages
=
find_packages
(
exclude
=
[
'build'
]),
packages
=
find_packages
(
exclude
=
[
'build'
]),
ext_package
=
''
,
ext_package
=
''
,
cffi_modules
=
[
osp
.
join
(
osp
.
dirname
(
__file__
),
'build.py:ffi'
)],
)
cffi_modules
=
[
osp
.
join
(
osp
.
dirname
(
__file__
),
'build.py:ffi'
)],
)
torch_scatter/functions/__init__.py
View file @
06192594
from
.scatter
import
scatter
from
.scatter
import
scatter
from
.utils
import
gen_filled_tensor
,
gen_output
from
.utils
import
gen_filled_tensor
,
gen_output
from
.add
import
scatter_add_
,
scatter_add
def
scatter_add_
(
output
,
index
,
input
,
dim
=
0
):
""" -> Tensor
Sums up all values from the tensor :attr:`input` into :attr:`output` at
the indices specified in the :attr:`index` tensor along an given axis
:attr:`dim`. For each value in :attr:`input`, its output index is specified
by its index in :attr:`input` for dimension != :attr:`dim` and by the
corresponding value in :attr:`index` for dimension = :attr:`dim`. If
multiple indices reference the same location, their contributions add.
If :attr:`input` and :attr:`index` are n-dimensional tensors with size
:math:`(x_0, ..., x_{i-1}, x_i, x_{i+1}, ..., x_{n-1})` and
:attr:`dim` = i, then :attr:`output` must be an n-dimensional tensor with
size :math:`(x_0, ..., x_{i-1}, y, x_{i+1}, ..., x_{n-1})`. Moreover, the
values of :attr:`index` must be between `0` and `output.size(dim) - 1`.
For one-dimensional tensors, the operation computes
:math:`output_i = output_i + \sum_j input_j`, where sum is over
:math:`j` such that :math:`index_j = i`.
Args:
output (Tensor): The destination tensor
index (LongTensor): The indices of elements to scatter
input (Tensor): The source tensor
dim (int, optional): The axis along which to index
Example::
>> input = torch.Tensor([[2, 0, 1, 4, 3], [0,2, 1, 3, 4]])
>> index = torch.LongTensor([[4, 5, 2, 3], [0, 0, 2, 2, 1]])
>> output = torch.zeros(2, 6)
>> scatter_add_(output, index, input, dim=1)
0 0 4 3 3 0
2 4 4 0 0 0
[torch.FloatTensor of size 2x6]
"""
return
output
.
scatter_add_
(
dim
,
index
,
input
)
def
scatter_add
(
index
,
input
,
dim
=
0
,
size
=
None
,
fill_value
=
0
):
""" -> Tensor
Sums ap all values from the tensor :attr:`input` at the indices
specified in the :attr:`index` tensor along an given axis :attr:`dim`.
The output size at dimension :attr:`dim` is given by :attr:`size` and must
be at least size `index.max(dim) - 1`. If :attr:`size` is not given, a
minimal sized output tensor is returned. The output tensor is initially
filled with the specified value at :attr:`fill_value`.
For one-dimensional tensors, the operation computes
:math:`output_i = fill_value + \sum_j input_j`, where sum is over
:math:`j` such that :math:`index_j = i`.
A more detailed explanation is described in :meth:`~scatter_add_`.
Args:
index (LongTensor): The indices of elements to scatter
input (Tensor): The source tensor
dim (int, optional): The axis along which to index
size (int, optional): Output size at dimension :attr:`dim`
fill_value (int, optional): Initial filling of output tensor
"""
output
=
gen_output
(
index
,
input
,
dim
,
size
,
fill_value
)
return
scatter_add_
(
output
,
index
,
input
,
dim
)
def
scatter_sub_
(
output
,
index
,
input
,
dim
=
0
):
def
scatter_sub_
(
output
,
index
,
input
,
dim
=
0
):
...
...
torch_scatter/functions/add.py
0 → 100644
View file @
06192594
from
.utils
import
gen_output
def
scatter_add_
(
output
,
index
,
input
,
dim
=
0
):
""" -> Tensor
Sums up all values from the tensor :attr:`input` into :attr:`output` at
the indices specified in the :attr:`index` tensor along an given axis
:attr:`dim`. For each value in :attr:`input`, its output index is specified
by its index in :attr:`input` for dimension != :attr:`dim` and by the
corresponding value in :attr:`index` for dimension = :attr:`dim`. If
multiple indices reference the same location, their contributions add.
If :attr:`input` and :attr:`index` are n-dimensional tensors with size
:math:`(x_0, ..., x_{i-1}, x_i, x_{i+1}, ..., x_{n-1})` and
:attr:`dim` = i, then :attr:`output` must be an n-dimensional tensor with
size :math:`(x_0, ..., x_{i-1}, y, x_{i+1}, ..., x_{n-1})`. Moreover, the
values of :attr:`index` must be between `0` and `output.size(dim) - 1`.
For one-dimensional tensors, the operation computes
:math:`output_i = output_i + \sum_j input_j`, where sum is over
:math:`j` such that :math:`index_j = i`.
Args:
output (Tensor): The destination tensor
index (LongTensor): The indices of elements to scatter
input (Tensor): The source tensor
dim (int, optional): The axis along which to index
Example::
>> input = torch.Tensor([[2, 0, 1, 4, 3], [0,2, 1, 3, 4]])
>> index = torch.LongTensor([[4, 5, 2, 3], [0, 0, 2, 2, 1]])
>> output = torch.zeros(2, 6)
>> scatter_add_(output, index, input, dim=1)
0 0 4 3 3 0
2 4 4 0 0 0
[torch.FloatTensor of size 2x6]
"""
return
output
.
scatter_add_
(
dim
,
index
,
input
)
def
scatter_add
(
index
,
input
,
dim
=
0
,
size
=
None
,
fill_value
=
0
):
""" -> Tensor
Sums ap all values from the tensor :attr:`input` at the indices
specified in the :attr:`index` tensor along an given axis :attr:`dim`.
The output size at dimension :attr:`dim` is given by :attr:`size` and must
be at least size `index.max(dim) - 1`. If :attr:`size` is not given, a
minimal sized output tensor is returned. The output tensor is initially
filled with the specified value at :attr:`fill_value`.
For one-dimensional tensors, the operation computes
:math:`output_i = fill_value + \sum_j input_j`, where sum is over
:math:`j` such that :math:`index_j = i`.
A more detailed explanation is described in :meth:`~scatter_add_`.
Args:
index (LongTensor): The indices of elements to scatter
input (Tensor): The source tensor
dim (int, optional): The axis along which to index
size (int, optional): Output size at dimension :attr:`dim`
fill_value (int, optional): Initial filling of output tensor
"""
output
=
gen_output
(
index
,
input
,
dim
,
size
,
fill_value
)
return
scatter_add_
(
output
,
index
,
input
,
dim
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment