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

Function GetSubLogicalShape

oneflow/core/framework/placement_sbp_util.cpp:512–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510}
511
512Maybe<Shape> GetSubLogicalShape(Symbol<one::GlobalTensorMeta> tensor_meta,
513 Symbol<ParallelDesc> sub_parallel_desc, Symbol<NdSbp> sub_nd_sbp) {
514 CHECK_EQ_OR_RETURN(sub_nd_sbp->sbp_parallel_size(), 1); // NOLINT(maybe-need-error-msg)
515 const auto& logical_shape = tensor_meta->shape();
516 const auto& physical_shape =
517 JUST(GetPhysicalShape(logical_shape, tensor_meta->nd_sbp(), tensor_meta->parallel_desc()));
518
519 std::shared_ptr<Shape> sub_logical_shape = std::make_shared<Shape>(*physical_shape);
520 if (sub_nd_sbp->sbp_parallel(0).has_split_parallel()) {
521 const int64_t split_axis = sub_nd_sbp->sbp_parallel(0).split_parallel().axis();
522 sub_logical_shape->Set(split_axis, logical_shape.At(split_axis));
523 }
524 return sub_logical_shape;
525}
526
527Maybe<Symbol<one::GlobalTensorMeta>> CalcSubGlobalTensorMeta(
528 Symbol<one::GlobalTensorMeta> tensor_meta, Symbol<ParallelDesc> sub_parallel_desc,

Callers 1

CalcSubGlobalTensorMetaFunction · 0.85

Calls 6

GetPhysicalShapeFunction · 0.70
shapeMethod · 0.45
nd_sbpMethod · 0.45
parallel_descMethod · 0.45
SetMethod · 0.45
AtMethod · 0.45

Tested by

no test coverage detected