From b809be1acbd8b25581d26697418053371a4669e9 Mon Sep 17 00:00:00 2001 From: WangZhen <23097963+0x45f@users.noreply.github.com> Date: Wed, 13 Jul 2022 10:02:24 +0800 Subject: [PATCH] Support zero dims input for eager run program OP (#44273) --- .../eager/to_static/run_program_op_node.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/paddle/fluid/eager/to_static/run_program_op_node.h b/paddle/fluid/eager/to_static/run_program_op_node.h index 4d08146f7aa..2af2bd369b4 100644 --- a/paddle/fluid/eager/to_static/run_program_op_node.h +++ b/paddle/fluid/eager/to_static/run_program_op_node.h @@ -58,13 +58,14 @@ static void CheckInputVarStatus(const Tensor &tensor) { "wrong type. Expect type is DenseTensor.", tensor.name())); - PADDLE_ENFORCE_EQ(tensor.initialized(), - true, - paddle::platform::errors::InvalidArgument( - "The tensor in input tensor %s of " - "RunProgram(Grad)Op " - "is not initialized.", - tensor.name())); + PADDLE_ENFORCE_EQ( + static_cast(tensor.impl().get())->IsInitialized(), + true, + paddle::platform::errors::InvalidArgument( + "The tensor in input tensor %s of " + "RunProgram(Grad)Op " + "is not initialized.", + tensor.name())); } static void CheckOutputVarStatus(const paddle::framework::Variable &src_var, @@ -84,7 +85,7 @@ static void CheckOutputVarStatus(const paddle::framework::Variable &src_var, "RunProgram(Grad)Op's internal scope holds " "wrong type. Expect type is DenseTensor", name)); - PADDLE_ENFORCE_EQ(src_tensor.initialized(), + PADDLE_ENFORCE_EQ(src_tensor.IsInitialized(), true, paddle::platform::errors::InvalidArgument( "The tensor in output tensor %s get from " @@ -120,7 +121,7 @@ static void ShareTensorsIntoScope(const std::vector &tensors, paddle::framework::Scope *scope) { for (size_t i = 0; i < tensors.size(); ++i) { auto name = tensors[i].name(); - if (name == "Fake_var" || !tensors[i].initialized()) { + if (name == "Fake_var") { continue; } auto *var = scope->Var(name); -- GitLab