Skip to content

Commit 9684c6c

Browse files
committed
address comments
1 parent 456b01c commit 9684c6c

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

mlir/include/mlir/Dialect/XeGPU/IR/XeGPUAttrs.td

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ def XeGPU_LayoutAttr : XeGPUAttr<"Layout", "layout"> {
243243
);
244244

245245
let builders = [
246-
AttrBuilder<(ins "llvm::ArrayRef<int>": $lane_layout,
247-
"llvm::ArrayRef<int>": $lane_data),
246+
AttrBuilder<(ins "llvm::ArrayRef<int32_t>": $lane_layout,
247+
"llvm::ArrayRef<int32_t>": $lane_data),
248248
[{
249249
auto sg_layout = DenseI32ArrayAttr();
250250
auto sg_data = DenseI32ArrayAttr();
@@ -254,14 +254,14 @@ def XeGPU_LayoutAttr : XeGPUAttr<"Layout", "layout"> {
254254
DenseI32ArrayAttr::get($_ctxt, lane_layout),
255255
DenseI32ArrayAttr::get($_ctxt, lane_data), order);
256256
}]>,
257-
AttrBuilder<(ins "llvm::ArrayRef<int>": $lane_layout,
258-
"llvm::ArrayRef<int>": $lane_data,
259-
"llvm::ArrayRef<int>": $order),
257+
AttrBuilder<(ins "llvm::ArrayRef<int32_t>": $lane_layout,
258+
"llvm::ArrayRef<int32_t>": $lane_data,
259+
"llvm::ArrayRef<int32_t>": $order),
260260
[{
261-
auto sg_layout = DenseI32ArrayAttr();
262-
auto sg_data = DenseI32ArrayAttr();
263-
auto inst_data = DenseI32ArrayAttr();
264-
return $_get($_ctxt, sg_layout, sg_data, inst_data,
261+
return $_get($_ctxt,
262+
/*sg_layout =*/ nullptr,
263+
/*sg_data =*/ nullptr,
264+
/*inst_data =*/ nullptr,
265265
DenseI32ArrayAttr::get($_ctxt, lane_layout),
266266
DenseI32ArrayAttr::get($_ctxt, lane_data),
267267
DenseI32ArrayAttr::get($_ctxt, order));
@@ -270,11 +270,8 @@ def XeGPU_LayoutAttr : XeGPUAttr<"Layout", "layout"> {
270270
"DenseI32ArrayAttr": $lane_data,
271271
"DenseI32ArrayAttr": $order),
272272
[{
273-
auto sg_layout = DenseI32ArrayAttr();
274-
auto sg_data = DenseI32ArrayAttr();
275-
auto inst_data = DenseI32ArrayAttr();
276-
return $_get($_ctxt, sg_layout, sg_data, inst_data,
277-
lane_layout, lane_data, order);
273+
return $_get($_ctxt, /*sg_layout =*/ nullptr, /*sg_data =*/ nullptr,
274+
/*inst_data =*/ nullptr, lane_layout, lane_data, order);
278275
}]>
279276
];
280277

mlir/lib/Dialect/XeGPU/IR/XeGPUOps.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ void CreateNdDescOp::build(OpBuilder &builder, OperationState &state,
148148
assert(shape.size() && offsets.size() && strides.size() &&
149149
shape.size() == strides.size() && shape.size() == offsets.size());
150150

151-
auto intTy = dyn_cast<IntegerType>(source.getType());
152-
auto memrefTy = dyn_cast<MemRefType>(source.getType());
153-
assert(intTy || memrefTy && "Source has to be either int or memref.");
151+
Type srcTy = source.getType();
152+
assert(isa<IntegerType>(srcTy) ||
153+
isa<MemRefType>(srcTy) && "Source has to be either int or memref.");
154154

155155
llvm::SmallVector<Value> dynamicOffsets;
156156
llvm::SmallVector<Value> dynamicShape;
@@ -168,11 +168,12 @@ void CreateNdDescOp::build(OpBuilder &builder, OperationState &state,
168168
auto staticShapeAttr = builder.getDenseI64ArrayAttr(staticShape);
169169
auto staticStridesAttr = builder.getDenseI64ArrayAttr(staticStrides);
170170

171-
if (memrefTy) {
171+
if (auto memrefTy = dyn_cast<MemRefType>(srcTy)) {
172172
auto memrefShape = memrefTy.getShape();
173-
auto [memrefStrides, offset] = memrefTy.getStridesAndOffset();
173+
auto [memrefStrides, _] = memrefTy.getStridesAndOffset();
174174

175175
// if shape and strides are from Memref, we don't need attributes for them
176+
// to keep the IR print clean.
176177
if (staticShape == memrefShape && staticStrides == memrefStrides) {
177178
staticShapeAttr = DenseI64ArrayAttr();
178179
staticStridesAttr = DenseI64ArrayAttr();

0 commit comments

Comments
 (0)