Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[clang-tidy] NO.25 enable modernize-use-transparent-functors #61689

Merged
merged 10 commits into from
Feb 26, 2024
2 changes: 1 addition & 1 deletion paddle/common/ddim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ DDim DDim::reshape(std::vector<int>& shape) const {
if (it != shape.end()) {
int index = static_cast<int>(std::distance(shape.begin(), it));
int reshape_out_product =
std::accumulate(shape.begin(), shape.end(), -1, std::multiplies<int>());
std::accumulate(shape.begin(), shape.end(), -1, std::multiplies<>());
shape[index] = static_cast<int>(product(in_dims)) / reshape_out_product;
}

Expand Down
10 changes: 5 additions & 5 deletions paddle/phi/infermeta/spmd_rules/reshape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ std::vector<int64_t> InferTargetShape(const std::vector<int64_t>& shape,
}
}

int64_t product = std::accumulate(
shape.begin(), shape.end(), 1, std::multiplies<int64_t>());
int64_t product =
std::accumulate(shape.begin(), shape.end(), 1, std::multiplies<>());
if (product > 0) {
PADDLE_ENFORCE_EQ(
product,
Expand All @@ -72,7 +72,7 @@ std::vector<std::shared_ptr<DimTrans>> MakeReshapeDimTrans(
const std::vector<int64_t>& tgt_shape) {
std::vector<std::shared_ptr<DimTrans>> ret;
int64_t total_elem_num_src = std::accumulate(
src_shape.begin(), src_shape.end(), 1, std::multiplies<int64_t>());
src_shape.begin(), src_shape.end(), 1, std::multiplies<>());
std::vector<int64_t> inferred_tgt_shape =
InferTargetShape(tgt_shape, total_elem_num_src);

Expand Down Expand Up @@ -268,8 +268,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>());
int64_t nelm =
std::accumulate(x_shape.begin(), x_shape.end(), 1, std::multiplies<>());
out_shape = InferTargetShape(out_shape, nelm);
std::vector<std::shared_ptr<DimTrans>> trans =
MakeReshapeDimTrans(out_shape, x_shape);
Expand Down
2 changes: 1 addition & 1 deletion paddle/pir/core/ir_printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void IrPrinter::PrintOpResult(Operation* op) {

void IrPrinter::PrintAttributeMap(Operation* op) {
AttributeMap attributes = op->attributes();
std::map<std::string, Attribute, std::less<std::string>> order_attributes(
std::map<std::string, Attribute, std::less<>> order_attributes(
attributes.begin(), attributes.end());
os << " {";

Expand Down
2 changes: 1 addition & 1 deletion test/cpp/fluid/memory/thread_local_allocator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<void *>()),
addresses.begin(), addresses.end(), std::equal_to<>()),
addresses.end());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32_t>());
std::multiplies<>());
out_data.resize(out_num);
PD_TensorCopyToCpuFloat(output_tensor, out_data.data());
LOG(INFO) << "Output tensor name is: " << PD_TensorGetName(output_tensor);
Expand Down