Example #1
0
 def _UpdateInfo4LazyInterfaceOp(self):
     for op_attr in c_api_util.GetOpAttributes().op_attribute:
         op_conf = op_attr.op_conf
         if c_api_util.IsInterfaceOpConf(op_conf):
             self.interface_op_name2op_attr_[op_conf.name] = op_attr
     for job in c_api_util.GetJobSet().job:
         op_name2parallel_conf = {}
         for placement_group in job.placement.placement_group:
             for op_name in placement_group.op_set.op_name:
                 op_name2parallel_conf[
                     op_name] = placement_group.parallel_conf
         for op_conf in job.net.op:
             if c_api_util.IsInterfaceOpConf(op_conf):
                 self.interface_op_name2job_name_[
                     op_conf.name] = job.job_conf.job_name
                 self.lazy_interface_op_name2parallel_conf_[
                     op_conf.name] = op_name2parallel_conf[op_conf.name]
Example #2
0
def CurJobAddMirroredOp(op_conf, scope_symbol=None):
    assert not hob.consistent_view_enabled(None)
    if scope_symbol is None:
        scope_symbol = oneflow.current_scope()
    op_conf.scope_symbol_id = scope_symbol.symbol_id
    if not op_conf.HasField("device_tag"):
        device_tag = scope_symbol.device_parallel_desc_symbol.device_tag
        op_conf.device_tag = device_tag
    op_attr = c_api_util.CurJobBuildAndInferCtx_AddAndInferMirroredOp(op_conf)
    if c_api_util.IsInterfaceOpConf(op_conf):
        sess = session_ctx.GetDefaultSession()
        sess.AddInfo4InterfaceOpName(op_conf.name, op_attr)
    return op_attr