-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[mlir] Use llvm::transform (NFC) #167205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mlir] Use llvm::transform (NFC) #167205
Conversation
Identified with llvm-use-ranges.
|
@llvm/pr-subscribers-mlir-affine @llvm/pr-subscribers-mlir-core Author: Kazu Hirata (kazutakahirata) ChangesIdentified with llvm-use-ranges. Full diff: https://github.com/llvm/llvm-project/pull/167205.diff 6 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h b/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h
index 452d4f6b4ed61..d996db88fcb2a 100644
--- a/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h
+++ b/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h
@@ -50,10 +50,8 @@ void populateAllReduceEndomorphismSimplificationPatterns(
auto getAlgebraicOpOperands = [](Operation *op,
SmallVector<OpOperand *> &operands) {
auto algebraicOp = llvm::cast<AlgebraicOp>(op);
- std::transform(algebraicOp->getOpOperands().begin(),
- algebraicOp->getOpOperands().end(),
- std::back_inserter(operands),
- [](OpOperand &operand) { return &operand; });
+ llvm::transform(algebraicOp->getOpOperands(), std::back_inserter(operands),
+ [](OpOperand &operand) { return &operand; });
};
auto getAlgebraicOpResult = [](Operation *op) {
auto algebraicOp = llvm::cast<AlgebraicOp>(op);
diff --git a/mlir/lib/Analysis/FlatLinearValueConstraints.cpp b/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
index 6588b53cbd9f8..0e0c5f2159382 100644
--- a/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
+++ b/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
@@ -530,7 +530,7 @@ std::pair<AffineMap, AffineMap> FlatLinearConstraints::getLowerAndUpperBound(
// i - j + 1 >= 0 is the constraint, 'pos' is for i the lower bound is j
// - 1.
addCoeffs(ineq, lb);
- std::transform(lb.begin(), lb.end(), lb.begin(), std::negate<int64_t>());
+ llvm::transform(lb, lb.begin(), std::negate<int64_t>());
auto expr =
getAffineExprFromFlatForm(lb, dimCount, symCount, localExprs, context);
// expr ceildiv divisor is (expr + divisor - 1) floordiv divisor
@@ -559,7 +559,7 @@ std::pair<AffineMap, AffineMap> FlatLinearConstraints::getLowerAndUpperBound(
auto eq = getEquality64(idx);
addCoeffs(eq, b);
if (eq[pos + offset] > 0)
- std::transform(b.begin(), b.end(), b.begin(), std::negate<int64_t>());
+ llvm::transform(b, b.begin(), std::negate<int64_t>());
// Extract the upper bound (in terms of other coeff's + const).
auto expr =
diff --git a/mlir/lib/Analysis/Presburger/Utils.cpp b/mlir/lib/Analysis/Presburger/Utils.cpp
index 2aaa4c033d0ce..b06a8a1b9ccf8 100644
--- a/mlir/lib/Analysis/Presburger/Utils.cpp
+++ b/mlir/lib/Analysis/Presburger/Utils.cpp
@@ -52,8 +52,8 @@ static void normalizeDivisionByGCD(MutableArrayRef<DynamicAPInt> dividend,
}
// Normalize the dividend and the denominator.
- std::transform(dividend.begin(), dividend.end(), dividend.begin(),
- [gcd](DynamicAPInt &n) { return floorDiv(n, gcd); });
+ llvm::transform(dividend, dividend.begin(),
+ [gcd](DynamicAPInt &n) { return floorDiv(n, gcd); });
divisor /= gcd;
}
@@ -331,8 +331,7 @@ presburger::getDivLowerBound(ArrayRef<DynamicAPInt> dividend,
assert(dividend[localVarIdx] == 0 &&
"Local to be set to division must have zero coeff!");
SmallVector<DynamicAPInt, 8> ineq(dividend.size());
- std::transform(dividend.begin(), dividend.end(), ineq.begin(),
- std::negate<DynamicAPInt>());
+ llvm::transform(dividend, ineq.begin(), std::negate<DynamicAPInt>());
ineq[localVarIdx] = divisor;
ineq.back() += divisor - 1;
return ineq;
@@ -522,15 +521,13 @@ void DivisionRepr::dump() const { print(llvm::errs()); }
SmallVector<DynamicAPInt, 8>
presburger::getDynamicAPIntVec(ArrayRef<int64_t> range) {
SmallVector<DynamicAPInt, 8> result(range.size());
- std::transform(range.begin(), range.end(), result.begin(),
- dynamicAPIntFromInt64);
+ llvm::transform(range, result.begin(), dynamicAPIntFromInt64);
return result;
}
SmallVector<int64_t, 8> presburger::getInt64Vec(ArrayRef<DynamicAPInt> range) {
SmallVector<int64_t, 8> result(range.size());
- std::transform(range.begin(), range.end(), result.begin(),
- int64fromDynamicAPInt);
+ llvm::transform(range, result.begin(), int64fromDynamicAPInt);
return result;
}
diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
index b405ec2201bf8..edfae7ee96039 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
@@ -342,8 +342,7 @@ void FlatAffineValueConstraints::getIneqAsAffineValueMap(
if (inequality[pos] > 0)
// Lower bound.
- std::transform(bound.begin(), bound.end(), bound.begin(),
- std::negate<int64_t>());
+ llvm::transform(bound, bound.begin(), std::negate<int64_t>());
else
// Upper bound (which is exclusive).
bound.back() += 1;
diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
index bf3810ff231da..5823914967e9c 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
@@ -2628,7 +2628,7 @@ static LogicalResult verifyZeroPoint(T op, Value val, const int64_t &zp,
if (!zpElemType.isInteger(8) && zp != 0) {
// convert operand to lower case for error message
std::string lower = operand;
- std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
+ llvm::transform(lower, lower.begin(), ::tolower);
return op.emitOpError()
<< lower << " zero point must be zero for non-int8 integer types";
}
diff --git a/mlir/lib/IR/PatternMatch.cpp b/mlir/lib/IR/PatternMatch.cpp
index 9332f55bd9393..f015f7c9e9066 100644
--- a/mlir/lib/IR/PatternMatch.cpp
+++ b/mlir/lib/IR/PatternMatch.cpp
@@ -80,10 +80,9 @@ Pattern::Pattern(const void *rootValue, RootKind rootKind,
if (generatedNames.empty())
return;
generatedOps.reserve(generatedNames.size());
- std::transform(generatedNames.begin(), generatedNames.end(),
- std::back_inserter(generatedOps), [context](StringRef name) {
- return OperationName(name, context);
- });
+ llvm::transform(
+ generatedNames, std::back_inserter(generatedOps),
+ [context](StringRef name) { return OperationName(name, context); });
}
//===----------------------------------------------------------------------===//
|
|
@llvm/pr-subscribers-mlir-presburger Author: Kazu Hirata (kazutakahirata) ChangesIdentified with llvm-use-ranges. Full diff: https://github.com/llvm/llvm-project/pull/167205.diff 6 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h b/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h
index 452d4f6b4ed61..d996db88fcb2a 100644
--- a/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h
+++ b/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h
@@ -50,10 +50,8 @@ void populateAllReduceEndomorphismSimplificationPatterns(
auto getAlgebraicOpOperands = [](Operation *op,
SmallVector<OpOperand *> &operands) {
auto algebraicOp = llvm::cast<AlgebraicOp>(op);
- std::transform(algebraicOp->getOpOperands().begin(),
- algebraicOp->getOpOperands().end(),
- std::back_inserter(operands),
- [](OpOperand &operand) { return &operand; });
+ llvm::transform(algebraicOp->getOpOperands(), std::back_inserter(operands),
+ [](OpOperand &operand) { return &operand; });
};
auto getAlgebraicOpResult = [](Operation *op) {
auto algebraicOp = llvm::cast<AlgebraicOp>(op);
diff --git a/mlir/lib/Analysis/FlatLinearValueConstraints.cpp b/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
index 6588b53cbd9f8..0e0c5f2159382 100644
--- a/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
+++ b/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
@@ -530,7 +530,7 @@ std::pair<AffineMap, AffineMap> FlatLinearConstraints::getLowerAndUpperBound(
// i - j + 1 >= 0 is the constraint, 'pos' is for i the lower bound is j
// - 1.
addCoeffs(ineq, lb);
- std::transform(lb.begin(), lb.end(), lb.begin(), std::negate<int64_t>());
+ llvm::transform(lb, lb.begin(), std::negate<int64_t>());
auto expr =
getAffineExprFromFlatForm(lb, dimCount, symCount, localExprs, context);
// expr ceildiv divisor is (expr + divisor - 1) floordiv divisor
@@ -559,7 +559,7 @@ std::pair<AffineMap, AffineMap> FlatLinearConstraints::getLowerAndUpperBound(
auto eq = getEquality64(idx);
addCoeffs(eq, b);
if (eq[pos + offset] > 0)
- std::transform(b.begin(), b.end(), b.begin(), std::negate<int64_t>());
+ llvm::transform(b, b.begin(), std::negate<int64_t>());
// Extract the upper bound (in terms of other coeff's + const).
auto expr =
diff --git a/mlir/lib/Analysis/Presburger/Utils.cpp b/mlir/lib/Analysis/Presburger/Utils.cpp
index 2aaa4c033d0ce..b06a8a1b9ccf8 100644
--- a/mlir/lib/Analysis/Presburger/Utils.cpp
+++ b/mlir/lib/Analysis/Presburger/Utils.cpp
@@ -52,8 +52,8 @@ static void normalizeDivisionByGCD(MutableArrayRef<DynamicAPInt> dividend,
}
// Normalize the dividend and the denominator.
- std::transform(dividend.begin(), dividend.end(), dividend.begin(),
- [gcd](DynamicAPInt &n) { return floorDiv(n, gcd); });
+ llvm::transform(dividend, dividend.begin(),
+ [gcd](DynamicAPInt &n) { return floorDiv(n, gcd); });
divisor /= gcd;
}
@@ -331,8 +331,7 @@ presburger::getDivLowerBound(ArrayRef<DynamicAPInt> dividend,
assert(dividend[localVarIdx] == 0 &&
"Local to be set to division must have zero coeff!");
SmallVector<DynamicAPInt, 8> ineq(dividend.size());
- std::transform(dividend.begin(), dividend.end(), ineq.begin(),
- std::negate<DynamicAPInt>());
+ llvm::transform(dividend, ineq.begin(), std::negate<DynamicAPInt>());
ineq[localVarIdx] = divisor;
ineq.back() += divisor - 1;
return ineq;
@@ -522,15 +521,13 @@ void DivisionRepr::dump() const { print(llvm::errs()); }
SmallVector<DynamicAPInt, 8>
presburger::getDynamicAPIntVec(ArrayRef<int64_t> range) {
SmallVector<DynamicAPInt, 8> result(range.size());
- std::transform(range.begin(), range.end(), result.begin(),
- dynamicAPIntFromInt64);
+ llvm::transform(range, result.begin(), dynamicAPIntFromInt64);
return result;
}
SmallVector<int64_t, 8> presburger::getInt64Vec(ArrayRef<DynamicAPInt> range) {
SmallVector<int64_t, 8> result(range.size());
- std::transform(range.begin(), range.end(), result.begin(),
- int64fromDynamicAPInt);
+ llvm::transform(range, result.begin(), int64fromDynamicAPInt);
return result;
}
diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
index b405ec2201bf8..edfae7ee96039 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
@@ -342,8 +342,7 @@ void FlatAffineValueConstraints::getIneqAsAffineValueMap(
if (inequality[pos] > 0)
// Lower bound.
- std::transform(bound.begin(), bound.end(), bound.begin(),
- std::negate<int64_t>());
+ llvm::transform(bound, bound.begin(), std::negate<int64_t>());
else
// Upper bound (which is exclusive).
bound.back() += 1;
diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
index bf3810ff231da..5823914967e9c 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
@@ -2628,7 +2628,7 @@ static LogicalResult verifyZeroPoint(T op, Value val, const int64_t &zp,
if (!zpElemType.isInteger(8) && zp != 0) {
// convert operand to lower case for error message
std::string lower = operand;
- std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
+ llvm::transform(lower, lower.begin(), ::tolower);
return op.emitOpError()
<< lower << " zero point must be zero for non-int8 integer types";
}
diff --git a/mlir/lib/IR/PatternMatch.cpp b/mlir/lib/IR/PatternMatch.cpp
index 9332f55bd9393..f015f7c9e9066 100644
--- a/mlir/lib/IR/PatternMatch.cpp
+++ b/mlir/lib/IR/PatternMatch.cpp
@@ -80,10 +80,9 @@ Pattern::Pattern(const void *rootValue, RootKind rootKind,
if (generatedNames.empty())
return;
generatedOps.reserve(generatedNames.size());
- std::transform(generatedNames.begin(), generatedNames.end(),
- std::back_inserter(generatedOps), [context](StringRef name) {
- return OperationName(name, context);
- });
+ llvm::transform(
+ generatedNames, std::back_inserter(generatedOps),
+ [context](StringRef name) { return OperationName(name, context); });
}
//===----------------------------------------------------------------------===//
|
|
@llvm/pr-subscribers-mlir-tosa Author: Kazu Hirata (kazutakahirata) ChangesIdentified with llvm-use-ranges. Full diff: https://github.com/llvm/llvm-project/pull/167205.diff 6 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h b/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h
index 452d4f6b4ed61..d996db88fcb2a 100644
--- a/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h
+++ b/mlir/include/mlir/Dialect/Shard/Transforms/Simplifications.h
@@ -50,10 +50,8 @@ void populateAllReduceEndomorphismSimplificationPatterns(
auto getAlgebraicOpOperands = [](Operation *op,
SmallVector<OpOperand *> &operands) {
auto algebraicOp = llvm::cast<AlgebraicOp>(op);
- std::transform(algebraicOp->getOpOperands().begin(),
- algebraicOp->getOpOperands().end(),
- std::back_inserter(operands),
- [](OpOperand &operand) { return &operand; });
+ llvm::transform(algebraicOp->getOpOperands(), std::back_inserter(operands),
+ [](OpOperand &operand) { return &operand; });
};
auto getAlgebraicOpResult = [](Operation *op) {
auto algebraicOp = llvm::cast<AlgebraicOp>(op);
diff --git a/mlir/lib/Analysis/FlatLinearValueConstraints.cpp b/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
index 6588b53cbd9f8..0e0c5f2159382 100644
--- a/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
+++ b/mlir/lib/Analysis/FlatLinearValueConstraints.cpp
@@ -530,7 +530,7 @@ std::pair<AffineMap, AffineMap> FlatLinearConstraints::getLowerAndUpperBound(
// i - j + 1 >= 0 is the constraint, 'pos' is for i the lower bound is j
// - 1.
addCoeffs(ineq, lb);
- std::transform(lb.begin(), lb.end(), lb.begin(), std::negate<int64_t>());
+ llvm::transform(lb, lb.begin(), std::negate<int64_t>());
auto expr =
getAffineExprFromFlatForm(lb, dimCount, symCount, localExprs, context);
// expr ceildiv divisor is (expr + divisor - 1) floordiv divisor
@@ -559,7 +559,7 @@ std::pair<AffineMap, AffineMap> FlatLinearConstraints::getLowerAndUpperBound(
auto eq = getEquality64(idx);
addCoeffs(eq, b);
if (eq[pos + offset] > 0)
- std::transform(b.begin(), b.end(), b.begin(), std::negate<int64_t>());
+ llvm::transform(b, b.begin(), std::negate<int64_t>());
// Extract the upper bound (in terms of other coeff's + const).
auto expr =
diff --git a/mlir/lib/Analysis/Presburger/Utils.cpp b/mlir/lib/Analysis/Presburger/Utils.cpp
index 2aaa4c033d0ce..b06a8a1b9ccf8 100644
--- a/mlir/lib/Analysis/Presburger/Utils.cpp
+++ b/mlir/lib/Analysis/Presburger/Utils.cpp
@@ -52,8 +52,8 @@ static void normalizeDivisionByGCD(MutableArrayRef<DynamicAPInt> dividend,
}
// Normalize the dividend and the denominator.
- std::transform(dividend.begin(), dividend.end(), dividend.begin(),
- [gcd](DynamicAPInt &n) { return floorDiv(n, gcd); });
+ llvm::transform(dividend, dividend.begin(),
+ [gcd](DynamicAPInt &n) { return floorDiv(n, gcd); });
divisor /= gcd;
}
@@ -331,8 +331,7 @@ presburger::getDivLowerBound(ArrayRef<DynamicAPInt> dividend,
assert(dividend[localVarIdx] == 0 &&
"Local to be set to division must have zero coeff!");
SmallVector<DynamicAPInt, 8> ineq(dividend.size());
- std::transform(dividend.begin(), dividend.end(), ineq.begin(),
- std::negate<DynamicAPInt>());
+ llvm::transform(dividend, ineq.begin(), std::negate<DynamicAPInt>());
ineq[localVarIdx] = divisor;
ineq.back() += divisor - 1;
return ineq;
@@ -522,15 +521,13 @@ void DivisionRepr::dump() const { print(llvm::errs()); }
SmallVector<DynamicAPInt, 8>
presburger::getDynamicAPIntVec(ArrayRef<int64_t> range) {
SmallVector<DynamicAPInt, 8> result(range.size());
- std::transform(range.begin(), range.end(), result.begin(),
- dynamicAPIntFromInt64);
+ llvm::transform(range, result.begin(), dynamicAPIntFromInt64);
return result;
}
SmallVector<int64_t, 8> presburger::getInt64Vec(ArrayRef<DynamicAPInt> range) {
SmallVector<int64_t, 8> result(range.size());
- std::transform(range.begin(), range.end(), result.begin(),
- int64fromDynamicAPInt);
+ llvm::transform(range, result.begin(), int64fromDynamicAPInt);
return result;
}
diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
index b405ec2201bf8..edfae7ee96039 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
@@ -342,8 +342,7 @@ void FlatAffineValueConstraints::getIneqAsAffineValueMap(
if (inequality[pos] > 0)
// Lower bound.
- std::transform(bound.begin(), bound.end(), bound.begin(),
- std::negate<int64_t>());
+ llvm::transform(bound, bound.begin(), std::negate<int64_t>());
else
// Upper bound (which is exclusive).
bound.back() += 1;
diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
index bf3810ff231da..5823914967e9c 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
@@ -2628,7 +2628,7 @@ static LogicalResult verifyZeroPoint(T op, Value val, const int64_t &zp,
if (!zpElemType.isInteger(8) && zp != 0) {
// convert operand to lower case for error message
std::string lower = operand;
- std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
+ llvm::transform(lower, lower.begin(), ::tolower);
return op.emitOpError()
<< lower << " zero point must be zero for non-int8 integer types";
}
diff --git a/mlir/lib/IR/PatternMatch.cpp b/mlir/lib/IR/PatternMatch.cpp
index 9332f55bd9393..f015f7c9e9066 100644
--- a/mlir/lib/IR/PatternMatch.cpp
+++ b/mlir/lib/IR/PatternMatch.cpp
@@ -80,10 +80,9 @@ Pattern::Pattern(const void *rootValue, RootKind rootKind,
if (generatedNames.empty())
return;
generatedOps.reserve(generatedNames.size());
- std::transform(generatedNames.begin(), generatedNames.end(),
- std::back_inserter(generatedOps), [context](StringRef name) {
- return OperationName(name, context);
- });
+ llvm::transform(
+ generatedNames, std::back_inserter(generatedOps),
+ [context](StringRef name) { return OperationName(name, context); });
}
//===----------------------------------------------------------------------===//
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/129/builds/32743 Here is the relevant piece of the build log for the reference |
Identified with llvm-use-ranges.