예제 #1
0
def BuildInitialScope(
    instruction_builder,
    session_id,
    job_conf,
    device_tag,
    machine_device_ids,
    is_mirrored,
):
    scope_proto = scope_cfg.ScopeProto()
    scope_proto.set_session_id(session_id)
    job_conf_sym = instruction_builder.GetJobConfSymbol(job_conf)
    scope_proto.set_job_desc_symbol_id(job_conf_sym.symbol_id)
    parallel_conf = MakeParallelConf(device_tag, machine_device_ids)
    device_parallel_desc_sym = instruction_builder.GetParallelDescSymbol(
        parallel_conf)
    scope_proto.set_device_parallel_desc_symbol_id(
        device_parallel_desc_sym.symbol_id)
    parallel_conf = MakeParallelConf("cpu", machine_device_ids)
    host_parallel_desc_sym = instruction_builder.GetParallelDescSymbol(
        parallel_conf)
    scope_proto.set_host_parallel_desc_symbol_id(
        host_parallel_desc_sym.symbol_id)
    if is_mirrored:
        scope_proto.mutable_opt_mirrored_parallel_conf(
        ).mutable_mirrored_parallel()
    else:
        scope_proto.mutable_opt_mirrored_parallel_conf(
        ).clear_mirrored_parallel()
    return instruction_builder.GetScopeSymbol(scope_proto)
예제 #2
0
 def _CloneScopeProto(self):
     scope_proto = scope_cfg.ScopeProto()
     scope_proto.CopyFrom(self.data)
     return scope_proto