Skip to content

[mlir][gpu] gpu.rotate verifier shouldn't check for constant operands #147320

Open
@kuhar

Description

@kuhar

Op verifiers are not supposed to check non-local properties in ::verify(): https://mlir.llvm.org/getting_started/DeveloperGuide/#ir-verifier

We should remove this code from the verifier for gpu.rotate:

auto offsetConstOp = getOffset().getDefiningOp<arith::ConstantOp>();
if (!offsetConstOp)
return emitOpError() << "offset is not a constant value";
auto offsetIntAttr =
llvm::dyn_cast<mlir::IntegerAttr>(offsetConstOp.getValue());
auto widthConstOp = getWidth().getDefiningOp<arith::ConstantOp>();
if (!widthConstOp)
return emitOpError() << "width is not a constant value";
auto widthIntAttr =
llvm::dyn_cast<mlir::IntegerAttr>(widthConstOp.getValue());
llvm::APInt offsetValue = offsetIntAttr.getValue();
llvm::APInt widthValue = widthIntAttr.getValue();
if (!widthValue.isPowerOf2())
return emitOpError() << "width must be a power of two";
if (offsetValue.sge(widthValue) || offsetValue.slt(0)) {
int64_t widthValueInt = widthValue.getSExtValue();
return emitOpError() << "offset must be in the range [0, " << widthValueInt
<< ")";
}

An alternative would be to take width as an attribute, if we want to have it verified.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions