Skip to content

Commit 972ac59

Browse files
authored
[mlir][NFC] update mlir/Dialect create APIs (21/n) (#149928)
See #147168 for more info.
1 parent 37f0f10 commit 972ac59

22 files changed

+1003
-971
lines changed

mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,8 @@ SparseTensorEncodingAttr::translateCrds(OpBuilder &builder, Location loc,
559559
SmallVector<Type> retType(
560560
dir == CrdTransDirectionKind::lvl2dim ? getDimRank() : getLvlRank(),
561561
builder.getIndexType());
562-
auto transOp = builder.create<CrdTranslateOp>(loc, retType, crds, dir, *this);
562+
auto transOp =
563+
CrdTranslateOp::create(builder, loc, retType, crds, dir, *this);
563564
return transOp.getOutCrds();
564565
}
565566

@@ -1481,7 +1482,7 @@ LogicalResult CrdTranslateOp::fold(FoldAdaptor adaptor,
14811482

14821483
void LvlOp::build(OpBuilder &builder, OperationState &state, Value source,
14831484
int64_t index) {
1484-
Value val = builder.create<arith::ConstantIndexOp>(state.location, index);
1485+
Value val = arith::ConstantIndexOp::create(builder, state.location, index);
14851486
return build(builder, state, source, val);
14861487
}
14871488

mlir/lib/Dialect/SparseTensor/IR/SparseTensorInterfaces.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ LogicalResult sparse_tensor::detail::stageWithSortImpl(
4141

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

4747
// -> dest.
4848
if (dstCOO.getType() == finalTp) {

mlir/lib/Dialect/SparseTensor/Transforms/SparseAssembler.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ static void convVals(OpBuilder &builder, Location loc, TypeRange types,
8888
} else if (directOut) {
8989
Value mem;
9090
if (kind == SparseTensorFieldKind::PosMemRef)
91-
mem = builder.create<sparse_tensor::ToPositionsOp>(loc, inputs[0],
92-
lv);
91+
mem = sparse_tensor::ToPositionsOp::create(builder, loc, inputs[0],
92+
lv);
9393
else if (kind == SparseTensorFieldKind::CrdMemRef)
94-
mem = builder.create<sparse_tensor::ToCoordinatesOp>(loc, inputs[0],
95-
lv);
94+
mem = sparse_tensor::ToCoordinatesOp::create(builder, loc,
95+
inputs[0], lv);
9696
else
97-
mem = builder.create<sparse_tensor::ToValuesOp>(loc, inputs[0]);
97+
mem = sparse_tensor::ToValuesOp::create(builder, loc, inputs[0]);
9898
toVals.push_back(mem);
9999
} else {
100100
ShapedType rtp = cast<ShapedType>(t);
@@ -109,15 +109,15 @@ static void convVals(OpBuilder &builder, Location loc, TypeRange types,
109109

110110
if (isIn) {
111111
// Assemble multiple inputs into a single sparse tensor.
112-
auto a = builder.create<sparse_tensor::AssembleOp>(loc, rtp, inputs);
112+
auto a = sparse_tensor::AssembleOp::create(builder, loc, rtp, inputs);
113113
toVals.push_back(a.getResult());
114114
} else if (!directOut) {
115115
// Disassemble a single sparse input into multiple outputs.
116116
// Note that this includes the counters, which are dropped.
117117
unsigned len = retTypes.size();
118118
retTypes.append(cntTypes);
119119
auto d =
120-
builder.create<sparse_tensor::DisassembleOp>(loc, retTypes, inputs);
120+
sparse_tensor::DisassembleOp::create(builder, loc, retTypes, inputs);
121121
for (unsigned i = 0; i < len; i++)
122122
toVals.push_back(d.getResult(i));
123123
}
@@ -199,8 +199,9 @@ struct SparseFuncAssembler : public OpRewritePattern<func::FuncOp> {
199199
OpBuilder moduleBuilder(modOp.getBodyRegion());
200200
unsigned extra = inputTypes.size();
201201
inputTypes.append(extraTypes);
202-
auto func = moduleBuilder.create<func::FuncOp>(
203-
loc, orgName, FunctionType::get(context, inputTypes, outputTypes));
202+
auto func = func::FuncOp::create(
203+
moduleBuilder, loc, orgName,
204+
FunctionType::get(context, inputTypes, outputTypes));
204205
func.setPublic();
205206

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

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

228229
// Finally, migrate a potential c-interface property.
229230
if (funcOp->getAttrOfType<UnitAttr>(

0 commit comments

Comments
 (0)