mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Fix use of allow_tensor_metadata in view variable creation (#57069)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/57069 Test Plan: Imported from OSS Reviewed By: zou3519 Differential Revision: D28071507 Pulled By: albanD fbshipit-source-id: 44f0e09846fdc569cf1a62a6f80ca88911e7e45c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6fa1d880b6
commit
c91bd25e90
@ -625,6 +625,7 @@ inline Variable make_variable_differentiable_view(
|
||||
// allocation happens in view ops.
|
||||
if (data.getIntrusivePtr().unique() && data.getIntrusivePtr()->unique_version()) {
|
||||
at::TensorImpl* data_impl = data.unsafeGetTensorImpl();
|
||||
data_impl->set_allow_tensor_metadata_change(allow_tensor_metadata_change);
|
||||
data_impl->set_autograd_meta(std::make_unique<DifferentiableViewMeta>(
|
||||
data_impl, std::move(backward_info), std::move(forward_info),
|
||||
creation_meta));
|
||||
@ -632,7 +633,7 @@ inline Variable make_variable_differentiable_view(
|
||||
} else {
|
||||
c10::intrusive_ptr<at::TensorImpl> data_impl_copy = data.getIntrusivePtr()->shallow_copy_and_detach(
|
||||
/*version_counter=*/0,
|
||||
/*allow_tensor_metadata_change=*/true);
|
||||
/*allow_tensor_metadata_change=*/allow_tensor_metadata_change);
|
||||
data_impl_copy->set_autograd_meta(std::make_unique<DifferentiableViewMeta>(
|
||||
data_impl_copy.get(), std::move(backward_info), std::move(forward_info),
|
||||
creation_meta));
|
||||
|
Reference in New Issue
Block a user