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
dgl
Commits
aa129522
Commit
aa129522
authored
May 20, 2019
by
VoVAllen
Committed by
Minjie Wang
May 19, 2019
Browse files
[Bug Fix] Fix inplace op at backend (#546)
* Fix inplace operation * fix line seprator
parent
d533e9ba
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
python/dgl/backend/mxnet/tensor.py
python/dgl/backend/mxnet/tensor.py
+1
-1
python/dgl/backend/pytorch/tensor.py
python/dgl/backend/pytorch/tensor.py
+1
-1
No files found.
python/dgl/backend/mxnet/tensor.py
View file @
aa129522
...
@@ -185,7 +185,7 @@ def unsorted_1d_segment_mean(input, seg_id, n_segs, dim):
...
@@ -185,7 +185,7 @@ def unsorted_1d_segment_mean(input, seg_id, n_segs, dim):
w
=
unsorted_1d_segment_sum
(
n_ones
,
seg_id
,
n_segs
,
0
)
w
=
unsorted_1d_segment_sum
(
n_ones
,
seg_id
,
n_segs
,
0
)
w
=
nd
.
clip
(
w
,
a_min
=
1
,
a_max
=
np
.
inf
)
w
=
nd
.
clip
(
w
,
a_min
=
1
,
a_max
=
np
.
inf
)
y
=
unsorted_1d_segment_sum
(
input
,
seg_id
,
n_segs
,
dim
)
y
=
unsorted_1d_segment_sum
(
input
,
seg_id
,
n_segs
,
dim
)
y
/
=
w
.
reshape
((
-
1
,)
+
(
1
,)
*
(
y
.
ndim
-
1
))
y
=
y
/
w
.
reshape
((
-
1
,)
+
(
1
,)
*
(
y
.
ndim
-
1
))
return
y
return
y
def
boolean_mask
(
input
,
mask
):
def
boolean_mask
(
input
,
mask
):
...
...
python/dgl/backend/pytorch/tensor.py
View file @
aa129522
...
@@ -157,7 +157,7 @@ def unsorted_1d_segment_mean(input, seg_id, n_segs, dim):
...
@@ -157,7 +157,7 @@ def unsorted_1d_segment_mean(input, seg_id, n_segs, dim):
w
=
unsorted_1d_segment_sum
(
th
.
ones_like
(
seg_id
),
seg_id
,
n_segs
,
0
).
to
(
input
)
w
=
unsorted_1d_segment_sum
(
th
.
ones_like
(
seg_id
),
seg_id
,
n_segs
,
0
).
to
(
input
)
w
=
w
.
clamp
(
min
=
1
)
# remove 0 entries
w
=
w
.
clamp
(
min
=
1
)
# remove 0 entries
y
=
unsorted_1d_segment_sum
(
input
,
seg_id
,
n_segs
,
dim
)
y
=
unsorted_1d_segment_sum
(
input
,
seg_id
,
n_segs
,
dim
)
y
/
=
w
.
view
((
-
1
,)
+
(
1
,)
*
(
y
.
dim
()
-
1
))
y
=
y
/
w
.
view
((
-
1
,)
+
(
1
,)
*
(
y
.
dim
()
-
1
))
return
y
return
y
def
boolean_mask
(
input
,
mask
):
def
boolean_mask
(
input
,
mask
):
...
...
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