def BuildFeedPathInstruction(builder): blob_object = bn_in_op2blob_object["out"] builder.FeedBlob(blob_object, python_callback.GetIdForRegisteredCallback(FeedPath)) builder.InsertRemoveForeignCallbackInstruction( blob_object.object_id, python_callback.GetIdForRegisteredCallback(FeedPath))
def BuildFetchBlobHeaderInstruction(builder): builder.FetchBlobHeader( blob_object, python_callback.GetIdForRegisteredCallback(fetcher) ) builder.InsertRemoveForeignCallbackInstruction( blob_object.object_id, python_callback.GetIdForRegisteredCallback(fetcher), )
def InsertRemoveForeignCallbackInstruction(self, object_id, callback): unique_callback_id = python_callback.GetIdForRegisteredCallback(callback) instruction = instr_util.InstructionProto() instruction.instr_type_name = "RemoveForeignCallback" instruction.operand.append(_DelObjectOperand(object_id)) instruction.operand.append(_Int64Operand(unique_callback_id)) self.instruction_list_.instruction.append(instruction)
def FeedBlob(self, blob_object, feeder): unique_callback_id = python_callback.GetIdForRegisteredCallback(feeder) instruction = instr_util.InstructionProto() device_tag = blob_object.parallel_desc_symbol.device_tag instruction.instr_type_name = "%s.%s" % (device_tag, "FeedBlob") instruction.parallel_desc_symbol_id = blob_object.parallel_desc_symbol.symbol_id instruction.operand.append(_Mut2Operand(blob_object.object_id)) instruction.operand.append(_Int64Operand(unique_callback_id)) self.instruction_list_.instruction.append(instruction)
def InsertRemoveForeignCallbackInstruction(self, object_id, callback): unique_callback_id = python_callback.GetIdForRegisteredCallback(callback) instruction = instr_cfg.InstructionProto() instruction.set_instr_type_name("RemoveForeignCallback") instruction.mutable_operand().Add().CopyFrom( oneflow_api.deprecated.vm.DelObjectOperand(object_id)) instruction.mutable_operand().Add().CopyFrom( oneflow_api.deprecated.vm.Int64Operand(unique_callback_id)) self.instruction_list().mutable_instruction().Add().CopyFrom(instruction)
def FeedBlob(self, blob_object, feeder): unique_callback_id = python_callback.GetIdForRegisteredCallback(feeder) instruction = instr_cfg.InstructionProto() device_tag = blob_object.parallel_desc_symbol.device_tag instruction.set_instr_type_name("%s.%s" % (device_tag, "FeedBlob")) instruction.set_parallel_desc_symbol_id( blob_object.parallel_desc_symbol.symbol_id) instruction.mutable_operand().Add().CopyFrom( oneflow_api.deprecated.vm.Mut2Operand(blob_object.object_id)) instruction.mutable_operand().Add().CopyFrom( oneflow_api.deprecated.vm.Int64Operand(unique_callback_id)) self.instruction_list().mutable_instruction().Add().CopyFrom(instruction)
def BuildFeedInstruction(builder): builder.FeedBlob(blob_object, python_callback.GetIdForRegisteredCallback(FeedBlob)) builder.InsertRemoveForeignCallbackInstruction( blob_object.object_id, python_callback.GetIdForRegisteredCallback(FeedBlob))