SmallVector<Value> operands;
for (Value operand : op.getInputs()) {
- if (auto assume_all = operand.getDefiningOp<AssumingAllOp>())
- operands.append(assume_all.operand_begin(), assume_all->operand_end());
+ if (auto assumeAll = operand.getDefiningOp<AssumingAllOp>())
+ operands.append(assumeAll.operand_begin(), assumeAll->operand_end());
else
operands.push_back(operand);
}
// Collect shapes checked by `cstr_broadcastable` operands.
SmallVector<std::pair<CstrBroadcastableOp, DenseSet<Value>>> shapes;
for (auto cstr : operands) {
- DenseSet<Value> shapes_set(cstr->operand_begin(), cstr->operand_end());
- shapes.emplace_back(cstr, std::move(shapes_set));
+ DenseSet<Value> shapesSet(cstr->operand_begin(), cstr->operand_end());
+ shapes.emplace_back(cstr, std::move(shapesSet));
}
// Sort by the number of shape operands (larger to smaller).
// shape operands, and remove redundant `cst_broadcastable` operations. We
// do this until we find a set of `cst_broadcastable` operations with
// non-overlapping constraints.
- SmallVector<CstrBroadcastableOp> marked_for_erase;
+ SmallVector<CstrBroadcastableOp> markedForErase;
for (unsigned i = 0; i < shapes.size(); ++i) {
auto isSubset = [&](auto pair) {
// Keep redundant `cstr_broadcastable` operations to be erased.
auto *it = std::remove_if(shapes.begin() + i + 1, shapes.end(), isSubset);
for (auto *it0 = it; it0 < shapes.end(); ++it0)
- marked_for_erase.push_back(it0->first);
+ markedForErase.push_back(it0->first);
shapes.erase(it, shapes.end());
}
// We didn't find any operands that could be removed.
- if (marked_for_erase.empty())
+ if (markedForErase.empty())
return failure();
// Collect non-overlapping `cst_broadcastable` constraints.
- SmallVector<Value> unique_constraints;
+ SmallVector<Value> uniqueConstraints;
for (auto &shape : shapes)
- unique_constraints.push_back(shape.first.getResult());
+ uniqueConstraints.push_back(shape.first.getResult());
// Replace with a new `assuming_all` operation ...
- rewriter.replaceOpWithNewOp<AssumingAllOp>(op, unique_constraints);
+ rewriter.replaceOpWithNewOp<AssumingAllOp>(op, uniqueConstraints);
// ... and maybe erase `cstr_broadcastable` ops without uses.
- for (auto &op : marked_for_erase)
+ for (auto &op : markedForErase)
if (op->use_empty())
rewriter.eraseOp(op);