From 3b5bb4ba5b72d6e08624a0631c3bf1ff37aa69ff Mon Sep 17 00:00:00 2001 From: kangguangli Date: Wed, 6 Sep 2023 19:59:53 +0800 Subject: [PATCH] fix place setting when translatring fill_constant (#56929) --- paddle/fluid/ir_adaptor/translator/op_translator.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/ir_adaptor/translator/op_translator.cc b/paddle/fluid/ir_adaptor/translator/op_translator.cc index e22fa5f3b37..86f31fd92ae 100644 --- a/paddle/fluid/ir_adaptor/translator/op_translator.cc +++ b/paddle/fluid/ir_adaptor/translator/op_translator.cc @@ -1181,11 +1181,20 @@ struct FillConstant2FullTranscriber : public OpTranscriber { ctx, paddle::dialect::VarTypeToDataType( static_cast(dtype)))}}; + + if (op_desc.HasAttr("force_cpu")) { + bool force_cpu = PADDLE_GET_CONST(bool, op_desc.GetAttr("force_cpu")); + if (force_cpu) { + attribute_map["place"] = + paddle::dialect::PlaceAttribute::get(ctx, phi::CPUPlace()); + } + } + int place_type = PADDLE_GET_CONST(int, op_desc.GetAttr("place_type")); switch (place_type) { case -1: - attribute_map["place"] = - paddle::dialect::PlaceAttribute::get(ctx, phi::CPUPlace()); + attribute_map["place"] = paddle::dialect::PlaceAttribute::get( + ctx, phi::Place(phi::AllocationType::UNDEFINED)); break; case 0: attribute_map["place"] = -- GitLab