From 6410989ca756c15e6ccda488ee3a4cd98f9b24d2 Mon Sep 17 00:00:00 2001 From: JackCaoG <59073027+JackCaoG@users.noreply.github.com> Date: Fri, 28 Jun 2024 15:30:28 -0700 Subject: [PATCH] should_donate should not propagate to the output data (#7585) --- test/dynamo/test_dynamo_aliasing.py | 1 + torch_xla/csrc/xla_graph_executor.cpp | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/test/dynamo/test_dynamo_aliasing.py b/test/dynamo/test_dynamo_aliasing.py index d8ee6c811bd2..5891def1dbc8 100644 --- a/test/dynamo/test_dynamo_aliasing.py +++ b/test/dynamo/test_dynamo_aliasing.py @@ -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() diff --git a/torch_xla/csrc/xla_graph_executor.cpp b/torch_xla/csrc/xla_graph_executor.cpp index 0cbb21c4439b..3e7004d4f635 100644 --- a/torch_xla/csrc/xla_graph_executor.cpp +++ b/torch_xla/csrc/xla_graph_executor.cpp @@ -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(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());