Skip to content

Commit 1218998

Browse files
committed
Adding new create methods
Following llvm#147168
1 parent 32f3566 commit 1218998

File tree

3 files changed

+210
-11
lines changed

3 files changed

+210
-11
lines changed

mlir/include/mlir/Dialect/Linalg/IR/Linalg.h

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,33 @@ class MatmulTransposeAOp : public MatmulOp {
160160
ValueRange inputs, ValueRange outputs,
161161
ArrayRef<NamedAttribute> attributes = {});
162162

163+
static MatmulTransposeAOp create(OpBuilder &builder, Location location,
164+
ValueRange inputs, ValueRange outputs,
165+
ArrayRef<NamedAttribute> attributes = {});
166+
163167
/// Build a transpose A matmul with a specific result type.
164168
static void build(OpBuilder &builder, OperationState &result,
165169
TypeRange resultTensorTypes, ValueRange inputs,
166170
ValueRange outputs,
167171
ArrayRef<NamedAttribute> attributes = {});
168172

173+
static MatmulTransposeAOp create(OpBuilder &builder, Location location,
174+
TypeRange resultTensorTypes,
175+
ValueRange inputs, ValueRange outputs,
176+
ArrayRef<NamedAttribute> attributes = {});
177+
169178
/// Build a transpose A matmul with a specific result type and a cast type.
170179
static void build(OpBuilder &builder, OperationState &result,
171180
TypeRange resultTensorTypes, ValueRange inputs,
172181
ValueRange outputs, Attribute cast,
173182
ArrayRef<NamedAttribute> attributes = {});
174183

184+
static MatmulTransposeAOp create(OpBuilder &builder, Location location,
185+
TypeRange resultTensorTypes,
186+
ValueRange inputs, ValueRange outputs,
187+
Attribute cast,
188+
ArrayRef<NamedAttribute> attributes = {});
189+
175190
/// Checks if the affine map is the expected one for this operation
176191
static bool isExpectedAffineMaps(Attribute attr);
177192

@@ -192,18 +207,33 @@ class MatmulTransposeBOp : public MatmulOp {
192207
ValueRange inputs, ValueRange outputs,
193208
ArrayRef<NamedAttribute> attributes = {});
194209

210+
static MatmulTransposeBOp create(OpBuilder &builder, Location location,
211+
ValueRange inputs, ValueRange outputs,
212+
ArrayRef<NamedAttribute> attributes = {});
213+
195214
/// Build a transpose B matmul with a specific result type.
196215
static void build(OpBuilder &builder, OperationState &result,
197216
TypeRange resultTensorTypes, ValueRange inputs,
198217
ValueRange outputs,
199218
ArrayRef<NamedAttribute> attributes = {});
200219

220+
static MatmulTransposeBOp create(OpBuilder &builder, Location location,
221+
TypeRange resultTensorTypes,
222+
ValueRange inputs, ValueRange outputs,
223+
ArrayRef<NamedAttribute> attributes = {});
224+
201225
/// Build a transpose B matmul with a specific result type and a cast type.
202226
static void build(OpBuilder &builder, OperationState &result,
203227
TypeRange resultTensorTypes, ValueRange inputs,
204228
ValueRange outputs, Attribute cast,
205229
ArrayRef<NamedAttribute> attributes = {});
206230

231+
static MatmulTransposeBOp create(OpBuilder &builder, Location location,
232+
TypeRange resultTensorTypes,
233+
ValueRange inputs, ValueRange outputs,
234+
Attribute cast,
235+
ArrayRef<NamedAttribute> attributes = {});
236+
207237
/// Checks if the affine map is the expected one for this operation
208238
static bool isExpectedAffineMaps(Attribute attr);
209239

@@ -225,18 +255,32 @@ class BatchMatmulTransposeAOp : public BatchMatmulOp {
225255
ValueRange inputs, ValueRange outputs,
226256
ArrayRef<NamedAttribute> attributes = {});
227257

258+
static BatchMatmulTransposeAOp
259+
create(OpBuilder &builder, Location location, ValueRange inputs,
260+
ValueRange outputs, ArrayRef<NamedAttribute> attributes = {});
261+
228262
/// Build a transpose A matmul with a specific result type.
229263
static void build(OpBuilder &builder, OperationState &result,
230264
TypeRange resultTensorTypes, ValueRange inputs,
231265
ValueRange outputs,
232266
ArrayRef<NamedAttribute> attributes = {});
233267

268+
static BatchMatmulTransposeAOp
269+
create(OpBuilder &builder, Location location, TypeRange resultTensorTypes,
270+
ValueRange inputs, ValueRange outputs,
271+
ArrayRef<NamedAttribute> attributes = {});
272+
234273
/// Build a transpose A matmul with a specific result type and a cast type.
235274
static void build(OpBuilder &builder, OperationState &result,
236275
TypeRange resultTensorTypes, ValueRange inputs,
237276
ValueRange outputs, Attribute cast,
238277
ArrayRef<NamedAttribute> attributes = {});
239278

279+
static BatchMatmulTransposeAOp
280+
create(OpBuilder &builder, Location location, TypeRange resultTensorTypes,
281+
ValueRange inputs, ValueRange outputs, Attribute cast,
282+
ArrayRef<NamedAttribute> attributes = {});
283+
240284
/// Checks if the affine map is the expected one for this operation
241285
static bool isExpectedAffineMaps(Attribute attr);
242286

@@ -253,23 +297,37 @@ class BatchMatmulTransposeBOp : public BatchMatmulOp {
253297
using BatchMatmulOp::BatchMatmulOp;
254298
static ::mlir::TypeID resolveTypeID() { return TypeID::get<BatchMatmulOp>(); }
255299

256-
/// Build a transpose A matmul.
300+
/// Build a transpose B matmul.
257301
static void build(OpBuilder &builder, OperationState &result,
258302
ValueRange inputs, ValueRange outputs,
259303
ArrayRef<NamedAttribute> attributes = {});
260304

261-
/// Build a transpose A matmul with a specific result type.
305+
static BatchMatmulTransposeBOp
306+
create(OpBuilder &builder, Location location, ValueRange inputs,
307+
ValueRange outputs, ArrayRef<NamedAttribute> attributes = {});
308+
309+
/// Build a transpose B matmul with a specific result type.
262310
static void build(OpBuilder &builder, OperationState &result,
263311
TypeRange resultTensorTypes, ValueRange inputs,
264312
ValueRange outputs,
265313
ArrayRef<NamedAttribute> attributes = {});
266314

267-
/// Build a transpose A matmul with a specific result type and a cast type.
315+
static BatchMatmulTransposeBOp
316+
create(OpBuilder &builder, Location location, TypeRange resultTensorTypes,
317+
ValueRange inputs, ValueRange outputs,
318+
ArrayRef<NamedAttribute> attributes = {});
319+
320+
/// Build a transpose B matmul with a specific result type and a cast type.
268321
static void build(OpBuilder &builder, OperationState &result,
269322
TypeRange resultTensorTypes, ValueRange inputs,
270323
ValueRange outputs, Attribute cast,
271324
ArrayRef<NamedAttribute> attributes = {});
272325

326+
static BatchMatmulTransposeBOp
327+
create(OpBuilder &builder, Location location, TypeRange resultTensorTypes,
328+
ValueRange inputs, ValueRange outputs, Attribute cast,
329+
ArrayRef<NamedAttribute> attributes = {});
330+
273331
/// Checks if the affine map is the expected one for this operation
274332
static bool isExpectedAffineMaps(Attribute attr);
275333

mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3924,6 +3924,7 @@ bool MatmulTransposeAOp::isExpectedAffineMaps(Attribute attr) {
39243924
(*positions)[1] == SmallVector<int64_t>{2, 1} &&
39253925
(*positions)[2] == SmallVector<int64_t>{0, 1};
39263926
}
3927+
39273928
void linalg::MatmulTransposeAOp::build(OpBuilder &builder,
39283929
OperationState &result,
39293930
ValueRange inputs, ValueRange outputs,
@@ -3932,6 +3933,17 @@ void linalg::MatmulTransposeAOp::build(OpBuilder &builder,
39323933
MatmulOp::getRegionBuilder(), getAffineMaps(builder));
39333934
}
39343935

3936+
MatmulTransposeAOp
3937+
MatmulTransposeAOp::create(OpBuilder &builder, Location location,
3938+
ValueRange inputs, ValueRange outputs,
3939+
ArrayRef<NamedAttribute> attributes) {
3940+
OperationState state(location, getOperationName());
3941+
build(builder, state, inputs, outputs, attributes);
3942+
auto res = dyn_cast<MatmulTransposeAOp>(builder.create(state));
3943+
assert(res && "builder didn't return the right type");
3944+
return res;
3945+
}
3946+
39353947
void linalg::MatmulTransposeAOp::build(OpBuilder &builder,
39363948
OperationState &result,
39373949
TypeRange resultTensorTypes,
@@ -3941,6 +3953,18 @@ void linalg::MatmulTransposeAOp::build(OpBuilder &builder,
39413953
MatmulOp::getRegionBuilder(), getAffineMaps(builder));
39423954
}
39433955

3956+
MatmulTransposeAOp
3957+
MatmulTransposeAOp::create(OpBuilder &builder, Location location,
3958+
TypeRange resultTensorTypes, ValueRange inputs,
3959+
ValueRange outputs,
3960+
ArrayRef<NamedAttribute> attributes) {
3961+
OperationState state(location, getOperationName());
3962+
build(builder, state, resultTensorTypes, inputs, outputs, attributes);
3963+
auto res = dyn_cast<MatmulTransposeAOp>(builder.create(state));
3964+
assert(res && "builder didn't return the right type");
3965+
return res;
3966+
}
3967+
39443968
void linalg::MatmulTransposeAOp::build(OpBuilder &builder,
39453969
OperationState &result,
39463970
TypeRange resultTensorTypes,
@@ -3952,6 +3976,18 @@ void linalg::MatmulTransposeAOp::build(OpBuilder &builder,
39523976
MatmulOp::getRegionBuilder(), getAffineMaps(builder));
39533977
}
39543978

3979+
MatmulTransposeAOp
3980+
MatmulTransposeAOp::create(OpBuilder &builder, Location location,
3981+
TypeRange resultTensorTypes, ValueRange inputs,
3982+
ValueRange outputs, Attribute cast,
3983+
ArrayRef<NamedAttribute> attributes) {
3984+
OperationState state(location, getOperationName());
3985+
build(builder, state, resultTensorTypes, inputs, outputs, cast, attributes);
3986+
auto res = dyn_cast<MatmulTransposeAOp>(builder.create(state));
3987+
assert(res && "builder didn't return the right type");
3988+
return res;
3989+
}
3990+
39553991
bool MatmulTransposeAOp::classof(Operation *op) {
39563992
return dyn_cast_or_null<linalg::MatmulOp>(op) &&
39573993
MatmulTransposeAOp::isExpectedAffineMaps(op->getAttr("indexing_maps"));
@@ -3989,6 +4025,17 @@ void linalg::MatmulTransposeBOp::build(OpBuilder &builder,
39894025
MatmulOp::getRegionBuilder(), getAffineMaps(builder));
39904026
}
39914027

4028+
MatmulTransposeBOp
4029+
MatmulTransposeBOp::create(OpBuilder &builder, Location location,
4030+
ValueRange inputs, ValueRange outputs,
4031+
ArrayRef<NamedAttribute> attributes) {
4032+
OperationState state(location, getOperationName());
4033+
build(builder, state, inputs, outputs, attributes);
4034+
auto res = dyn_cast<MatmulTransposeBOp>(builder.create(state));
4035+
assert(res && "builder didn't return the right type");
4036+
return res;
4037+
}
4038+
39924039
void linalg::MatmulTransposeBOp::build(OpBuilder &builder,
39934040
OperationState &result,
39944041
TypeRange resultTensorTypes,
@@ -3998,6 +4045,18 @@ void linalg::MatmulTransposeBOp::build(OpBuilder &builder,
39984045
MatmulOp::getRegionBuilder(), getAffineMaps(builder));
39994046
}
40004047

4048+
MatmulTransposeBOp
4049+
MatmulTransposeBOp::create(OpBuilder &builder, Location location,
4050+
TypeRange resultTensorTypes, ValueRange inputs,
4051+
ValueRange outputs,
4052+
ArrayRef<NamedAttribute> attributes) {
4053+
OperationState state(location, getOperationName());
4054+
build(builder, state, resultTensorTypes, inputs, outputs, attributes);
4055+
auto res = dyn_cast<MatmulTransposeBOp>(builder.create(state));
4056+
assert(res && "builder didn't return the right type");
4057+
return res;
4058+
}
4059+
40014060
void linalg::MatmulTransposeBOp::build(OpBuilder &builder,
40024061
OperationState &result,
40034062
TypeRange resultTensorTypes,
@@ -4009,6 +4068,18 @@ void linalg::MatmulTransposeBOp::build(OpBuilder &builder,
40094068
MatmulOp::getRegionBuilder(), getAffineMaps(builder));
40104069
}
40114070

4071+
MatmulTransposeBOp
4072+
MatmulTransposeBOp::create(OpBuilder &builder, Location location,
4073+
TypeRange resultTensorTypes, ValueRange inputs,
4074+
ValueRange outputs, Attribute cast,
4075+
ArrayRef<NamedAttribute> attributes) {
4076+
OperationState state(location, getOperationName());
4077+
build(builder, state, resultTensorTypes, inputs, outputs, cast, attributes);
4078+
auto res = dyn_cast<MatmulTransposeBOp>(builder.create(state));
4079+
assert(res && "builder didn't return the right type");
4080+
return res;
4081+
}
4082+
40124083
bool MatmulTransposeBOp::classof(Operation *op) {
40134084
return dyn_cast_or_null<linalg::MatmulOp>(op) &&
40144085
MatmulTransposeBOp::isExpectedAffineMaps(op->getAttr("indexing_maps"));
@@ -4046,6 +4117,17 @@ void linalg::BatchMatmulTransposeAOp::build(
40464117
BatchMatmulOp::getRegionBuilder(), getAffineMaps(builder));
40474118
}
40484119

4120+
BatchMatmulTransposeAOp
4121+
BatchMatmulTransposeAOp::create(OpBuilder &builder, Location location,
4122+
ValueRange inputs, ValueRange outputs,
4123+
ArrayRef<NamedAttribute> attributes) {
4124+
OperationState state(location, getOperationName());
4125+
build(builder, state, inputs, outputs, attributes);
4126+
auto res = dyn_cast<BatchMatmulTransposeAOp>(builder.create(state));
4127+
assert(res && "builder didn't return the right type");
4128+
return res;
4129+
}
4130+
40494131
void linalg::BatchMatmulTransposeAOp::build(
40504132
OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,
40514133
ValueRange inputs, ValueRange outputs,
@@ -4054,6 +4136,18 @@ void linalg::BatchMatmulTransposeAOp::build(
40544136
BatchMatmulOp::getRegionBuilder(), getAffineMaps(builder));
40554137
}
40564138

4139+
BatchMatmulTransposeAOp
4140+
BatchMatmulTransposeAOp::create(OpBuilder &builder, Location location,
4141+
TypeRange resultTensorTypes, ValueRange inputs,
4142+
ValueRange outputs,
4143+
ArrayRef<NamedAttribute> attributes) {
4144+
OperationState state(location, getOperationName());
4145+
build(builder, state, resultTensorTypes, inputs, outputs, attributes);
4146+
auto res = dyn_cast<BatchMatmulTransposeAOp>(builder.create(state));
4147+
assert(res && "builder didn't return the right type");
4148+
return res;
4149+
}
4150+
40574151
void linalg::BatchMatmulTransposeAOp::build(
40584152
OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,
40594153
ValueRange inputs, ValueRange outputs, Attribute cast,
@@ -4063,6 +4157,18 @@ void linalg::BatchMatmulTransposeAOp::build(
40634157
BatchMatmulOp::getRegionBuilder(), getAffineMaps(builder));
40644158
}
40654159

4160+
BatchMatmulTransposeAOp
4161+
BatchMatmulTransposeAOp::create(OpBuilder &builder, Location location,
4162+
TypeRange resultTensorTypes, ValueRange inputs,
4163+
ValueRange outputs, Attribute cast,
4164+
ArrayRef<NamedAttribute> attributes) {
4165+
OperationState state(location, getOperationName());
4166+
build(builder, state, resultTensorTypes, inputs, outputs, cast, attributes);
4167+
auto res = dyn_cast<BatchMatmulTransposeAOp>(builder.create(state));
4168+
assert(res && "builder didn't return the right type");
4169+
return res;
4170+
}
4171+
40664172
bool BatchMatmulTransposeAOp::classof(Operation *op) {
40674173
return dyn_cast_or_null<linalg::BatchMatmulOp>(op) &&
40684174
BatchMatmulTransposeAOp::isExpectedAffineMaps(
@@ -4101,6 +4207,17 @@ void linalg::BatchMatmulTransposeBOp::build(
41014207
BatchMatmulOp::getRegionBuilder(), getAffineMaps(builder));
41024208
}
41034209

4210+
BatchMatmulTransposeBOp
4211+
BatchMatmulTransposeBOp::create(OpBuilder &builder, Location location,
4212+
ValueRange inputs, ValueRange outputs,
4213+
ArrayRef<NamedAttribute> attributes) {
4214+
OperationState state(location, getOperationName());
4215+
build(builder, state, inputs, outputs, attributes);
4216+
auto res = dyn_cast<BatchMatmulTransposeBOp>(builder.create(state));
4217+
assert(res && "builder didn't return the right type");
4218+
return res;
4219+
}
4220+
41044221
void linalg::BatchMatmulTransposeBOp::build(
41054222
OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,
41064223
ValueRange inputs, ValueRange outputs,
@@ -4109,6 +4226,18 @@ void linalg::BatchMatmulTransposeBOp::build(
41094226
BatchMatmulOp::getRegionBuilder(), getAffineMaps(builder));
41104227
}
41114228

4229+
BatchMatmulTransposeBOp
4230+
BatchMatmulTransposeBOp::create(OpBuilder &builder, Location location,
4231+
TypeRange resultTensorTypes, ValueRange inputs,
4232+
ValueRange outputs,
4233+
ArrayRef<NamedAttribute> attributes) {
4234+
OperationState state(location, getOperationName());
4235+
build(builder, state, resultTensorTypes, inputs, outputs, attributes);
4236+
auto res = dyn_cast<BatchMatmulTransposeBOp>(builder.create(state));
4237+
assert(res && "builder didn't return the right type");
4238+
return res;
4239+
}
4240+
41124241
void linalg::BatchMatmulTransposeBOp::build(
41134242
OpBuilder &builder, OperationState &result, TypeRange resultTensorTypes,
41144243
ValueRange inputs, ValueRange outputs, Attribute cast,
@@ -4118,6 +4247,18 @@ void linalg::BatchMatmulTransposeBOp::build(
41184247
BatchMatmulOp::getRegionBuilder(), getAffineMaps(builder));
41194248
}
41204249

4250+
BatchMatmulTransposeBOp
4251+
BatchMatmulTransposeBOp::create(OpBuilder &builder, Location location,
4252+
TypeRange resultTensorTypes, ValueRange inputs,
4253+
ValueRange outputs, Attribute cast,
4254+
ArrayRef<NamedAttribute> attributes) {
4255+
OperationState state(location, getOperationName());
4256+
build(builder, state, resultTensorTypes, inputs, outputs, cast, attributes);
4257+
auto res = dyn_cast<BatchMatmulTransposeBOp>(builder.create(state));
4258+
assert(res && "builder didn't return the right type");
4259+
return res;
4260+
}
4261+
41214262
bool BatchMatmulTransposeBOp::classof(Operation *op) {
41224263
return dyn_cast_or_null<linalg::BatchMatmulOp>(op) &&
41234264
BatchMatmulTransposeBOp::isExpectedAffineMaps(

0 commit comments

Comments
 (0)