From e6b12f78e8ccf362cd6f5d22b22d18126b4303e4 Mon Sep 17 00:00:00 2001 From: enkilee Date: Wed, 7 Feb 2024 15:14:37 +0800 Subject: [PATCH 1/5] clangtidy 25 --- paddle/common/ddim.cc | 2 +- paddle/phi/infermeta/spmd_rules/reshape.cc | 6 +++--- paddle/pir/core/ir_printer.cc | 2 +- test/cpp/fluid/memory/thread_local_allocator_test.cc | 2 +- .../cpp/inference/api/analyzer_capi_exp_pd_tensor_tester.cc | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/paddle/common/ddim.cc b/paddle/common/ddim.cc index 75eb1423cce8a..d80a87f5657b5 100644 --- a/paddle/common/ddim.cc +++ b/paddle/common/ddim.cc @@ -248,7 +248,7 @@ DDim DDim::reshape(std::vector& shape) const { if (it != shape.end()) { int index = static_cast(std::distance(shape.begin(), it)); int reshape_out_product = - std::accumulate(shape.begin(), shape.end(), -1, std::multiplies()); + std::accumulate(shape.begin(), shape.end(), -1, std::multiplies<>()); shape[index] = static_cast(product(in_dims)) / reshape_out_product; } diff --git a/paddle/phi/infermeta/spmd_rules/reshape.cc b/paddle/phi/infermeta/spmd_rules/reshape.cc index 5f4f59f9995dd..2e02c2a178cc6 100644 --- a/paddle/phi/infermeta/spmd_rules/reshape.cc +++ b/paddle/phi/infermeta/spmd_rules/reshape.cc @@ -45,7 +45,7 @@ std::vector InferTargetShape(const std::vector& shape, } int64_t product = std::accumulate( - shape.begin(), shape.end(), 1, std::multiplies()); + shape.begin(), shape.end(), 1, std::multiplies<>()); if (product > 0) { PADDLE_ENFORCE_EQ( product, @@ -72,7 +72,7 @@ std::vector> MakeReshapeDimTrans( const std::vector& tgt_shape) { std::vector> ret; int64_t total_elem_num_src = std::accumulate( - src_shape.begin(), src_shape.end(), 1, std::multiplies()); + src_shape.begin(), src_shape.end(), 1, std::multiplies<>()); std::vector inferred_tgt_shape = InferTargetShape(tgt_shape, total_elem_num_src); @@ -269,7 +269,7 @@ SpmdInfo ReshapeInferSpmdReverse(const DistMetaTensor& x, // when inferring the transformation from out_shape to // x_shape, so infer the '-1' value before inferrng DimTrans int64_t nelm = std::accumulate( - x_shape.begin(), x_shape.end(), 1, std::multiplies()); + x_shape.begin(), x_shape.end(), 1, std::multiplies<>()); out_shape = InferTargetShape(out_shape, nelm); std::vector> trans = MakeReshapeDimTrans(out_shape, x_shape); diff --git a/paddle/pir/core/ir_printer.cc b/paddle/pir/core/ir_printer.cc index 354e40cd671be..4e51d79f2b3f7 100644 --- a/paddle/pir/core/ir_printer.cc +++ b/paddle/pir/core/ir_printer.cc @@ -266,7 +266,7 @@ void IrPrinter::PrintOpResult(Operation* op) { void IrPrinter::PrintAttributeMap(Operation* op) { AttributeMap attributes = op->attributes(); - std::map> order_attributes( + std::map> order_attributes( attributes.begin(), attributes.end()); os << " {"; diff --git a/test/cpp/fluid/memory/thread_local_allocator_test.cc b/test/cpp/fluid/memory/thread_local_allocator_test.cc index c322295892da3..c6cb4cf0acf20 100644 --- a/test/cpp/fluid/memory/thread_local_allocator_test.cc +++ b/test/cpp/fluid/memory/thread_local_allocator_test.cc @@ -78,7 +78,7 @@ TEST(ThreadLocalAllocator, cross_scope_release) { for (auto &addresses : allocator_addresses) { std::sort(addresses.begin(), addresses.end()); ASSERT_EQ(std::adjacent_find( - addresses.begin(), addresses.end(), std::equal_to()), + addresses.begin(), addresses.end(), std::equal_to<>()), addresses.end()); } diff --git a/test/cpp/inference/api/analyzer_capi_exp_pd_tensor_tester.cc b/test/cpp/inference/api/analyzer_capi_exp_pd_tensor_tester.cc index c17ffac0e523b..5254459100bbf 100644 --- a/test/cpp/inference/api/analyzer_capi_exp_pd_tensor_tester.cc +++ b/test/cpp/inference/api/analyzer_capi_exp_pd_tensor_tester.cc @@ -69,7 +69,7 @@ void PD_run() { int32_t out_num = std::accumulate(output_shape->data, output_shape->data + output_shape->size, 1, - std::multiplies()); + std::multiplies<>()); out_data.resize(out_num); PD_TensorCopyToCpuFloat(output_tensor, out_data.data()); LOG(INFO) << "Output tensor name is: " << PD_TensorGetName(output_tensor); From ac6b83e90eca915ea7af6e6718afa8556f1c448d Mon Sep 17 00:00:00 2001 From: enkilee Date: Thu, 8 Feb 2024 00:04:36 +0800 Subject: [PATCH 2/5] codestyle --- paddle/phi/infermeta/spmd_rules/reshape.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/paddle/phi/infermeta/spmd_rules/reshape.cc b/paddle/phi/infermeta/spmd_rules/reshape.cc index 2e02c2a178cc6..2c0c52af19759 100644 --- a/paddle/phi/infermeta/spmd_rules/reshape.cc +++ b/paddle/phi/infermeta/spmd_rules/reshape.cc @@ -44,8 +44,9 @@ std::vector InferTargetShape(const std::vector& shape, } } - int64_t product = std::accumulate( - shape.begin(), shape.end(), 1, std::multiplies<>()); + int64_t product = + std::accumulate(shape.begin(), shape.end(), 1, std::multiplies<>()); + if (product > 0) { PADDLE_ENFORCE_EQ( product, @@ -268,8 +269,8 @@ SpmdInfo ReshapeInferSpmdReverse(const DistMetaTensor& x, // The out_shape may contain '-1', which will cause error // when inferring the transformation from out_shape to // x_shape, so infer the '-1' value before inferrng DimTrans - int64_t nelm = std::accumulate( - x_shape.begin(), x_shape.end(), 1, std::multiplies<>()); + int64_t nelm = + std::accumulate(x_shape.begin(), x_shape.end(), 1, std::multiplies<>()); out_shape = InferTargetShape(out_shape, nelm); std::vector> trans = MakeReshapeDimTrans(out_shape, x_shape); From 36be606c3ace2b73ab7ea16efb5d898630dbef2c Mon Sep 17 00:00:00 2001 From: enkilee Date: Thu, 8 Feb 2024 00:05:02 +0800 Subject: [PATCH 3/5] codestyle --- paddle/phi/infermeta/spmd_rules/reshape.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/paddle/phi/infermeta/spmd_rules/reshape.cc b/paddle/phi/infermeta/spmd_rules/reshape.cc index 2c0c52af19759..a84d3daeecf94 100644 --- a/paddle/phi/infermeta/spmd_rules/reshape.cc +++ b/paddle/phi/infermeta/spmd_rules/reshape.cc @@ -46,7 +46,6 @@ std::vector InferTargetShape(const std::vector& shape, int64_t product = std::accumulate(shape.begin(), shape.end(), 1, std::multiplies<>()); - if (product > 0) { PADDLE_ENFORCE_EQ( product, From 1e0a3eec31cacacb405753c84e0169cc60beaec4 Mon Sep 17 00:00:00 2001 From: enkilee Date: Tue, 20 Feb 2024 10:55:18 +0800 Subject: [PATCH 4/5] fix --- paddle/pir/{ => src}/core/ir_printer.cc | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename paddle/pir/{ => src}/core/ir_printer.cc (100%) diff --git a/paddle/pir/core/ir_printer.cc b/paddle/pir/src/core/ir_printer.cc similarity index 100% rename from paddle/pir/core/ir_printer.cc rename to paddle/pir/src/core/ir_printer.cc From 6d4d53f7008f434e3db0ad91eb48a77a881c4220 Mon Sep 17 00:00:00 2001 From: enkilee Date: Wed, 21 Feb 2024 10:34:47 +0800 Subject: [PATCH 5/5] fix --- paddle/pir/src/core/ir_printer.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/paddle/pir/src/core/ir_printer.cc b/paddle/pir/src/core/ir_printer.cc index 6ae3071da550f..c1a0fcd905ac8 100644 --- a/paddle/pir/src/core/ir_printer.cc +++ b/paddle/pir/src/core/ir_printer.cc @@ -69,7 +69,7 @@ void BasicIrPrinter::PrintType(Type type) { } else if (type.isa()) { os << "vec["; auto inner_types = type.dyn_cast().data(); - PrintInterleave( + pir::detail::PrintInterleave( inner_types.begin(), inner_types.end(), [this](Type v) { this->PrintType(v); }, @@ -132,7 +132,7 @@ void BasicIrPrinter::PrintAttribute(Attribute attr) { } else if (auto arr = attr.dyn_cast()) { const auto& vec = arr.AsVector(); os << "["; - PrintInterleave( + pir::detail::PrintInterleave( vec.begin(), vec.end(), [this](Attribute v) { this->PrintAttribute(v); }, @@ -256,7 +256,7 @@ void IrPrinter::PrintOpResult(Operation* op) { for (size_t idx = 0; idx < num_op_result; idx++) { op_results.push_back(op->result(idx)); } - PrintInterleave( + pir::detail::PrintInterleave( op_results.begin(), op_results.end(), [this](Value v) { this->PrintValue(v); }, @@ -270,7 +270,7 @@ void IrPrinter::PrintAttributeMap(Operation* op) { attributes.begin(), attributes.end()); os << " {"; - PrintInterleave( + pir::detail::PrintInterleave( order_attributes.begin(), order_attributes.end(), [this](std::pair it) { @@ -291,7 +291,7 @@ void IrPrinter::PrintOpOperands(Operation* op) { for (size_t idx = 0; idx < num_op_operands; idx++) { op_operands.push_back(op->operand_source(idx)); } - PrintInterleave( + pir::detail::PrintInterleave( op_operands.begin(), op_operands.end(), [this](Value v) { this->PrintValue(v); }, @@ -312,7 +312,7 @@ void IrPrinter::PrintOperandsType(Operation* op) { } } os << " ("; - PrintInterleave( + pir::detail::PrintInterleave( op_operand_types.begin(), op_operand_types.end(), [this](Type t) { this->PrintType(t); }, @@ -332,7 +332,7 @@ void IrPrinter::PrintOpReturnType(Operation* op) { op_result_types.emplace_back(nullptr); } } - PrintInterleave( + pir::detail::PrintInterleave( op_result_types.begin(), op_result_types.end(), [this](Type t) { this->PrintType(t); },