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

Function ConstructAndInferOp

oneflow/core/operator/operator.cpp:1575–1600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1573} // namespace
1574
1575Maybe<Operator> ConstructAndInferOp(const OperatorConf& op_conf,
1576 const OpNodeSignature& upstream_signature, const Scope& scope) {
1577 const auto& parallel_desc = *JUST(scope.GetParallelDesc(op_conf));
1578 bool is_local = scope.opt_local_parallel_conf().has_local_parallel();
1579 const auto& op = JUST(ConstructOp(op_conf));
1580 JUST(CheckOpInputSignature(*op, upstream_signature));
1581 JUST(op->FillOpParallelDesc(parallel_desc));
1582 HashMap<std::string, std::unique_ptr<BlobDesc>> bn_in_op2blob_desc;
1583 for (const auto& ibn : op->input_bns()) {
1584 const auto& map = upstream_signature.logical_blob_desc_signature().bn_in_op2blob_desc();
1585 bn_in_op2blob_desc[ibn].reset(new BlobDesc(map.at(ibn)));
1586 }
1587 const auto& ConstBlobDesc4Ibn = [&](const std::string& ibn) -> const BlobDesc& {
1588 return *bn_in_op2blob_desc.at(ibn);
1589 };
1590 JUST(op->FillLogicalInBlobDesc(ConstBlobDesc4Ibn));
1591 // infer is_local
1592 JUST(InferLocalSignature(op.get(), upstream_signature, is_local, parallel_desc));
1593 SbpSignature sbp_sig_conf;
1594 // iner sbp
1595 JUST(InferOpOutSbpParallel(op.get(), upstream_signature, ConstBlobDesc4Ibn, sbp_sig_conf,
1596 parallel_desc));
1597 // infer logical blob_desc
1598 JUST(op->InferLogicalOutBlobDescsIf());
1599 return op;
1600}
1601
1602namespace {
1603

Callers

nothing calls this directly

Calls 11

ConstructOpFunction · 0.85
CheckOpInputSignatureFunction · 0.85
InferLocalSignatureFunction · 0.85
InferOpOutSbpParallelFunction · 0.85
FillOpParallelDescMethod · 0.80
FillLogicalInBlobDescMethod · 0.80
GetParallelDescMethod · 0.45
resetMethod · 0.45
atMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected