未验证 提交 383f1c4f 编写于 作者: Y Yuang Liu 提交者: GitHub

update the split logic for uniform (#47670)

上级 54bc3b46
...@@ -171,8 +171,10 @@ class SegmentLayers(object): ...@@ -171,8 +171,10 @@ class SegmentLayers(object):
def uniform(self, num_items, num_parts): def uniform(self, num_items, num_parts):
result = [0 for _ in range(num_parts + 1)] result = [0 for _ in range(num_parts + 1)]
part_size = math.floor(num_items / num_parts) part_size = math.floor(num_items / num_parts)
for i in range(num_parts): extra_layers = num_items % num_parts
result[i] = int(min(part_size * i, num_items)) for i in range(1, num_parts):
offset = 1 if i > (num_parts - extra_layers) else 0
result[i] = int(min(result[i - 1] + part_size + offset, num_items))
result[num_parts] = num_items result[num_parts] = num_items
return result return result
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册