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
aeb47792
"git@developer.sourcefind.cn:OpenDAS/mmdetection3d.git" did not exist on "90e63784f3d41909a713cf68ac381ee5fd94ff9a"
Commit
aeb47792
authored
Dec 19, 2017
by
rusty1s
Browse files
scatter add uses pytorch impl
parent
1270e840
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
34 deletions
+4
-34
torch_scatter/functions/__init__.py
torch_scatter/functions/__init__.py
+4
-2
torch_scatter/src/cpu.h
torch_scatter/src/cpu.h
+0
-16
torch_scatter/src/generic/cpu.c
torch_scatter/src/generic/cpu.c
+0
-16
No files found.
torch_scatter/functions/__init__.py
View file @
aeb47792
import
torch
from
.scatter
import
scatter
from
.scatter
import
scatter
from
.utils
import
gen_filled_tensor
,
gen_output
from
.utils
import
gen_filled_tensor
,
gen_output
...
@@ -5,7 +7,7 @@ from .utils import gen_filled_tensor, gen_output
...
@@ -5,7 +7,7 @@ from .utils import gen_filled_tensor, gen_output
def
scatter_add_
(
output
,
index
,
input
,
dim
=
0
):
def
scatter_add_
(
output
,
index
,
input
,
dim
=
0
):
"""If multiple indices reference the same location, their contributions
"""If multiple indices reference the same location, their contributions
add."""
add."""
return
scatter
(
'
add
'
,
dim
,
output
,
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
,
max_index
=
None
,
fill_value
=
0
):
...
@@ -16,7 +18,7 @@ def scatter_add(index, input, dim=0, max_index=None, fill_value=0):
...
@@ -16,7 +18,7 @@ def scatter_add(index, input, dim=0, max_index=None, fill_value=0):
def
scatter_sub_
(
output
,
index
,
input
,
dim
=
0
):
def
scatter_sub_
(
output
,
index
,
input
,
dim
=
0
):
"""If multiple indices reference the same location, their negated
"""If multiple indices reference the same location, their negated
contributions add."""
contributions add."""
return
scatter
(
'sub'
,
dim
,
output
,
index
,
input
)
return
output
.
scatter_add_
(
dim
,
index
,
-
input
)
def
scatter_sub
(
index
,
input
,
dim
=
0
,
max_index
=
None
,
fill_value
=
0
):
def
scatter_sub
(
index
,
input
,
dim
=
0
,
max_index
=
None
,
fill_value
=
0
):
...
...
torch_scatter/src/cpu.h
View file @
aeb47792
void
scatter_add_Float
(
int
dim
,
THFloatTensor
*
output
,
THLongTensor
*
index
,
THFloatTensor
*
input
);
void
scatter_add_Double
(
int
dim
,
THDoubleTensor
*
output
,
THLongTensor
*
index
,
THDoubleTensor
*
input
);
void
scatter_add_Byte
(
int
dim
,
THByteTensor
*
output
,
THLongTensor
*
index
,
THByteTensor
*
input
);
void
scatter_add_Char
(
int
dim
,
THCharTensor
*
output
,
THLongTensor
*
index
,
THCharTensor
*
input
);
void
scatter_add_Short
(
int
dim
,
THShortTensor
*
output
,
THLongTensor
*
index
,
THShortTensor
*
input
);
void
scatter_add_Int
(
int
dim
,
THIntTensor
*
output
,
THLongTensor
*
index
,
THIntTensor
*
input
);
void
scatter_add_Long
(
int
dim
,
THLongTensor
*
output
,
THLongTensor
*
index
,
THLongTensor
*
input
);
void
scatter_sub_Float
(
int
dim
,
THFloatTensor
*
output
,
THLongTensor
*
index
,
THFloatTensor
*
input
);
void
scatter_sub_Double
(
int
dim
,
THDoubleTensor
*
output
,
THLongTensor
*
index
,
THDoubleTensor
*
input
);
void
scatter_sub_Byte
(
int
dim
,
THByteTensor
*
output
,
THLongTensor
*
index
,
THByteTensor
*
input
);
void
scatter_sub_Char
(
int
dim
,
THCharTensor
*
output
,
THLongTensor
*
index
,
THCharTensor
*
input
);
void
scatter_sub_Short
(
int
dim
,
THShortTensor
*
output
,
THLongTensor
*
index
,
THShortTensor
*
input
);
void
scatter_sub_Int
(
int
dim
,
THIntTensor
*
output
,
THLongTensor
*
index
,
THIntTensor
*
input
);
void
scatter_sub_Long
(
int
dim
,
THLongTensor
*
output
,
THLongTensor
*
index
,
THLongTensor
*
input
);
void
scatter_mul_Float
(
int
dim
,
THFloatTensor
*
output
,
THLongTensor
*
index
,
THFloatTensor
*
input
);
void
scatter_mul_Float
(
int
dim
,
THFloatTensor
*
output
,
THLongTensor
*
index
,
THFloatTensor
*
input
);
void
scatter_mul_Double
(
int
dim
,
THDoubleTensor
*
output
,
THLongTensor
*
index
,
THDoubleTensor
*
input
);
void
scatter_mul_Double
(
int
dim
,
THDoubleTensor
*
output
,
THLongTensor
*
index
,
THDoubleTensor
*
input
);
void
scatter_mul_Byte
(
int
dim
,
THByteTensor
*
output
,
THLongTensor
*
index
,
THByteTensor
*
input
);
void
scatter_mul_Byte
(
int
dim
,
THByteTensor
*
output
,
THLongTensor
*
index
,
THByteTensor
*
input
);
...
...
torch_scatter/src/generic/cpu.c
View file @
aeb47792
...
@@ -2,22 +2,6 @@
...
@@ -2,22 +2,6 @@
#define TH_GENERIC_FILE "generic/cpu.c"
#define TH_GENERIC_FILE "generic/cpu.c"
#else
#else
void
scatter_
(
add
)(
int
dim
,
THTensor
*
output
,
THLongTensor
*
index
,
THTensor
*
input
)
{
TH_TENSOR_DIM_APPLY3
(
real
,
output
,
int64_t
,
index
,
real
,
input
,
dim
,
TH_TENSOR_DIM_APPLY3_SIZE_EQ_EXCEPT_DIM
,
for
(
int64_t
i
=
0
;
i
<
THLongTensor_size
(
index
,
dim
);
i
++
)
{
assertIndexInBoundaries
(
index_data
[
i
],
output_size
,
TH_TENSOR_DIM_APPLY_counter
);
output_data
[
index_data
[
i
]]
+=
input_data
[
i
];
})
}
void
scatter_
(
sub
)(
int
dim
,
THTensor
*
output
,
THLongTensor
*
index
,
THTensor
*
input
)
{
TH_TENSOR_DIM_APPLY3
(
real
,
output
,
int64_t
,
index
,
real
,
input
,
dim
,
TH_TENSOR_DIM_APPLY3_SIZE_EQ_EXCEPT_DIM
,
for
(
int64_t
i
=
0
;
i
<
THLongTensor_size
(
index
,
dim
);
i
++
)
{
assertIndexInBoundaries
(
index_data
[
i
],
output_size
,
TH_TENSOR_DIM_APPLY_counter
);
output_data
[
index_data
[
i
]]
-=
input_data
[
i
];
})
}
void
scatter_
(
mul
)(
int
dim
,
THTensor
*
output
,
THLongTensor
*
index
,
THTensor
*
input
)
{
void
scatter_
(
mul
)(
int
dim
,
THTensor
*
output
,
THLongTensor
*
index
,
THTensor
*
input
)
{
TH_TENSOR_DIM_APPLY3
(
real
,
output
,
int64_t
,
index
,
real
,
input
,
dim
,
TH_TENSOR_DIM_APPLY3_SIZE_EQ_EXCEPT_DIM
,
TH_TENSOR_DIM_APPLY3
(
real
,
output
,
int64_t
,
index
,
real
,
input
,
dim
,
TH_TENSOR_DIM_APPLY3_SIZE_EQ_EXCEPT_DIM
,
for
(
int64_t
i
=
0
;
i
<
THLongTensor_size
(
index
,
dim
);
i
++
)
{
for
(
int64_t
i
=
0
;
i
<
THLongTensor_size
(
index
,
dim
);
i
++
)
{
...
...
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