[Mlir-commits] [mlir] [mlir][tosa] Add new block-scaled tensor type and support for MXFP CAST (PR #203583)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Jun 22 05:55:19 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Luke Hutton (lhutton1)
<details>
<summary>Changes</summary>
This commit adds a new compound-block scaled tensor type and uses this type to implement support for MXFP in the CAST operation, as per the following specification changes:
https://github.com/arm/tosa-specification/pull/50, https://github.com/arm/tosa-specification/pull/53.
The new block-scaled type is closely modelled after the `quant` dialect type and supports the following parameters:
- value type - The type of the data values in each block.
- scale type - The type of the scale value associated with each block.
- block shape - The size and axis of each block. Support for specifying constant scale values has not been added in this commit, but will be added in a later one.
Example syntax for the new block-scaled type:
```
tensor<160x!tosa.block_scaled<f8E5M2:f8E8M0FNU:BLOCK_SHAPE_32>>
```
As a pre-requisite for supporting MXFP CAST, the commit also adds new extensions intended to split the existing EXT-MXFP extension into separate extensions for each block-scaled type. This allows for more fine-grained control over which block-scaled types are supported by a given target. See specification change
https://github.com/arm/tosa-specification/pull/26 for details.
Finally, support for casting to/from the new block-scaled type has been added, aligning with the behaviour specified in the CAST operation specification.
---
Patch is 68.20 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/203583.diff
20 Files Affected:
- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc (+119-1)
- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td (+52-9)
- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaOps.h (+2)
- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td (+15-54)
- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaProfileCompliance.h (+26-4)
- (modified) mlir/include/mlir/Dialect/Tosa/IR/TosaTypesBase.td (+75-42)
- (modified) mlir/lib/Dialect/Tosa/IR/TargetEnv.cpp (+14)
- (modified) mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp (+41-3)
- (modified) mlir/lib/Dialect/Tosa/IR/TosaOps.cpp (+65)
- (modified) mlir/lib/Dialect/Tosa/Transforms/TosaProfileCompliance.cpp (+67-25)
- (modified) mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp (+1-1)
- (modified) mlir/test/Dialect/Tosa/availability.mlir (+3-3)
- (modified) mlir/test/Dialect/Tosa/canonicalize.mlir (+67)
- (modified) mlir/test/Dialect/Tosa/invalid.mlir (+32)
- (modified) mlir/test/Dialect/Tosa/invalid_extension.mlir (+28)
- (modified) mlir/test/Dialect/Tosa/ops.mlir (+26)
- (modified) mlir/test/Dialect/Tosa/tosa-attach-target.mlir (+17-2)
- (modified) mlir/test/Dialect/Tosa/tosa-validation-version-1p0-invalid.mlir (+8)
- (modified) mlir/test/Dialect/Tosa/tosa-validation-version-1p1-valid.mlir (+29-1)
- (modified) mlir/test/Dialect/Tosa/verifier.mlir (+42)
``````````diff
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc b/mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc
index 50bb9f69c6242..26890abd187bd 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc
@@ -1023,7 +1023,125 @@ extensionComplianceMap = {
{{{fp8e5m2T, fp16T}, SpecificationVersion::V_1_0},
{{fp8e5m2T, fp32T}, SpecificationVersion::V_1_0},
{{fp16T, fp8e5m2T}, SpecificationVersion::V_1_0},
- {{fp32T, fp8e5m2T}, SpecificationVersion::V_1_0}}}}},
+ {{fp32T, fp8e5m2T}, SpecificationVersion::V_1_0}}},
+ {{Extension::fp8e4m3, Extension::mx_common, Extension::mx_fp8e4m3},
+ {{{fp8e4m3T, bs32_fp8ue8m0_fp8e4m3T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp8e4m3T, fp8e4m3T},
+ SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::fp8e4m3, Extension::mx_common, Extension::mx_fp8e5m2},
+ {{{fp8e4m3T, bs32_fp8ue8m0_fp8e5m2T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp8e5m2T, fp8e4m3T},
+ SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::fp8e4m3, Extension::mx_common, Extension::mx_fp6e3m2},
+ {{{fp8e4m3T, bs32_fp8ue8m0_fp6e3m2T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp6e3m2T, fp8e4m3T},
+ SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::fp8e4m3, Extension::mx_common, Extension::mx_fp6e2m3},
+ {{{fp8e4m3T, bs32_fp8ue8m0_fp6e2m3T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp6e2m3T, fp8e4m3T},
+ SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::fp8e4m3, Extension::mx_common, Extension::mx_fp4e2m1},
+ {{{fp8e4m3T, bs32_fp8ue8m0_fp4e2m1T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp4e2m1T, fp8e4m3T},
+ SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::fp8e4m3, Extension::mx_common, Extension::mx_int8},
+ {{{fp8e4m3T, bs32_fp8ue8m0_mxint8T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_mxint8T, fp8e4m3T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::fp8e5m2, Extension::mx_common, Extension::mx_fp8e4m3},
+ {{{fp8e5m2T, bs32_fp8ue8m0_fp8e4m3T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp8e4m3T, fp8e5m2T},
+ SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::fp8e5m2, Extension::mx_common, Extension::mx_fp8e5m2},
+ {{{fp8e5m2T, bs32_fp8ue8m0_fp8e5m2T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp8e5m2T, fp8e5m2T},
+ SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::fp8e5m2, Extension::mx_common, Extension::mx_fp6e3m2},
+ {{{fp8e5m2T, bs32_fp8ue8m0_fp6e3m2T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp6e3m2T, fp8e5m2T},
+ SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::fp8e5m2, Extension::mx_common, Extension::mx_fp6e2m3},
+ {{{fp8e5m2T, bs32_fp8ue8m0_fp6e2m3T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp6e2m3T, fp8e5m2T},
+ SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::fp8e5m2, Extension::mx_common, Extension::mx_fp4e2m1},
+ {{{fp8e5m2T, bs32_fp8ue8m0_fp4e2m1T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp4e2m1T, fp8e5m2T},
+ SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::fp8e5m2, Extension::mx_common, Extension::mx_int8},
+ {{{fp8e5m2T, bs32_fp8ue8m0_mxint8T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_mxint8T, fp8e5m2T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::mx_common, Extension::mx_fp8e4m3},
+ {{{fp16T, bs32_fp8ue8m0_fp8e4m3T}, SpecificationVersion::V_1_1_DRAFT},
+ {{fp32T, bs32_fp8ue8m0_fp8e4m3T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp8e4m3T, fp16T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp8e4m3T, fp32T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::mx_common, Extension::mx_fp8e5m2},
+ {{{fp16T, bs32_fp8ue8m0_fp8e5m2T}, SpecificationVersion::V_1_1_DRAFT},
+ {{fp32T, bs32_fp8ue8m0_fp8e5m2T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp8e5m2T, fp16T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp8e5m2T, fp32T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::mx_common, Extension::mx_fp6e3m2},
+ {{{fp16T, bs32_fp8ue8m0_fp6e3m2T}, SpecificationVersion::V_1_1_DRAFT},
+ {{fp32T, bs32_fp8ue8m0_fp6e3m2T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp6e3m2T, fp16T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp6e3m2T, fp32T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::mx_common, Extension::mx_fp6e2m3},
+ {{{fp16T, bs32_fp8ue8m0_fp6e2m3T}, SpecificationVersion::V_1_1_DRAFT},
+ {{fp32T, bs32_fp8ue8m0_fp6e2m3T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp6e2m3T, fp16T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp6e2m3T, fp32T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::mx_common, Extension::mx_fp4e2m1},
+ {{{fp16T, bs32_fp8ue8m0_fp4e2m1T}, SpecificationVersion::V_1_1_DRAFT},
+ {{fp32T, bs32_fp8ue8m0_fp4e2m1T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp4e2m1T, fp16T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp4e2m1T, fp32T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::mx_common, Extension::mx_int8},
+ {{{fp16T, bs32_fp8ue8m0_mxint8T}, SpecificationVersion::V_1_1_DRAFT},
+ {{fp32T, bs32_fp8ue8m0_mxint8T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_mxint8T, fp16T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_mxint8T, fp32T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::bf16, Extension::mx_common, Extension::mx_fp8e4m3},
+ {{{bf16T, bs32_fp8ue8m0_fp8e4m3T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp8e4m3T, bf16T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::bf16, Extension::mx_common, Extension::mx_fp8e5m2},
+ {{{bf16T, bs32_fp8ue8m0_fp8e5m2T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp8e5m2T, bf16T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::bf16, Extension::mx_common, Extension::mx_fp6e3m2},
+ {{{bf16T, bs32_fp8ue8m0_fp6e3m2T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp6e3m2T, bf16T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::bf16, Extension::mx_common, Extension::mx_fp6e2m3},
+ {{{bf16T, bs32_fp8ue8m0_fp6e2m3T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp6e2m3T, bf16T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::bf16, Extension::mx_common, Extension::mx_fp4e2m1},
+ {{{bf16T, bs32_fp8ue8m0_fp4e2m1T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_fp4e2m1T, bf16T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf},
+ {{Extension::bf16, Extension::mx_common, Extension::mx_int8},
+ {{{bf16T, bs32_fp8ue8m0_mxint8T}, SpecificationVersion::V_1_1_DRAFT},
+ {{bs32_fp8ue8m0_mxint8T, bf16T}, SpecificationVersion::V_1_1_DRAFT}},
+ allOf}}},
{"tosa.cast_from_block_scaled",
{{{Extension::bf16, Extension::mxfp},
{{{fp4e2m1T, fp8ue8m0T, bf16T}, SpecificationVersion::V_1_1_DRAFT},
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td
index 591073e9985ae..308e98ac42435 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td
@@ -254,6 +254,13 @@ class Tosa_I32EnumAttr<string name, string description, string mnemonic,
// MXFP : Microscaling formats.
// MXFP_CONV : Microscaling format convolution.
// SHAPE : Shape calcuation operators.
+// MX_COMMON : Base for MXFP microscaling formats.
+// MX_FP4E2M1 : Microscaling format FP4E2M1.
+// MX_FP6E2M3 : Microscaling format FP6E2M3.
+// MX_FP6E3M2 : Microscaling format FP6E3M2.
+// MX_FP8E4M3 : Microscaling format FP8E4M3.
+// MX_FP8E5M2 : Microscaling format FP8E5M2.
+// MX_INT8 : Microscaling format INT8.
//===----------------------------------------------------------------------===//
def Tosa_NONE : I32EnumAttrCase<"none", 0>;
@@ -289,23 +296,35 @@ def Tosa_EXT_MXFP : I32EnumAttrCase<"mxfp", 12>;
def Tosa_EXT_INT64 : I32EnumAttrCase<"int64", 13>;
def Tosa_EXT_MXFP_CONV : I32EnumAttrCase<"mxfp_conv", 14>;
def Tosa_EXT_SHAPE : I32EnumAttrCase<"shape", 15>;
+def Tosa_EXT_MX_COMMON : I32EnumAttrCase<"mx_common", 16>;
+def Tosa_EXT_MX_FP4E2M1 : I32EnumAttrCase<"mx_fp4e2m1", 17>;
+def Tosa_EXT_MX_FP6E2M3 : I32EnumAttrCase<"mx_fp6e2m3", 18>;
+def Tosa_EXT_MX_FP6E3M2 : I32EnumAttrCase<"mx_fp6e3m2", 19>;
+def Tosa_EXT_MX_FP8E4M3 : I32EnumAttrCase<"mx_fp8e4m3", 20>;
+def Tosa_EXT_MX_FP8E5M2 : I32EnumAttrCase<"mx_fp8e5m2", 21>;
+def Tosa_EXT_MX_INT8 : I32EnumAttrCase<"mx_int8", 22>;
def Tosa_ExtensionAttr
- : Tosa_I32EnumAttr<"Extension", "supported TOSA extensions", "ext", [
- Tosa_EXT_NONE, Tosa_EXT_INT16, Tosa_EXT_INT4, Tosa_EXT_BF16,
- Tosa_EXT_FP8E4M3, Tosa_EXT_FP8E5M2, Tosa_EXT_FFT, Tosa_EXT_VARIABLE,
- Tosa_EXT_CONTROLFLOW, Tosa_EXT_DOUBLEROUND, Tosa_EXT_INEXACTROUND,
- Tosa_EXT_DYNAMIC, Tosa_EXT_MXFP, Tosa_EXT_INT64, Tosa_EXT_MXFP_CONV,
- Tosa_EXT_SHAPE,
- ]> {
+ : Tosa_I32EnumAttr<
+ "Extension", "supported TOSA extensions", "ext",
+ [Tosa_EXT_NONE, Tosa_EXT_INT16, Tosa_EXT_INT4, Tosa_EXT_BF16,
+ Tosa_EXT_FP8E4M3, Tosa_EXT_FP8E5M2, Tosa_EXT_FFT, Tosa_EXT_VARIABLE,
+ Tosa_EXT_CONTROLFLOW, Tosa_EXT_DOUBLEROUND, Tosa_EXT_INEXACTROUND,
+ Tosa_EXT_DYNAMIC, Tosa_EXT_MXFP, Tosa_EXT_INT64, Tosa_EXT_MXFP_CONV,
+ Tosa_EXT_SHAPE, Tosa_EXT_MX_COMMON, Tosa_EXT_MX_FP4E2M1,
+ Tosa_EXT_MX_FP6E2M3, Tosa_EXT_MX_FP6E3M2, Tosa_EXT_MX_FP8E4M3,
+ Tosa_EXT_MX_FP8E5M2, Tosa_EXT_MX_INT8]> {
let extraClassDeclaration = [{
- static llvm::SmallVector<Extension, 14> getAllValues() {
+ static llvm::SmallVector<Extension, 22> getAllValues() {
return {
Extension::int16, Extension::int4, Extension::bf16,
Extension::fp8e4m3, Extension::fp8e5m2, Extension::fft,
Extension::variable, Extension::controlflow, Extension::doubleround,
Extension::inexactround, Extension::dynamic, Extension::mxfp,
- Extension::int64, Extension::mxfp_conv, Extension::shape
+ Extension::int64, Extension::mxfp_conv, Extension::shape,
+ Extension::mx_common, Extension::mx_fp4e2m1, Extension::mx_fp6e2m3,
+ Extension::mx_fp6e3m2, Extension::mx_fp8e4m3, Extension::mx_fp8e5m2,
+ Extension::mx_int8
};
}
}];
@@ -484,6 +503,7 @@ def Tosa_RoundingModeAttr
: Tosa_I32EnumAttr<"RoundingMode", "Supported rounding modes", "rounding_mode",
[Tosa_ROUNDING_SINGLE_ROUND, Tosa_ROUNDING_INEXACT_ROUND, Tosa_ROUNDING_DOUBLE_ROUND]>;
+// Block_size attr is deprecated and will be removed in the future
def Tosa_BLOCK_SIZE_1 : I32EnumAttrCase<"BLOCK_SIZE_1", 1>;
def Tosa_BLOCK_SIZE_32 : I32EnumAttrCase<"BLOCK_SIZE_32", 32>;
@@ -497,6 +517,29 @@ def Tosa_BlockSizeAttr
}];
}
+def Tosa_BLOCK_SHAPE_32 : I32EnumAttrCase<"BLOCK_SHAPE_32", 32>;
+
+def Tosa_BlockShape
+ : Tosa_I32Enum<
+ "BlockShape",
+ "Block shape for the block_scaled formats."
+ "The names follow the convention of BLOCK_SHAPE_M where M "
+ "is the block size of the innermost dimension. Similarly, "
+ "BLOCK_SHAPE_MxN indicates block size of N in the innermost "
+ "dimension and block size of M in the next innermost dimension. "
+ "As of now, only 1 dimension (innermost) is supported for "
+ "block-scaling.",
+ [Tosa_BLOCK_SHAPE_32]>;
+
+def Tosa_BlockShapeAttr
+ : EnumAttr<Tosa_Dialect, Tosa_BlockShape, "block_shape"> {
+ let extraClassDeclaration = [{
+ static uint32_t getBlockShapeValue(BlockShape blockShape) {
+ return static_cast<uint32_t>(blockShape);
+ }
+ }];
+}
+
//===----------------------------------------------------------------------===//
// TOSA Interfaces.
//===----------------------------------------------------------------------===//
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.h b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.h
index e0626368175ee..a5c6037692ff1 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.h
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.h
@@ -92,6 +92,8 @@ class TosaShapeOperatorWithSameRanks
}
};
+LogicalResult verifyBlockScaledTensorType(Operation &op, mlir::Type type);
+
} // namespace tosa
} // namespace OpTrait
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
index a99fb2fcae547..32f8bf08cbc84 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
@@ -2689,57 +2689,6 @@ def Tosa_CastOp: Tosa_Op<"cast", [Pure, SameOperandsAndResultShape,
let description = [{
Casts a tensor from one data type to another.
- * This table is showing the supported conversions from the TOSA Specification.
- * The MLIR dialect here can be used to represent other conversions.
-
- | Mode | Input | Output |
- |--------------------------|---------|---------|
- | fp16 to fp32 | float16 | float32 |
- | fp16 to int 16 | float16 | int16 |
- | fp16 to int 32 | float16 | int32 |
- | fp16 to int 8 | float16 | int8 |
- | fp32 to fp16 | float32 | float16 |
- | fp32 to int 16 | float32 | int16 |
- | fp32 to int 32 | float32 | int32 |
- | fp32 to int 8 | float32 | int8 |
- | int 16 to fp16 | int16 | float16 |
- | int 16 to fp32 | int16 | float32 |
- | int 32 to fp16 | int32 | float16 |
- | int 32 to fp32 | int32 | float32 |
- | int 8 to fp16 | int8 | float16 |
- | int 8 to fp32 | int8 | float32 |
- | bool to int 16 | Boolean | int16 |
- | bool to int 32 | Boolean | int32 |
- | bool to int 8 | Boolean | int8 |
- | int 16 to bool | int16 | Boolean |
- | int 16 to int 32 | int16 | int32 |
- | int 16 to int 8 | int16 | int8 |
- | int 32 to bool | int32 | Boolean |
- | int 32 to int 16 | int32 | int16 |
- | int 32 to int 8 | int32 | int8 |
- | int 8 to bool | int8 | Boolean |
- | int 8 to int 16 | int8 | int16 |
- | int 8 to int 32 | int8 | int32 |
- | bf16 to fp32 | bf16 | float32 |
- | bf16 to int 16 | bf16 | int16 |
- | bf16 to int 32 | bf16 | int32 |
- | bf16 to int 8 | bf16 | int8 |
- | fp32 to bf16 | float32 | bf16 |
- | int 16 to bf16 | int16 | bf16 |
- | int 32 to bf16 | int32 | bf16 |
- | int 8 to bf16 | int8 | bf16 |
- | bf16 to fp8e4m3 | bf16 | fp8e4m3 |
- | fp8e4m3 to bf16 | fp8e4m3 | bf16 |
- | bf16 to fp8e5m2 | bf16 | fp8e5m2 |
- | fp8e5m2 to bf16 | fp8e5m2 | bf16 |
- | fp16 to fp8e4m3 | float16 | fp8e4m3 |
- | fp32 to fp8e4m3 | float32 | fp8e4m3 |
- | fp8e4m3 to fp16 | fp8e4m3 | float16 |
- | fp8e4m3 to fp32 | fp8e4m3 | float32 |
- | fp16 to fp8e5m2 | float16 | fp8e5m2 |
- | fp32 to fp8e5m2 | float32 | fp8e5m2 |
- | fp8e5m2 to fp16 | fp8e5m2 | float16 |
- | fp8e5m2 to fp32 | fp8e5m2 | float32 |
}];
let arguments = (ins
@@ -2750,19 +2699,25 @@ def Tosa_CastOp: Tosa_Op<"cast", [Pure, SameOperandsAndResultShape,
Tosa_Tensor:$output
);
- list<Availability> availability = [
- Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
- Extension<[Tosa_EXT_FP8E4M3, Tosa_EXT_FP8E5M2, Tosa_EXT_BF16, Tosa_EXT_INT64]>,
+ list<Availability> availability =
+ [Profile<[Tosa_PRO_INT, Tosa_PRO_FP]>,
+ Extension<[Tosa_EXT_FP8E4M3, Tosa_EXT_FP8E5M2, Tosa_EXT_BF16,
+ Tosa_EXT_INT64, Tosa_EXT_MX_COMMON, Tosa_EXT_MX_FP4E2M1,
+ Tosa_EXT_MX_FP6E2M3, Tosa_EXT_MX_FP6E3M2, Tosa_EXT_MX_FP8E4M3,
+ Tosa_EXT_MX_FP8E5M2, Tosa_EXT_MX_INT8]>,
];
let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
let hasFolder = 1;
let hasCanonicalizer = 1;
+ let hasVerifier = 1;
}
//===----------------------------------------------------------------------===//
// Operator: cast_from_block_scaled
+//
+// Note: This operation is deprecated. It will be removed in the future.
//===----------------------------------------------------------------------===//
def Tosa_CastFromBlockScaledOp: Tosa_InferShapedTypeOp<"cast_from_block_scaled", [Pure]> {
let summary = "Apply scales from a scale tensor to the values in a value tensor";
@@ -2771,6 +2726,8 @@ def Tosa_CastFromBlockScaledOp: Tosa_InferShapedTypeOp<"cast_from_block_scaled",
Apply the scales from a scale tensor to the values in a value tensor, casting
the result to the output type. The block dimension must be the last dimension
of the tensor.
+
+ Note: This operation is deprecated. It will be removed in the future.
}];
let arguments = (ins
@@ -2794,6 +2751,8 @@ def Tosa_CastFromBlockScaledOp: Tosa_InferShapedTypeOp<"cast_from_block_scaled",
//===----------------------------------------------------------------------===//
// Operator: cast_to_block_scaled
+//
+// Note: This operation is deprecated. It will be removed in the future.
//===----------------------------------------------------------------------===//
def Tosa_CastToBlockScaledOp : Tosa_InferShapedTypeOp<"cast_to_block_scaled", [Pure]> {
let summary = "Calculate scale tensor values per block, output to separate scale and data tensors.";
@@ -2803,6 +2762,8 @@ def Tosa_CastToBlockScaledOp : Tosa_InferShapedTypeOp<"cast_to_block_scaled", [P
scaled data values from an input tensor. The output tensors are cast to the
specified scale and value types. The block dimension will be the last dimension
of the tensor.
+
+ Note: This operation is deprecated. It will be removed in the future.
}];
let arguments = (ins
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaProfileCompliance.h b/mlir/include/mlir/Dialect/Tosa/IR/TosaProfileCompliance.h
index 0135a651be481..4e14b27a421e4 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaProfileCompliance.h
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaProfileCompliance.h
@@ -23,10 +23,22 @@ using namespace mlir::tosa;
// Type Compilance Definition
//===----------------------------------------------------------------------===//
-typedef struct {
+struct TypeInfo {
+ TypeInfo(mlir::TypeID typeID, uint32_t bitWidth)
+ : typeID(typeID), bitWidth(bitWidth), valueTypeID(mlir::TypeID()),
+ scaleTypeID(mlir::TypeID()), blockSize(0) {}
+
+ TypeInfo(mlir::TypeID typeID, uint32_t bitWidth, mlir::TypeID valueTypeID,
+ mlir::TypeID scaleTypeID, uint32_t blockSize)
+ : typeID(typeID), bitWidth(bitWidth), valueTypeID(valueTypeID),
+ scaleTypeID(scaleTypeID), blockSize(blockSize) {}
+
mlir::TypeID typeID;
uint32_t bitWidth;
-} TypeInfo;
+ mlir::TypeID valueTypeID;
+ mlir::TypeID scaleTypeID;
+ uint32_t blockSize;
+};
enum CheckCondition {
invalid,
@@ -70,6 +82,14 @@ class ProfileInfoDepot {
private:
TypeInfo convertTypeToInfo(Type type) {
+ if (auto blockScaledTy = dyn_cast<tosa::BlockScaledType>(type)) {
+ Type valueTy = blockScaledTy.getValueType();
+ Type scaleTy = blockSc...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/203583
More information about the Mlir-commits
mailing list