Commit aa129522 authored by VoVAllen's avatar VoVAllen Committed by Minjie Wang
Browse files

[Bug Fix] Fix inplace op at backend (#546)

* Fix inplace operation

* fix line seprator
parent d533e9ba
......@@ -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 = nd.clip(w, a_min=1, a_max=np.inf)
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
def boolean_mask(input, mask):
......
......@@ -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 = w.clamp(min=1) # remove 0 entries
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
def boolean_mask(input, mask):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment