def BuildModeInitInstruction(builder): upstream_signature = op_attribute_pb.OpNodeSignature() parallel_conf = oneflow.placement.current_scope().default_parallel_conf op_conf.scope_symbol_id = oneflow.current_scope().symbol_id op_attribute = c_api_util.InferOpConf(op_conf, upstream_signature) builder.StatelessCall(op_attribute, parallel_conf, bn_in_op2blob_object=bn_in_op2blob_object)
def BuildModelInitInstruction(builder): upstream_signature = op_node_signature_pb.OpNodeSignature() op_conf.scope_symbol_id = oneflow.current_scope().symbol_id op_attribute = c_api_util.InferOpConf(op_conf, upstream_signature) parallel_conf = ( oneflow.current_scope().device_parallel_desc_symbol.parallel_conf) builder.StatelessCall(op_attribute, parallel_conf, bn_in_op2blob_object=bn_in_op2blob_object)
def BuildModelInitInstruction(builder): upstream_signature = op_node_signature_pb.OpNodeSignature() op_conf.scope_symbol_id = oneflow.current_scope().symbol_id op_attribute = c_api_util.InferOpConf(op_conf, upstream_signature) parallel_conf = ( oneflow.current_scope().device_parallel_desc_symbol.parallel_conf) cfg_op_attribute = oneflow_api.deprecated.MakeOpAttributeByString( str(op_attribute)) builder.StatelessCall(cfg_op_attribute, parallel_conf, bn_in_op2blob_object, boxing_util.BoxingTo)
def _MakeNewBlobObjectLike(builder, blob_object, new_parallel_desc_symbol): op_conf = op_conf_pb.OperatorConf() op_conf.name = id_util.UniqueStr("Input") op_conf.device_tag = new_parallel_desc_symbol.device_tag op_conf.input_conf.out = "out" blob_object.op_arg_parallel_attr.DumpToToInterfaceBlobConf( op_conf.input_conf.blob_conf) blob_object.op_arg_blob_attr.DumpToToInterfaceBlobConf( op_conf.input_conf.blob_conf) op_conf.scope_symbol_id = oneflow.current_scope().symbol_id upstream_signature = op_attribute_pb.OpNodeSignature() op_attribute = c_api_util.InferOpConf(op_conf, upstream_signature) parallel_conf = new_parallel_desc_symbol.parallel_conf bn_in_op2blob_object = {} builder.BoxingStatelessCall(op_attribute, parallel_conf, bn_in_op2blob_object=bn_in_op2blob_object) return bn_in_op2blob_object["out"]
def _MakeNewBlobObjectLike(builder, blob_object, new_parallel_desc_symbol): op_conf = op_conf_pb.OperatorConf() op_conf.name = id_util.UniqueStr("Input") op_conf.device_tag = new_parallel_desc_symbol.device_tag op_conf.input_conf.out = "out" cfg_interface_blob_conf = ( oneflow_api.oneflow.core.operator.interface_blob_conf.InterfaceBlobConf() ) blob_object.op_arg_parallel_attr.DumpToInterfaceBlobConf(cfg_interface_blob_conf) blob_object.op_arg_blob_attr.DumpToInterfaceBlobConf(cfg_interface_blob_conf) text_format.Parse(str(cfg_interface_blob_conf), op_conf.input_conf.blob_conf) op_conf.scope_symbol_id = oneflow.current_scope().symbol_id upstream_signature = op_node_signature_pb.OpNodeSignature() op_attribute = c_api_util.InferOpConf(op_conf, upstream_signature) parallel_conf = new_parallel_desc_symbol.parallel_conf bn_in_op2blob_object = oneflow_api.deprecated.BnInOp2BlobObject() builder.RawStatelessCall( op_attribute, parallel_conf, bn_in_op2blob_object=bn_in_op2blob_object ) return bn_in_op2blob_object["out"]
def Infer(op_conf, ibn2blob_object, scope_symbol_id=None): if scope_symbol_id is None: scope_symbol_id = oneflow.current_scope().symbol_id op_conf.scope_symbol_id = scope_symbol_id upstream_signature = MakeUpstreamSignature(ibn2blob_object) return c_api_util.InferOpConf(op_conf, upstream_signature)