Skip to content

Commit 2e31808

Browse files
[Fix] Compilation fixes
1 parent 1758f6c commit 2e31808

File tree

4 files changed

+47
-35
lines changed

4 files changed

+47
-35
lines changed

mlir/lib/Dialect/Quant/IR/QuantTypes.cpp

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ QuantizedType::verifyInvariants(function_ref<InFlightDiagnostic()> emitError,
5151
(flags & QuantizationFlags::Signed) == QuantizationFlags::Signed;
5252

5353
// Integral storage type width checks
54-
if (storageType.isa<IntegerType>()) {
54+
if (mlir::isa<IntegerType>(storageType)) {
5555
unsigned integralWidth =
5656
llvm::dyn_cast<IntegerType>(storageType).getWidth();
5757

@@ -60,7 +60,7 @@ QuantizedType::verifyInvariants(function_ref<InFlightDiagnostic()> emitError,
6060
}
6161

6262
int64_t defaultMin, defaultMax;
63-
if (storageType.isa<IntegerType>()) {
63+
if (mlir::isa<IntegerType>(storageType)) {
6464
const auto width = llvm::dyn_cast<IntegerType>(storageType).getWidth();
6565
defaultMin = QuantizedType::getDefaultMinimumForInteger(isSigned, width);
6666
defaultMax = QuantizedType::getDefaultMaximumForInteger(isSigned, width);
@@ -74,8 +74,9 @@ QuantizedType::verifyInvariants(function_ref<InFlightDiagnostic()> emitError,
7474
defaultMin = QuantizedType::getDefaultMinimumForF4E2M1FN();
7575
defaultMax = QuantizedType::getDefaultMaximumForF4E2M1FN();
7676
} else {
77-
return emitError() << "illegal storage type, supported types are: integral "
78-
"types, Float8E4M3FNType, Float8E5M2Type and Float4E2M1FNType ";
77+
return emitError()
78+
<< "illegal storage type, supported types are: integral "
79+
"types, Float8E4M3FNType, Float8E5M2Type and Float4E2M1FNType ";
7980
}
8081

8182
// Verify storageTypeMin and storageTypeMax.
@@ -572,20 +573,25 @@ LogicalResult QuantileQuantizedType::verifyInvariants(
572573
}
573574

574575
unsigned typeWidth{};
575-
if (storageType.isa<IntegerType>()) {
576+
if (mlir::isa<IntegerType>(storageType)) {
576577
typeWidth = llvm::dyn_cast<IntegerType>(storageType).getWidth();
577-
} else if (mlir::isa<Float8E5M2Type, Float8E4M3FNType, Float4E2M1FNType>(storageType)) {
578-
// Float8E5M2Type, Float8E4M3FNType and Float4E2M1FNType derive from FloatType.
578+
} else if (mlir::isa<Float8E5M2Type, Float8E4M3FNType, Float4E2M1FNType>(
579+
storageType)) {
580+
// Float8E5M2Type, Float8E4M3FNType and Float4E2M1FNType derive from
581+
// FloatType.
579582
typeWidth = llvm::dyn_cast<FloatType>(storageType).getWidth();
580583
} else {
581-
return emitError() << "illegal storage type, supported types are: integral "
582-
"types, Float8E4M3FNType, Float8E5M2Type and Float4E2M1FNType ";
584+
return emitError()
585+
<< "illegal storage type, supported types are: integral "
586+
"types, Float8E4M3FNType, Float8E5M2Type and Float4E2M1FNType ";
583587
}
584588

585589
const size_t storageTypeRange = storageTypeMax - storageTypeMin + 1;
586590
const size_t typeWidthSize = 1 << typeWidth;
587591
const size_t expectedSize =
588-
(storageTypeRange < typeWidthSize) && !mlir::isa<FloatType>(storageType) ? storageTypeRange : typeWidthSize;
592+
(storageTypeRange < typeWidthSize) && !mlir::isa<FloatType>(storageType)
593+
? storageTypeRange
594+
: typeWidthSize;
589595

590596
const auto quantileArraySize = quantiles.size();
591597
if (quantileArraySize != expectedSize) {
@@ -657,20 +663,25 @@ LogicalResult QuantileQuantizedPerAxisType::verifyInvariants(
657663
}
658664

659665
unsigned typeWidth{};
660-
if (storageType.isa<IntegerType>()) {
666+
if (mlir::isa<IntegerType>(storageType)) {
661667
typeWidth = llvm::dyn_cast<IntegerType>(storageType).getWidth();
662-
} else if (mlir::isa<Float8E5M2Type, Float8E4M3FNType, Float4E2M1FNType>(storageType)) {
663-
// Float8E5M2Type, Float8E4M3FNType and Float4E2M1FNType derive from FloatType.
668+
} else if (mlir::isa<Float8E5M2Type, Float8E4M3FNType, Float4E2M1FNType>(
669+
storageType)) {
670+
// Float8E5M2Type, Float8E4M3FNType and Float4E2M1FNType derive from
671+
// FloatType.
664672
typeWidth = llvm::dyn_cast<FloatType>(storageType).getWidth();
665673
} else {
666-
return emitError() << "illegal storage type, supported types are: integral "
667-
"types, Float8E4M3FNType, Float8E5M2Type and Float4E2M1FNType ";
674+
return emitError()
675+
<< "illegal storage type, supported types are: integral "
676+
"types, Float8E4M3FNType, Float8E5M2Type and Float4E2M1FNType ";
668677
}
669678

670679
const size_t storageTypeRange = storageTypeMax - storageTypeMin + 1;
671680
const size_t typeWidthSize = 1 << typeWidth;
672681
const size_t expectedSize =
673-
(storageTypeRange < typeWidthSize) && !mlir::isa<FloatType>(storageType) ? storageTypeRange : typeWidthSize;
682+
(storageTypeRange < typeWidthSize) && !mlir::isa<FloatType>(storageType)
683+
? storageTypeRange
684+
: typeWidthSize;
674685

675686
const auto quantileArraySize = quantiles.size();
676687
if (quantileArraySize != expectedSize) {

mlir/lib/Dialect/Quant/IR/TypeParser.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static Type parseQuantileType(DialectAsmParser &parser) {
8484
if (!succeeded(*result))
8585
return nullptr;
8686

87-
if (!type.isa<IntegerType>() && !type.isa<FloatType>()) {
87+
if (!mlir::isa<IntegerType>(type) && !mlir::isa<FloatType>(type)) {
8888
parser.emitError(typeLoc, "illegal quantile type alias");
8989
return nullptr;
9090
}
@@ -128,7 +128,7 @@ static ParseResult parseStorageRange(DialectAsmParser &parser, Type storageType,
128128
bool isSigned, int64_t &storageTypeMin,
129129
int64_t &storageTypeMax) {
130130
int64_t defaultMin, defaultMax;
131-
if (storageType.isa<IntegerType>()) {
131+
if (mlir::isa<IntegerType>(storageType)) {
132132
const auto width = llvm::dyn_cast<IntegerType>(storageType).getWidth();
133133
defaultMin = QuantizedType::getDefaultMinimumForInteger(isSigned, width);
134134
defaultMax = QuantizedType::getDefaultMaximumForInteger(isSigned, width);
@@ -638,11 +638,11 @@ static void printStorageType(QuantizedType type, DialectAsmPrinter &out) {
638638
// storage type
639639
unsigned storageWidth = type.getStorageTypeIntegralWidth();
640640
bool isSigned = type.isSigned();
641-
if (type.getStorageType().isa<Float8E5M2Type>()) {
641+
if (mlir::isa<Float8E5M2Type>(type.getStorageType())) {
642642
out << "f8E5M2";
643-
} else if (type.getStorageType().isa<Float8E4M3FNType>()) {
643+
} else if (mlir::isa<Float8E4M3FNType>(type.getStorageType())) {
644644
out << "f8E4M3FN";
645-
} else if (type.getStorageType().isa<Float4E2M1FNType>()) {
645+
} else if (mlir::isa<Float4E2M1FNType>(type.getStorageType())) {
646646
out << "f4E2M1FN";
647647
} else if (isSigned) {
648648
out << "i" << storageWidth;
@@ -652,24 +652,24 @@ static void printStorageType(QuantizedType type, DialectAsmPrinter &out) {
652652

653653
// storageTypeMin and storageTypeMax if not default.
654654
int64_t defaultMin =
655-
type.getStorageType().isa<IntegerType>()
655+
mlir::isa<IntegerType>(type.getStorageType())
656656
? QuantizedType::getDefaultMinimumForInteger(isSigned, storageWidth)
657-
: type.getStorageType().isa<Float8E5M2Type>()
657+
: mlir::isa<Float8E5M2Type>(type.getStorageType())
658658
? QuantizedType::getDefaultMinimumForF8E5M2()
659-
: type.getStorageType().isa<Float8E4M3FNType>()
659+
: mlir::isa<Float8E4M3FNType>(type.getStorageType())
660660
? QuantizedType::getDefaultMinimumForF8E4M3FN()
661-
: type.getStorageType().isa<Float4E2M1FNType>()
661+
: mlir::isa<Float4E2M1FNType>(type.getStorageType())
662662
? QuantizedType::getDefaultMinimumForF4E2M1FN()
663663
: std::numeric_limits<int64_t>::max();
664664

665665
int64_t defaultMax =
666-
type.getStorageType().isa<IntegerType>()
666+
mlir::isa<IntegerType>(type.getStorageType())
667667
? QuantizedType::getDefaultMaximumForInteger(isSigned, storageWidth)
668-
: type.getStorageType().isa<Float8E5M2Type>()
668+
: mlir::isa<Float8E5M2Type>(type.getStorageType())
669669
? QuantizedType::getDefaultMaximumForF8E5M2()
670-
: type.getStorageType().isa<Float8E4M3FNType>()
670+
: mlir::isa<Float8E4M3FNType>(type.getStorageType())
671671
? QuantizedType::getDefaultMaximumForF8E4M3FN()
672-
: type.getStorageType().isa<Float4E2M1FNType>()
672+
: mlir::isa<Float4E2M1FNType>(type.getStorageType())
673673
? QuantizedType::getDefaultMaximumForF4E2M1FN()
674674
: std::numeric_limits<int64_t>::min();
675675

@@ -688,11 +688,11 @@ static void printQuantileType(Type quantileType, DialectAsmPrinter &out) {
688688
} else {
689689
out << ":i" << storageTypeWidth;
690690
}
691-
} else if (quantileType.isa<Float8E5M2Type>()) {
691+
} else if (mlir::isa<Float8E5M2Type>(quantileType)) {
692692
out << ":f8E5M2";
693-
} else if (quantileType.isa<Float8E4M3FNType>()) {
693+
} else if (mlir::isa<Float8E4M3FNType>(quantileType)) {
694694
out << ":f8E4M3FN";
695-
} else if (quantileType.isa<Float4E2M1FNType>()) {
695+
} else if (mlir::isa<Float4E2M1FNType>(quantileType)) {
696696
out << ":f4E2M1FN";
697697
} else {
698698
// Float types

mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct CastOpInterface
8282
auto rankedResultType = cast<RankedTensorType>(castOp.getType());
8383
return cast<BufferLikeType>(MemRefType::get(
8484
rankedResultType.getShape(), rankedResultType.getElementType(),
85-
llvm::cast<MemRefType>(*maybeSrcBufferType).getLayout(), memorySpace);
85+
llvm::cast<MemRefType>(*maybeSrcBufferType).getLayout(), memorySpace));
8686
}
8787

8888
LogicalResult bufferize(Operation *op, RewriterBase &rewriter,

mlir/lib/Transforms/Utils/InliningUtils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,9 @@ LogicalResult mlir::inlineCall(
564564
auto [inlineBlock, inlinePoint] = callInterface->getInlineBlockAndPoint(call);
565565

566566
// Attempt to inline the call.
567-
if (failed(inlineRegionImpl(interface, src, inlineBlock, inlinePoint, mapper,
568-
callResults, callableResultTypes, call.getLoc(),
567+
if (failed(inlineRegionImpl(interface, cloneCallback, src, inlineBlock,
568+
inlinePoint, mapper, callResults,
569+
callableResultTypes, call.getLoc(),
569570
shouldCloneInlinedRegion, call)))
570571
return cleanupState();
571572
return success();

0 commit comments

Comments
 (0)