Skip to content

Commit

Permalink
should_donate should not propagate to the output data (pytorch#7585)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackCaoG authored Jun 28, 2024
1 parent 6d375f2 commit 6410989
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
1 change: 1 addition & 0 deletions test/dynamo/test_dynamo_aliasing.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def test_manual_buffer_donation(self):
self.assertEqual(met.counter_value('XlaSetBufferDonation'), 1)
dummy_inplace_add_compiled(input)
torch.allclose(input_cloned.cpu() + 1, input.cpu())
self.assertFalse(torch_xla._XLAC._get_buffer_donation(input))

def test_manual_buffer_donation_for_non_inplce_op(self):
device = xm.xla_device()
Expand Down
9 changes: 0 additions & 9 deletions torch_xla/csrc/xla_graph_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,15 +1038,6 @@ void XLAGraphExecutor::ExtractIRAndPrepareXlaData_(
runtime::GetComputationClient()->CreateDataPlaceholder(
tensor_device.toString(), std::move(shape));

// If current IR is a device data, executing the graph will generate a new
// Data with the same value. In this case we want to inherit the buffer
// donation option from the old Data.
auto device_data = torch_xla::DeviceData::Cast(ir_value.node.get());
if (device_data && device_data->get_buffer_donation()) {
std::dynamic_pointer_cast<runtime::ComputationClient::Data>(handle)
->set_should_donate_buffer(true);
}

tensor_data_vec.push_back(handle);
if (tensor->CurrentDataHandle() == nullptr && config.force_ltc_data) {
tensor->AssignIrValue(torch::lazy::Value());
Expand Down

0 comments on commit 6410989

Please sign in to comment.