diff --git a/paddle/fluid/ir/dialect/op_gen.py b/paddle/fluid/ir/dialect/op_gen.py index ab8354f1fb8b75ef4d69f226a277441bbbce8599..cc4ca4a2cd790b240696b750f7b3dce73e03a406 100644 --- a/paddle/fluid/ir/dialect/op_gen.py +++ b/paddle/fluid/ir/dialect/op_gen.py @@ -251,8 +251,8 @@ def to_phi_and_fluid_op_name(op_item): scalar_type_maps = { - 'int': 'ir::Int32_tAttribute', - 'int64_t': 'ir::Int64_tAttribute', + 'int': 'ir::Int32Attribute', + 'int64_t': 'ir::Int64Attribute', 'float': 'ir::FloatAttribute', 'dobule': 'ir::DoubleAttribute', 'bool': 'ir::BoolAttribute', @@ -309,17 +309,17 @@ class OpInfoParser: self.attr_types_map = { 'IntArray': ['paddle::dialect::IntArrayAttribute', 'IntArray'], 'Scalar': ['paddle::dialect::ScalarAttribute', 'Scalar'], - 'Scalar(int)': ['ir::Int32_tAttribute', 'int'], - 'Scalar(int64_t)': ['ir::Int64_tAttribute', 'int64_t'], + 'Scalar(int)': ['ir::Int32Attribute', 'int'], + 'Scalar(int64_t)': ['ir::Int64Attribute', 'int64_t'], 'Scalar(float)': ['ir::FloatAttribute', 'float'], 'Scalar(dobule)': ['ir::DoubleAttribute', 'dobule'], 'Scalar[]': [ 'ir::ArrayAttribute', 'const std::vector&', ], - 'int': ['ir::Int32_tAttribute', 'int'], - 'int32_t': ['ir::Int32_tAttribute', 'int32_t'], - 'int64_t': ['ir::Int64_tAttribute', 'int64_t'], + 'int': ['ir::Int32Attribute', 'int'], + 'int32_t': ['ir::Int32Attribute', 'int32_t'], + 'int64_t': ['ir::Int64Attribute', 'int64_t'], 'long': ['ir::LongAttribute', 'long'], 'size_t': ['ir::Size_tAttribute', 'size_t'], 'float': ['ir::FloatAttribute', 'float'], @@ -345,11 +345,11 @@ class OpInfoParser: ], 'DataType': ['paddle::dialect::DataTypeAttribute', 'DataType'], 'int64_t[]': [ - 'ir::ArrayAttribute', + 'ir::ArrayAttribute', 'const std::vector&', ], 'int[]': [ - 'ir::ArrayAttribute', + 'ir::ArrayAttribute', 'const std::vector&', ], } diff --git a/paddle/fluid/ir/dialect/pd_attribute.cc b/paddle/fluid/ir/dialect/pd_attribute.cc index 0bb42226d49ac8c786fc728c73817feb0366065a..08f552683d1b21e01fba8ca5e2708c26a22b0f8e 100644 --- a/paddle/fluid/ir/dialect/pd_attribute.cc +++ b/paddle/fluid/ir/dialect/pd_attribute.cc @@ -31,10 +31,10 @@ phi::Scalar ScalarAttribute::data() { return phi::Scalar(dyn_cast().data()); } else if (isa()) { return phi::Scalar(dyn_cast().data()); - } else if (isa()) { - return phi::Scalar(dyn_cast().data()); - } else if (isa()) { - return phi::Scalar(dyn_cast().data()); + } else if (isa()) { + return phi::Scalar(dyn_cast().data()); + } else if (isa()) { + return phi::Scalar(dyn_cast().data()); } else if (isa()) { return phi::Scalar(dyn_cast().data()); } else { diff --git a/paddle/fluid/ir/dialect/pd_attribute.h b/paddle/fluid/ir/dialect/pd_attribute.h index 1cc1c90950df72abe814b03e6ab87044fba855f4..c95dbe248caf6b98b28cd3849d430ad537a1bcc0 100644 --- a/paddle/fluid/ir/dialect/pd_attribute.h +++ b/paddle/fluid/ir/dialect/pd_attribute.h @@ -44,8 +44,8 @@ class ScalarAttribute : public ir::Attribute { return (val.type_id() == ir::BoolAttribute::type_id()) || (val.type_id() == ir::FloatAttribute::type_id()) || (val.type_id() == ir::DoubleAttribute::type_id()) || - (val.type_id() == ir::Int32_tAttribute::type_id()) || - (val.type_id() == ir::Int64_tAttribute::type_id()); + (val.type_id() == ir::Int32Attribute::type_id()) || + (val.type_id() == ir::Int64Attribute::type_id()); } phi::Scalar data(); diff --git a/paddle/fluid/ir/dialect/utils.h b/paddle/fluid/ir/dialect/utils.h index 14f83d818098101f0be5da8cd1c67b1c2f6c138d..46724c0c77304920c9bdd1ce84f82b5379606b2f 100644 --- a/paddle/fluid/ir/dialect/utils.h +++ b/paddle/fluid/ir/dialect/utils.h @@ -83,9 +83,9 @@ static inline ir::Attribute TransToIrAttribute(phi::Scalar scalar, case phi::DataType::FLOAT64: return ir::DoubleAttribute::get(ctx, scalar.to()); case phi::DataType::INT32: - return ir::Int32_tAttribute::get(ctx, scalar.to()); + return ir::Int32Attribute::get(ctx, scalar.to()); case phi::DataType::INT64: - return ir::Int64_tAttribute::get(ctx, scalar.to()); + return ir::Int64Attribute::get(ctx, scalar.to()); case phi::DataType::BOOL: return ir::BoolAttribute::get(ctx, scalar.to()); default: diff --git a/paddle/fluid/ir_adaptor/translator/attribute_translator.cc b/paddle/fluid/ir_adaptor/translator/attribute_translator.cc index f2da12c6643d94f43f6ddf761804341a208dbae0..95e61d849f26b22115d67d2448b69ea5d9b71242 100644 --- a/paddle/fluid/ir_adaptor/translator/attribute_translator.cc +++ b/paddle/fluid/ir_adaptor/translator/attribute_translator.cc @@ -38,7 +38,7 @@ class AttributeVisitor { public: virtual ir::Attribute operator()(int i) { VLOG(10) << "translating int"; - return ir::Int32_tAttribute::get(ctx, i); + return ir::Int32Attribute::get(ctx, i); } virtual ir::Attribute operator()(float f) { @@ -91,7 +91,7 @@ class AttributeVisitor { std::vector attrs; attrs.reserve(is.size()); for (const auto& v : is) { - attrs.push_back(ir::Int32_tAttribute::get(ctx, v)); + attrs.push_back(ir::Int32Attribute::get(ctx, v)); } return ir::ArrayAttribute::get(ctx, attrs); } @@ -111,7 +111,7 @@ class AttributeVisitor { std::vector attrs; attrs.reserve(i64s.size()); for (const auto& v : i64s) { - attrs.push_back(ir::Int64_tAttribute::get(ctx, v)); + attrs.push_back(ir::Int64Attribute::get(ctx, v)); } return ir::ArrayAttribute::get(ctx, attrs); } diff --git a/paddle/fluid/ir_adaptor/translator/op_translator.cc b/paddle/fluid/ir_adaptor/translator/op_translator.cc index 3e2c8117897ceea5fa039511be27a27bfef6fd85..9bd8c7452cde2e7a1ec8855c104f25ada9320c2c 100644 --- a/paddle/fluid/ir_adaptor/translator/op_translator.cc +++ b/paddle/fluid/ir_adaptor/translator/op_translator.cc @@ -131,7 +131,7 @@ inline ir::Operation* InsertSliceOperationForTarget( std::string slice_op_name(ir::SliceOp::name()); ir::OpInfo op_info = ctx->GetRegisteredOpInfo(slice_op_name); std::unordered_map op_attribute_map = { - {"index", ir::Int32_tAttribute::get(ctx, defining_info.idx_in_vector)}, + {"index", ir::Int32Attribute::get(ctx, defining_info.idx_in_vector)}, }; ir::VectorType src_vec_type = defining_info.value.type().dyn_cast(); @@ -179,11 +179,11 @@ inline ir::Operation* InsertFullOperationForAttributeInput(ir::IrContext* ctx, } else if (attr.isa()) { data = static_cast(attr.dyn_cast().data()); dtype = phi::DataType::FLOAT64; - } else if (attr.isa()) { - data = static_cast(attr.dyn_cast().data()); + } else if (attr.isa()) { + data = static_cast(attr.dyn_cast().data()); dtype = phi::DataType::INT32; - } else if (attr.isa()) { - data = static_cast(attr.dyn_cast().data()); + } else if (attr.isa()) { + data = static_cast(attr.dyn_cast().data()); dtype = phi::DataType::INT64; } else if (attr.isa()) { data = static_cast(attr.dyn_cast().data()); diff --git a/paddle/ir/core/builtin_attribute.cc b/paddle/ir/core/builtin_attribute.cc index 76cc50d3de43807b5f94f269a17766a8f2cf1f39..d9f4798ccab26681f4fb758e17d268305e155f64 100644 --- a/paddle/ir/core/builtin_attribute.cc +++ b/paddle/ir/core/builtin_attribute.cc @@ -25,9 +25,9 @@ float FloatAttribute::data() const { return storage()->GetAsKey(); } double DoubleAttribute::data() const { return storage()->GetAsKey(); } -int32_t Int32_tAttribute::data() const { return storage()->GetAsKey(); } +int32_t Int32Attribute::data() const { return storage()->GetAsKey(); } -int64_t Int64_tAttribute::data() const { return storage()->GetAsKey(); } +int64_t Int64Attribute::data() const { return storage()->GetAsKey(); } std::vector ArrayAttribute::data() const { return storage()->GetAsKey(); diff --git a/paddle/ir/core/builtin_attribute.h b/paddle/ir/core/builtin_attribute.h index cc4741dc3a7f47c80a1528f31629e8edfdf22796..ba013af6ff28356d4b6e380d6580a37f063fdef4 100644 --- a/paddle/ir/core/builtin_attribute.h +++ b/paddle/ir/core/builtin_attribute.h @@ -61,20 +61,20 @@ class DoubleAttribute : public Attribute { double data() const; }; -class Int32_tAttribute : public Attribute { +class Int32Attribute : public Attribute { public: using Attribute::Attribute; - DECLARE_ATTRIBUTE_UTILITY_FUNCTOR(Int32_tAttribute, Int32_tAttributeStorage); + DECLARE_ATTRIBUTE_UTILITY_FUNCTOR(Int32Attribute, Int32AttributeStorage); int32_t data() const; }; -class Int64_tAttribute : public Attribute { +class Int64Attribute : public Attribute { public: using Attribute::Attribute; - DECLARE_ATTRIBUTE_UTILITY_FUNCTOR(Int64_tAttribute, Int64_tAttributeStorage); + DECLARE_ATTRIBUTE_UTILITY_FUNCTOR(Int64Attribute, Int64AttributeStorage); int64_t data() const; }; diff --git a/paddle/ir/core/builtin_attribute_storage.h b/paddle/ir/core/builtin_attribute_storage.h index 40b833fe9c7a7dab52f8ce453a4fb90fe65642e6..bf68dc387cb31777a8cecf1d97fc638d3657b0a9 100644 --- a/paddle/ir/core/builtin_attribute_storage.h +++ b/paddle/ir/core/builtin_attribute_storage.h @@ -81,8 +81,8 @@ struct StrAttributeStorage : public AttributeStorage { DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE(BoolAttributeStorage, bool); DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE(FloatAttributeStorage, float); DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE(DoubleAttributeStorage, double); -DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE(Int32_tAttributeStorage, int32_t); -DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE(Int64_tAttributeStorage, int64_t); +DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE(Int32AttributeStorage, int32_t); +DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE(Int64AttributeStorage, int64_t); DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE(PointerAttributeStorage, void *); struct ArrayAttributeStorage : public AttributeStorage { diff --git a/paddle/ir/core/builtin_dialect.cc b/paddle/ir/core/builtin_dialect.cc index f3a5183cd6ca617f7db45ff3273b579dceef990c..0be2bc1a2e30434b0971631c78c61f171483457b 100644 --- a/paddle/ir/core/builtin_dialect.cc +++ b/paddle/ir/core/builtin_dialect.cc @@ -41,8 +41,8 @@ void BuiltinDialect::initialize() { FloatAttribute, DoubleAttribute, PointerAttribute, - Int32_tAttribute, - Int64_tAttribute, + Int32Attribute, + Int64Attribute, ArrayAttribute>(); RegisterOps &inputs, IR_ENFORCE(attributes.count("index") != 0, "The attributes must contains index."); const ir::Attribute &attr = attributes.at("index"); - IR_ENFORCE(attr.isa(), + IR_ENFORCE(attr.isa(), "The attribute index must be INT32."); - auto index = attr.dyn_cast().data(); + auto index = attr.dyn_cast().data(); // index >= 0 and < inputs[0].size() IR_ENFORCE( diff --git a/paddle/ir/core/ir_printer.cc b/paddle/ir/core/ir_printer.cc index fd0a41fbdae3092fef9337072f55d48ff445ac10..900a6a147753e197cc52e56c9caf46ca3af46ac6 100644 --- a/paddle/ir/core/ir_printer.cc +++ b/paddle/ir/core/ir_printer.cc @@ -83,9 +83,9 @@ class BasicIRPrinter { os << f.data(); } else if (auto d = attr.dyn_cast()) { os << d.data(); - } else if (auto i = attr.dyn_cast()) { + } else if (auto i = attr.dyn_cast()) { os << i.data(); - } else if (auto i = attr.dyn_cast()) { + } else if (auto i = attr.dyn_cast()) { os << i.data(); } else if (auto arr = attr.dyn_cast()) { const auto& vec = arr.data(); diff --git a/test/cpp/ir/core/ir_op_test.cc b/test/cpp/ir/core/ir_op_test.cc index c071a0d45df81c446c6d40d6879e23864707d300..6d9524634c71368484d053c0fde2eed948147c82 100644 --- a/test/cpp/ir/core/ir_op_test.cc +++ b/test/cpp/ir/core/ir_op_test.cc @@ -238,7 +238,7 @@ TEST(op_test, module_op_death) { // (3) Test uses for op. std::vector inputs{ir::OpResult()}; - ir::AttributeMap attrs{{"program", ir::Int32_tAttribute::get(ctx, 1)}}; + ir::AttributeMap attrs{{"program", ir::Int32Attribute::get(ctx, 1)}}; std::vector output_types = {ir::Float32Type::get(ctx)}; EXPECT_THROW(ir::Operation::Create(inputs, {}, {}, op_info), diff --git a/test/cpp/ir/core/ir_program_test.cc b/test/cpp/ir/core/ir_program_test.cc index 2388752a87ba1b957bd0e5fdffe17c617adc2f82..b67fe6d4d89208e4b748e170429d32c0c1cc9f67 100644 --- a/test/cpp/ir/core/ir_program_test.cc +++ b/test/cpp/ir/core/ir_program_test.cc @@ -283,7 +283,7 @@ TEST(program_test, slice_combine_test) { // (7) Def slice_op = SliceOp(combine_op, 0) std::string slice_op_name = std::string(ir::SliceOp::name()); ir::OpInfo slice_op_info = ctx->GetRegisteredOpInfo(slice_op_name); - ir::Attribute index_attr = ir::Int32_tAttribute::get(ctx, 0); + ir::Attribute index_attr = ir::Int32Attribute::get(ctx, 0); ir::Operation *slice_op = ir::Operation::Create({combine_op->GetResultByIndex(0)}, {{"index", index_attr}}, @@ -319,8 +319,7 @@ TEST(program_test, builder) { } ir::ConstantOp constant = builder.Build( - ir::Int32_tAttribute::get(ctx, 2), ir::Int32Type::get(ctx)); + ir::Int32Attribute::get(ctx, 2), ir::Int32Type::get(ctx)); EXPECT_EQ(program.block()->size() == 2, true); - EXPECT_EQ(constant.value().dyn_cast().data() == 2, - true); + EXPECT_EQ(constant.value().dyn_cast().data() == 2, true); } diff --git a/test/cpp/ir/core/op_info_test.cc b/test/cpp/ir/core/op_info_test.cc index da3142dfe5f6a936a4c1b53e9279836ae0517abd..c869328af34aef01d93a590eb7c90769a65fe01a 100644 --- a/test/cpp/ir/core/op_info_test.cc +++ b/test/cpp/ir/core/op_info_test.cc @@ -28,7 +28,7 @@ TEST(ir_op_info_test, op_op_info_test) { ir::Block* block = program.block(); ir::Builder builder(context, block); - builder.Build(ir::Int32_tAttribute::get(context, 5), + builder.Build(ir::Int32Attribute::get(context, 5), ir::Int32Type::get(context)); ir::Operation* op = block->back(); diff --git a/test/cpp/ir/core/phi_kernel_adaptor.h b/test/cpp/ir/core/phi_kernel_adaptor.h index 2e44ff55848e381627f9a848556501074ca6f3b1..e9a6ed5bddd647e268d65b60baa4cd59ffb705bf 100644 --- a/test/cpp/ir/core/phi_kernel_adaptor.h +++ b/test/cpp/ir/core/phi_kernel_adaptor.h @@ -164,9 +164,8 @@ void build_context(ir::Operation* op, } else if (type_name == "paddle::dialect::DataTypeAttribute") { ctx->EmplaceBackAttr( attr_map[t].dyn_cast().data()); - } else if (type_name == "ir::Int32_tAttribute") { - ctx->EmplaceBackAttr( - attr_map[t].dyn_cast().data()); + } else if (type_name == "ir::Int32Attribute") { + ctx->EmplaceBackAttr(attr_map[t].dyn_cast().data()); } else if (type_name == "paddle::dialect::PlaceAttribute") { ctx->EmplaceBackAttr( attr_map[t].dyn_cast().data()); diff --git a/test/cpp/ir/core/scalar_attribute_test.cc b/test/cpp/ir/core/scalar_attribute_test.cc index c2292357f412df2f0bf6c05597ffabfb1ad52340..8dc3f8314ad2db231e9728f03576e607dd21afab 100644 --- a/test/cpp/ir/core/scalar_attribute_test.cc +++ b/test/cpp/ir/core/scalar_attribute_test.cc @@ -47,9 +47,9 @@ TEST(ScalarTest, test_classof) { ir::Attribute double_scalar = ir::DoubleAttribute::get(ctx, 1.0); EXPECT_TRUE(double_scalar.isa()); - ir::Attribute int32_scalar = ir::Int32_tAttribute::get(ctx, 1); + ir::Attribute int32_scalar = ir::Int32Attribute::get(ctx, 1); EXPECT_TRUE(int32_scalar.isa()); - ir::Attribute int64_scalar = ir::Int64_tAttribute::get(ctx, 1l); + ir::Attribute int64_scalar = ir::Int64Attribute::get(ctx, 1l); EXPECT_TRUE(int64_scalar.isa()); }