MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / CanMergeSplit

Function CanMergeSplit

oneflow/core/framework/sbp_infer_util.cpp:397–404  ·  view source on GitHub ↗

We can not just simply merging two same split For example, shape = [6], we are trying to merge [2, 2]: (S0, S0) -> [4]: S0 For each rank, [4]: S0 has number of data: 2, 2, 1, 1 For each rank, [2]: S0 has number of data: 3, 3 For each rank, [2, 2]: (S0, S0) has number of data: 2, 1, 2, 1 Thus {[2, 2]: (S0, S0)} != {[4]: S0} for shape [6] However {[2, 2]: (S0, S0)} == {[4]: S0} for shape [4], [5], [

Source from the content-addressed store, hash-verified

395// More specifically, {[a, b]: (Si, Si)} == {[a*b]: Si} if and only if
396// shape value % (a * b) == 0, 1, a*b - 1
397bool CanMergeSplit(int32_t shape_value, int32_t merged_split_hierarchy_value) {
398 int32_t remainder = shape_value % merged_split_hierarchy_value;
399 if (remainder <= 1 || remainder == merged_split_hierarchy_value - 1) {
400 return true;
401 } else {
402 return false;
403 }
404}
405
406} // namespace
407

Callers 2

NdSbpsDimReduceFunction · 0.85
InOutParallelDimReduceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected