From d0e5fc1b0d0520939effea2c45d8482a8dcfb594 Mon Sep 17 00:00:00 2001 From: wanghuancoder Date: Thu, 24 Aug 2023 14:09:52 +0800 Subject: [PATCH] fix cast vector of int64 bug (#56566) --- .../fluid/ir_adaptor/translator/op_translator.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/paddle/fluid/ir_adaptor/translator/op_translator.cc b/paddle/fluid/ir_adaptor/translator/op_translator.cc index 1850dec2f39..6a7a2236151 100644 --- a/paddle/fluid/ir_adaptor/translator/op_translator.cc +++ b/paddle/fluid/ir_adaptor/translator/op_translator.cc @@ -1166,8 +1166,8 @@ struct FillConstant2FullTranscriber : public OpTranscriber { const std::string& normalized_op_name, const OpAttributeInfoList& op_attr_infos, const OpDesc& op_desc) override { - std::vector shape = - PADDLE_GET_CONST(std::vector, op_desc.GetAttr("shape")); + auto& attribute_translator = AttributeTranslator::instance(); + paddle::framework::Attribute shape_attr = op_desc.GetAttr("shape"); float value = PADDLE_GET_CONST(float, op_desc.GetAttr("value")); int dtype = PADDLE_GET_CONST(int, op_desc.GetAttr("dtype")); @@ -1175,7 +1175,8 @@ struct FillConstant2FullTranscriber : public OpTranscriber { ir::AttributeMap attribute_map = { {"shape", - paddle::dialect::IntArrayAttribute::get(ctx, phi::IntArray(shape))}, + attribute_translator("paddle::dialect::IntArrayAttribute", + shape_attr)}, {"value", attr_value.dyn_cast()}, {"dtype", paddle::dialect::DataTypeAttribute::get( @@ -1241,10 +1242,10 @@ struct FillConstant2FullWithTensorTranscriber : public OpTranscriber { ctx, param_map, program, shape_tensor_list_vars); op_inputs.push_back(defining_op->result(0)); } else { - std::vector shape = - PADDLE_GET_CONST(std::vector, op_desc.GetAttr("shape")); - ir::Attribute new_attr = - paddle::dialect::IntArrayAttribute::get(ctx, phi::IntArray(shape)); + auto& attribute_translator = AttributeTranslator::instance(); + paddle::framework::Attribute shape_attr = op_desc.GetAttr("shape"); + ir::Attribute new_attr = attribute_translator( + "paddle::dialect::IntArrayAttribute", shape_attr); auto defining_op = InsertFullArrayOperationForAttributeInput(ctx, program, new_attr); op_inputs.push_back(defining_op->result(0)); -- GitLab