From 52009d199818e640e6d88de6188c68e02ec0767e Mon Sep 17 00:00:00 2001 From: niuliling123 <51102941+niuliling123@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:57:49 +0800 Subject: [PATCH] Update for SetOutDataLayout when VarType is EagerVariable (#46515) --- paddle/fluid/imperative/layout_transformer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddle/fluid/imperative/layout_transformer.h b/paddle/fluid/imperative/layout_transformer.h index 9689fffb67..555ec4170c 100644 --- a/paddle/fluid/imperative/layout_transformer.h +++ b/paddle/fluid/imperative/layout_transformer.h @@ -25,7 +25,7 @@ namespace imperative { template void SetOutDataLayout(std::shared_ptr var, const paddle::experimental::DataLayout layout) { - if (var != nullptr) { + if (var != nullptr && var->Var().IsInitialized()) { paddle::imperative::SetDataLayout(var, layout); // set out_tensor's layout if (var->MutableVar()->IsInitialized()) { -- GitLab