def EagerOpKernelForward(add_and_infer, op_conf, opkernel_object): op_attribute = add_and_infer(op_conf, opkernel_object.scope_symbol) op_executor.OpKernelCall(opkernel_object, op_attribute, blob_register) bw_blob_register = gradient_util.GetDefaultBackwardBlobRegister() gradient_util.TrySetBackwardUsedBlobObject(op_attribute, blob_register, bw_blob_register) return op_attribute
def EagerForward(add_and_infer, op_conf, scope_symbol=None): op_attribute = add_and_infer(op_conf, scope_symbol) parallel_conf = scope_symbol.device_parallel_desc_symbol.parallel_conf op_executor.Interpret(op_attribute, parallel_conf, blob_register) bw_blob_register = gradient_util.GetDefaultBackwardBlobRegister() gradient_util.TrySetBackwardUsedBlobObject(op_attribute, blob_register, bw_blob_register) return op_attribute
def MirroredCast(op_attribute_str, parallel_conf): op_attribute = text_format.Parse(op_attribute_str, op_attribute_pb.OpAttribute()) blob_register = oneflow_api.GetDefaultBlobRegister() is_cast_to_mirrored = op_attribute.op_conf.HasField("cast_to_mirrored_conf") is_cast_from_mirrored = op_attribute.op_conf.HasField("cast_from_mirrored_conf") assert is_cast_to_mirrored or is_cast_from_mirrored _MirroredCastAndAddOutputBlobReleaser(op_attribute, blob_register) bw_blob_register = gradient_util.GetDefaultBackwardBlobRegister() gradient_util.TrySetBackwardUsedBlobObject( op_attribute, blob_register, bw_blob_register )