[Mlir-commits] [llvm] [mlir] [mlir][tosa] Add profile-based operation validation (PR #126992)
Luke Hutton
llvmlistbot at llvm.org
Wed Feb 19 07:54:42 PST 2025
================
@@ -200,6 +207,189 @@ def Tosa_ExplicitValuePadOpQuantInfoBuilder : OpBuilder<
input, paddings, pad_value);
}]>;
+// Wrapper over base I32EnumAttr to set common fields.
+class Tosa_I32Enum<string name, string description, list<I32EnumAttrCase> cases>
+ : I32EnumAttr<name, description, cases> {
+ let genSpecializedAttr = 0;
+ let cppNamespace = "::mlir::tosa";
+}
+
+class Tosa_I32EnumAttr<string name, string description, string mnemonic,
+ list<I32EnumAttrCase> cases>
+ : EnumAttr<Tosa_Dialect, Tosa_I32Enum<name, description, cases>, mnemonic> {
+ let assemblyFormat = "`<` $value `>`";
+}
+
+//===----------------------------------------------------------------------===//
+// TOSA Spec Section 1.5.
+//
+// Profile:
+// INT : Integer Inference. Integer operations, primarily 8 and 32-bit values.
+// FP : Floating-Point Inference. Primarily FP16 and FP32 operations.
+//
+// Extension:
+// INT16 : 16-bit integer operations.
+// INT4 : 4-bit integer weights.
+// BF16 : BFloat16 operations.
+// FP8 : 8-bit floating-point operations E4M3.
+// FP8 : 8-bit floating-point operations E5M2.
+// FFT : Fast Fourier Transform operations.
+// VARIABLE : Stateful variable operations.
+//===----------------------------------------------------------------------===//
+
+def Tosa_PRO_INT : I32EnumAttrCase<"pro_int", 1>;
+def Tosa_PRO_FP : I32EnumAttrCase<"pro_fp", 2>;
+def Tosa_NONE : I32EnumAttrCase<"none", 3>;
+
+def Tosa_EXT_INT16 : I32EnumAttrCase<"int16", 1>;
+def Tosa_EXT_INT4 : I32EnumAttrCase<"int4", 2>;
+def Tosa_EXT_BF16 : I32EnumAttrCase<"bf16", 3>;
+def Tosa_EXT_FP8E4M3 : I32EnumAttrCase<"fp8e4m3", 4>;
+def Tosa_EXT_FP8E5M2 : I32EnumAttrCase<"fp8e5m2", 5>;
+def Tosa_EXT_FFT : I32EnumAttrCase<"fft", 6>;
+def Tosa_EXT_VARIABLE : I32EnumAttrCase<"variable", 7>;
+def Tosa_EXT_NONE : I32EnumAttrCase<"none", 8>;
+
+def Tosa_ExtensionAttr
+ : Tosa_I32EnumAttr<"Extension", "supported TOSA extensions", "ext", [
+ Tosa_EXT_INT16, Tosa_EXT_INT4, Tosa_EXT_BF16, Tosa_EXT_FP8E4M3,
+ Tosa_EXT_FP8E5M2, Tosa_EXT_FFT, Tosa_EXT_VARIABLE, Tosa_EXT_NONE
+ ]>;
+
+def Tosa_ExtensionArrayAttr
+ : TypedArrayAttrBase<Tosa_ExtensionAttr, "TOSA extension array attribute">;
+
+def Tosa_ProfileAttr
+ : Tosa_I32EnumAttr<"Profile", "supported TOSA profiles", "prof",
+ [Tosa_PRO_INT, Tosa_PRO_FP, Tosa_NONE]>;
+
+def Tosa_ProfileArrayAttr
+ : TypedArrayAttrBase<Tosa_ProfileAttr, "TOSA profile array attribute">;
+
+// The base class for defining op availability dimensions.
+class Availability {
+ // The following are fields for controlling the generated C++ OpInterface.
+
+ // The namespace for the generated C++ OpInterface subclass.
+ string cppNamespace = "::mlir::tosa";
+
+ // The name for the generated C++ OpInterface subclass.
+ string interfaceName = ?;
+
+ // The description for the generated C++ OpInterface subclass.
+ string interfaceDescription = "";
+
+ // The query function's return type in the generated C++ OpInterface subclass.
+ string queryFnRetType = ?;
+
+ // The query function's name in the generated C++ OpInterface subclass.
+ string queryFnName = ?;
+
+ code mergeAction = ?;
----------------
lhutton1 wrote:
nit: missing explanation comment?
https://github.com/llvm/llvm-project/pull/126992
More information about the Mlir-commits
mailing list