Skip to content

[mlir][transform] Clean up prints. NFC. #136401

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
Apr 19, 2025
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
48 changes: 20 additions & 28 deletions mlir/lib/Dialect/GPU/TransformOps/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/InterleavedRange.h"

using namespace mlir;
using namespace mlir::gpu;
Expand All @@ -50,10 +51,8 @@ using namespace mlir::transform::gpu;
template <typename ThreadOrBlockIdOp>
static Value buildLinearId(RewriterBase &rewriter, Location loc,
ArrayRef<OpFoldResult> originalBasisOfr) {
LLVM_DEBUG(llvm::interleaveComma(
originalBasisOfr,
DBGS() << "----buildLinearId with originalBasisOfr: ");
llvm::dbgs() << "\n");
LLVM_DEBUG(DBGS() << "----buildLinearId with originalBasisOfr: "
<< llvm::interleaved(originalBasisOfr) << "\n");
assert(originalBasisOfr.size() == 3 && "expected 3 sizes");
IndexType indexType = rewriter.getIndexType();
AffineExpr tx, ty, tz, bdx, bdy;
Expand Down Expand Up @@ -99,32 +98,25 @@ static GpuIdBuilderFnType commonLinearIdBuilderFn(int64_t multiplicity = 1) {
affine::makeComposedAffineApply(rewriter, loc, e, {scaledLinearId}));
}

// clang-format off
LLVM_DEBUG(llvm::interleaveComma(reverseBasisSizes,
DBGS() << "--delinearization basis: ");
llvm::dbgs() << "\n";
llvm::interleaveComma(strides,
DBGS() << "--delinearization strides: ");
llvm::dbgs() << "\n";
llvm::interleaveComma(delinearizingExprs,
DBGS() << "--delinearization exprs: ");
llvm::dbgs() << "\n";
llvm::interleaveComma(ids, DBGS() << "--ids: ");
llvm::dbgs() << "\n";);
// clang-format on
LLVM_DEBUG(DBGS() << "--delinearization basis: "
<< llvm::interleaved(reverseBasisSizes) << "\n";
DBGS() << "--delinearization strides: "
<< llvm::interleaved(strides) << "\n";
DBGS() << "--delinearization exprs: "
<< llvm::interleaved(delinearizingExprs) << "\n";
DBGS() << "--ids: " << llvm::interleaved(ids) << "\n");

// Return n-D ids for indexing and 1-D size + id for predicate generation.
return IdBuilderResult{
/*mappingIdOps=*/ids,
/*availableMappingSizes=*/
SmallVector<int64_t>{computeProduct(originalBasis)},
// `forallMappingSizes` iterate in the scaled basis, they need to be
// scaled back into the original basis to provide tight
// activeMappingSizes quantities for predication.
/*activeMappingSizes=*/
SmallVector<int64_t>{computeProduct(forallMappingSizes) *
multiplicity},
/*activeIdOps=*/SmallVector<Value>{cast<Value>(linearId)}};
return IdBuilderResult{
/*mappingIdOps=*/ids,
/*availableMappingSizes=*/
SmallVector<int64_t>{computeProduct(originalBasis)},
// `forallMappingSizes` iterate in the scaled basis, they need to be
// scaled back into the original basis to provide tight
// activeMappingSizes quantities for predication.
/*activeMappingSizes=*/
SmallVector<int64_t>{computeProduct(forallMappingSizes) * multiplicity},
/*activeIdOps=*/SmallVector<Value>{cast<Value>(linearId)}};
};

return res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "mlir/Dialect/Transform/IR/TransformDialect.h"
#include "mlir/Dialect/Transform/IR/TransformTypes.h"
#include "mlir/IR/OpImplementation.h"
#include "llvm/Support/InterleavedRange.h"

using namespace mlir;

Expand Down Expand Up @@ -58,7 +59,7 @@ DiagnosedSilenceableFailure transform::DebugEmitParamAsRemarkOp::apply(
llvm::raw_string_ostream os(str);
if (getMessage())
os << *getMessage() << " ";
llvm::interleaveComma(state.getParams(getParam()), os);
os << llvm::interleaved(state.getParams(getParam()));
if (!getAnchor()) {
emitRemark() << str;
return DiagnosedSilenceableFailure::success();
Expand Down
8 changes: 3 additions & 5 deletions mlir/lib/Dialect/Transform/IR/TransformOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/InterleavedRange.h"
#include <optional>

#define DEBUG_TYPE "transform-dialect"
Expand Down Expand Up @@ -2630,11 +2631,8 @@ static void printSequenceOpOperands(OpAsmPrinter &printer, Operation *op,
printer << "(";

printer << rootType;
if (hasExtras) {
printer << ", ";
llvm::interleaveComma(extraBindingTypes, printer.getStream());
printer << ")";
}
if (hasExtras)
printer << ", " << llvm::interleaved(extraBindingTypes) << ')';
}

/// Returns `true` if the given op operand may be consuming the handle value in
Expand Down
5 changes: 3 additions & 2 deletions mlir/lib/Dialect/Transform/Interfaces/MatchInterfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include "mlir/Dialect/Transform/Interfaces/MatchInterfaces.h"

#include "llvm/Support/InterleavedRange.h"

using namespace mlir;

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -68,8 +70,7 @@ void transform::printTransformMatchDims(OpAsmPrinter &printer, Operation *op,
if (isInverted) {
printer << kDimExceptKeyword << "(";
}
llvm::interleaveComma(rawDimList.asArrayRef(), printer.getStream(),
[&](int64_t value) { printer << value; });
printer << llvm::interleaved(rawDimList.asArrayRef());
if (isInverted) {
printer << ")";
}
Expand Down
12 changes: 7 additions & 5 deletions mlir/lib/Dialect/Transform/Interfaces/TransformInterfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/iterator.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/InterleavedRange.h"

#define DEBUG_TYPE "transform-dialect"
#define DEBUG_TYPE_FULL "transform-dialect-full"
Expand Down Expand Up @@ -486,11 +488,11 @@ void transform::TransformState::recordOpHandleInvalidationOne(
return;

FULL_LDBG("--recordOpHandleInvalidationOne\n");
DEBUG_WITH_TYPE(
DEBUG_TYPE_FULL,
llvm::interleaveComma(potentialAncestors, DBGS() << "--ancestors: ",
[](Operation *op) { llvm::dbgs() << *op; });
llvm::dbgs() << "\n");
DEBUG_WITH_TYPE(DEBUG_TYPE_FULL, {
(DBGS() << "--ancestors: "
<< llvm::interleaved(llvm::make_pointee_range(potentialAncestors))
<< "\n");
});

Operation *owner = consumingHandle.getOwner();
unsigned operandNo = consumingHandle.getOperandNumber();
Expand Down
5 changes: 2 additions & 3 deletions mlir/lib/Dialect/XeGPU/Transforms/XeGPUSubgroupDistribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "mlir/IR/Builders.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/InterleavedRange.h"
#include "llvm/Support/raw_ostream.h"

namespace mlir {
Expand Down Expand Up @@ -58,9 +59,7 @@ struct Layout {
};

void Layout::print(llvm::raw_ostream &os) const {
os << "[";
llvm::interleaveComma(layout, os);
os << "]";
os << llvm::interleaved_array(layout);
}

int64_t Layout::operator[](size_t idx) const {
Expand Down
Loading