Skip to content

[mlir][Interfaces] ValueBoundsConstraintSet: Add dump helper function #86634

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

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ class ValueBoundsConstraintSet
/// Return an expression that represents a constant.
AffineExpr getExpr(int64_t constant);

/// Debugging only: Dump the constraint set and the column-to-value/dim
/// mapping to llvm::errs.
void dump() const;

protected:
/// Dimension identifier to indicate a value is index-typed. This is used for
/// internal data structures/API only.
Expand Down
29 changes: 29 additions & 0 deletions mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,35 @@ ValueBoundsConstraintSet::areEquivalentSlices(MLIRContext *ctx,
return true;
}

void ValueBoundsConstraintSet::dump() const {
llvm::errs() << "==========\nColumns:\n";
llvm::errs() << "(column\tdim\tvalue)\n";
for (auto [index, valueDim] : llvm::enumerate(positionToValueDim)) {
llvm::errs() << " " << index << "\t";
if (valueDim) {
if (valueDim->second == kIndexValue) {
llvm::errs() << "n/a\t";
} else {
llvm::errs() << valueDim->second << "\t";
}
llvm::errs() << getOwnerOfValue(valueDim->first)->getName() << " ";
if (OpResult result = dyn_cast<OpResult>(valueDim->first)) {
llvm::errs() << "(result " << result.getResultNumber() << ")";
} else {
llvm::errs() << "(bbarg "
<< cast<BlockArgument>(valueDim->first).getArgNumber()
<< ")";
}
llvm::errs() << "\n";
} else {
llvm::errs() << "n/a\tn/a\n";
}
}
llvm::errs() << "\nConstraint set:\n";
cstr.dump();
llvm::errs() << "==========\n";
}

ValueBoundsConstraintSet::BoundBuilder &
ValueBoundsConstraintSet::BoundBuilder::operator[](int64_t dim) {
assert(!this->dim.has_value() && "dim was already set");
Expand Down