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
143a57ec
Commit
143a57ec
authored
Dec 17, 2017
by
rusty1s
Browse files
searching for bug
parent
28f42bdc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
test/test_max.py
test/test_max.py
+2
-1
torch_scatter/src/generic/cpu.c
torch_scatter/src/generic/cpu.c
+6
-2
No files found.
test/test_max.py
View file @
143a57ec
...
@@ -6,7 +6,8 @@ from torch_scatter import scatter_max_, scatter_max
...
@@ -6,7 +6,8 @@ from torch_scatter import scatter_max_, scatter_max
from
.utils
import
tensor_strs
,
Tensor
from
.utils
import
tensor_strs
,
Tensor
@
pytest
.
mark
.
parametrize
(
'str'
,
tensor_strs
)
# @pytest.mark.parametrize('str', tensor_strs)
@
pytest
.
mark
.
parametrize
(
'str'
,
[
'DoubleTensor'
])
def
test_scatter_mean
(
str
):
def
test_scatter_mean
(
str
):
input
=
[[
2
,
0
,
1
,
4
,
3
],
[
0
,
2
,
1
,
3
,
4
]]
input
=
[[
2
,
0
,
1
,
4
,
3
],
[
0
,
2
,
1
,
3
,
4
]]
index
=
[[
4
,
5
,
4
,
2
,
3
],
[
0
,
0
,
2
,
2
,
1
]]
index
=
[[
4
,
5
,
4
,
2
,
3
],
[
0
,
0
,
2
,
2
,
1
]]
...
...
torch_scatter/src/generic/cpu.c
View file @
143a57ec
...
@@ -65,10 +65,14 @@ void scatter_(min)(int dim, THTensor *output, THLongTensor *index, THTensor *inp
...
@@ -65,10 +65,14 @@ void scatter_(min)(int dim, THTensor *output, THLongTensor *index, THTensor *inp
})
})
}
}
void
index_backward
(
int
dim
,
THTensor
*
output
,
THLongTensor
*
index
,
THTensor
*
grad
,
THLongTensor
*
grad_index
)
{
void
index_backward
(
int
dim
,
THTensor
*
output
,
THLongTensor
*
index
,
THTensor
*
grad
,
THLongTensor
*
grad_index
)
{
TH_TENSOR_DIM_APPLY4
(
real
,
output
,
int64_t
,
index
,
real
,
grad
,
int64_t
,
grad_index
,
dim
,
TH_TENSOR_DIM_APPLY4
(
real
,
output
,
int64_t
,
index
,
real
,
grad
,
int64_t
,
grad_index
,
dim
,
for
(
int64_t
i
=
0
;
i
<
THLongTensor_size
(
index
,
dim
);
i
++
)
{
for
(
int64_t
i
=
0
;
i
<
THLongTensor_size
(
index
,
dim
);
i
++
)
{
if
(
grad_index_data
[
index_data
[
i
]]
==
i
)
output_data
[
index_data
[
i
]]
=
grad_data
[
i
];
int64_t
idx
=
*
(
index_data
+
i
*
index_stride
);
/* if (grad_index_data[index_data[i]] == i) { */
/* printf("i: %i, ", i); */
/* output_data[i] = grad_data[idx]; */
/* } */
})
})
}
}
...
...
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