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
eb438429
Commit
eb438429
authored
Dec 21, 2017
by
rusty1s
Browse files
docstring
parent
2ea9507b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
torch_scatter/functions/__init__.py
torch_scatter/functions/__init__.py
+21
-14
No files found.
torch_scatter/functions/__init__.py
View file @
eb438429
...
@@ -3,7 +3,9 @@ from .utils import gen_filled_tensor, gen_output
...
@@ -3,7 +3,9 @@ from .utils import gen_filled_tensor, gen_output
def
scatter_add_
(
output
,
index
,
input
,
dim
=
0
):
def
scatter_add_
(
output
,
index
,
input
,
dim
=
0
):
"""Sums up all values from the tensor :attr:`input` into :attr:`output` at
""" -> 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
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
: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
by its index in :attr:`input` for dimension != :attr:`dim` and by the
...
@@ -24,7 +26,7 @@ def scatter_add_(output, index, input, dim=0):
...
@@ -24,7 +26,7 @@ def scatter_add_(output, index, input, dim=0):
output (Tensor): The destination tensor
output (Tensor): The destination tensor
index (LongTensor): The indices of elements to scatter
index (LongTensor): The indices of elements to scatter
input (Tensor): The source tensor
input (Tensor): The source tensor
dim (int): The axis along which to index
dim (int
, optional
): The axis along which to index
Example::
Example::
>> input = torch.Tensor([[2, 0, 1, 4, 3], [0,2, 1, 3, 4]])
>> input = torch.Tensor([[2, 0, 1, 4, 3], [0,2, 1, 3, 4]])
...
@@ -38,25 +40,30 @@ def scatter_add_(output, index, input, dim=0):
...
@@ -38,25 +40,30 @@ def scatter_add_(output, index, input, dim=0):
return
output
.
scatter_add_
(
dim
,
index
,
input
)
return
output
.
scatter_add_
(
dim
,
index
,
input
)
def
scatter_add
(
index
,
input
,
dim
=
0
,
max_index
=
None
,
fill_value
=
0
):
def
scatter_add
(
index
,
input
,
dim
=
0
,
size
=
None
,
fill_value
=
0
):
"""Sums ap all values from the tensor :attr:`input` at the indices
""" -> 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`.
specified in the :attr:`index` tensor along an given axis :attr:`dim`.
The output size is given by :attr:`max_index` and must be at least size
The output size at dimension :attr:`dim` is given by :attr:`size` and must
`index.max(dim) - 1`. If `max_index` is not given, a minimal sized output
be at least size `index.max(dim) - 1`. If :attr:`size` is not given, a
tensor is returned. The output tensor is filled with :attr:`fill_value`
minimal sized output tensor is returned. The output tensor is initially
before scatter.
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 of the operation is described in
A more detailed explanation is described in :meth:`~scatter_add_`.
:meth:`~scatter_add_`.
Args:
Args:
index (LongTensor): The indices of elements to scatter
index (LongTensor): The indices of elements to scatter
input (Tensor): The source tensor
input (Tensor): The source tensor
dim (int): The axis along which to index
dim (int
, optional
): The axis along which to index
max_index (int
): Output size at dimension :attr:`dim`
size (int, optional
): Output size at dimension :attr:`dim`
fill_value (int
): Fill value of output before scatte
r
fill_value (int
, optional): Initial filling of output tenso
r
"""
"""
output
=
gen_output
(
index
,
input
,
dim
,
max_index
,
fill_value
)
output
=
gen_output
(
index
,
input
,
dim
,
size
,
fill_value
)
return
scatter_add_
(
output
,
index
,
input
,
dim
)
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