Skip to content

[mlir][NFC] update mlir/Dialect create APIs (21/n) #149928

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
Jul 22, 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
5 changes: 3 additions & 2 deletions mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ SparseTensorEncodingAttr::translateCrds(OpBuilder &builder, Location loc,
SmallVector<Type> retType(
dir == CrdTransDirectionKind::lvl2dim ? getDimRank() : getLvlRank(),
builder.getIndexType());
auto transOp = builder.create<CrdTranslateOp>(loc, retType, crds, dir, *this);
auto transOp =
CrdTranslateOp::create(builder, loc, retType, crds, dir, *this);
return transOp.getOutCrds();
}

Expand Down Expand Up @@ -1481,7 +1482,7 @@ LogicalResult CrdTranslateOp::fold(FoldAdaptor adaptor,

void LvlOp::build(OpBuilder &builder, OperationState &state, Value source,
int64_t index) {
Value val = builder.create<arith::ConstantIndexOp>(state.location, index);
Value val = arith::ConstantIndexOp::create(builder, state.location, index);
return build(builder, state, source, val);
}

Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/SparseTensor/IR/SparseTensorInterfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ LogicalResult sparse_tensor::detail::stageWithSortImpl(

// -> sort
Type dstCOOTp = dstStt.getCOOType(/*ordered=*/true);
Value dstCOO = rewriter.create<ReorderCOOOp>(
loc, dstCOOTp, srcCOO, SparseTensorSortKind::HybridQuickSort);
Value dstCOO = ReorderCOOOp::create(rewriter, loc, dstCOOTp, srcCOO,
SparseTensorSortKind::HybridQuickSort);

// -> dest.
if (dstCOO.getType() == finalTp) {
Expand Down
25 changes: 13 additions & 12 deletions mlir/lib/Dialect/SparseTensor/Transforms/SparseAssembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ static void convVals(OpBuilder &builder, Location loc, TypeRange types,
} else if (directOut) {
Value mem;
if (kind == SparseTensorFieldKind::PosMemRef)
mem = builder.create<sparse_tensor::ToPositionsOp>(loc, inputs[0],
lv);
mem = sparse_tensor::ToPositionsOp::create(builder, loc, inputs[0],
lv);
else if (kind == SparseTensorFieldKind::CrdMemRef)
mem = builder.create<sparse_tensor::ToCoordinatesOp>(loc, inputs[0],
lv);
mem = sparse_tensor::ToCoordinatesOp::create(builder, loc,
inputs[0], lv);
else
mem = builder.create<sparse_tensor::ToValuesOp>(loc, inputs[0]);
mem = sparse_tensor::ToValuesOp::create(builder, loc, inputs[0]);
toVals.push_back(mem);
} else {
ShapedType rtp = cast<ShapedType>(t);
Expand All @@ -109,15 +109,15 @@ static void convVals(OpBuilder &builder, Location loc, TypeRange types,

if (isIn) {
// Assemble multiple inputs into a single sparse tensor.
auto a = builder.create<sparse_tensor::AssembleOp>(loc, rtp, inputs);
auto a = sparse_tensor::AssembleOp::create(builder, loc, rtp, inputs);
toVals.push_back(a.getResult());
} else if (!directOut) {
// Disassemble a single sparse input into multiple outputs.
// Note that this includes the counters, which are dropped.
unsigned len = retTypes.size();
retTypes.append(cntTypes);
auto d =
builder.create<sparse_tensor::DisassembleOp>(loc, retTypes, inputs);
sparse_tensor::DisassembleOp::create(builder, loc, retTypes, inputs);
for (unsigned i = 0; i < len; i++)
toVals.push_back(d.getResult(i));
}
Expand Down Expand Up @@ -199,8 +199,9 @@ struct SparseFuncAssembler : public OpRewritePattern<func::FuncOp> {
OpBuilder moduleBuilder(modOp.getBodyRegion());
unsigned extra = inputTypes.size();
inputTypes.append(extraTypes);
auto func = moduleBuilder.create<func::FuncOp>(
loc, orgName, FunctionType::get(context, inputTypes, outputTypes));
auto func = func::FuncOp::create(
moduleBuilder, loc, orgName,
FunctionType::get(context, inputTypes, outputTypes));
func.setPublic();

// Construct new wrapper method body.
Expand All @@ -216,14 +217,14 @@ struct SparseFuncAssembler : public OpRewritePattern<func::FuncOp> {
// Call the original, now private method. A subsequent inlining pass can
// determine whether cloning the method body in place is worthwhile.
auto org = SymbolRefAttr::get(context, wrapper);
auto call = rewriter.create<func::CallOp>(loc, funcOp.getResultTypes(), org,
inputs);
auto call = func::CallOp::create(rewriter, loc, funcOp.getResultTypes(),
org, inputs);

// Convert outputs and return.
SmallVector<Value> outputs;
convVals(rewriter, loc, funcOp.getResultTypes(), call.getResults(),
body->getArguments(), outputs, extra, /*isIn=*/false, directOut);
rewriter.create<func::ReturnOp>(loc, outputs);
func::ReturnOp::create(rewriter, loc, outputs);

// Finally, migrate a potential c-interface property.
if (funcOp->getAttrOfType<UnitAttr>(
Expand Down
Loading
Loading