[Mlir-commits] [mlir] [mlir][spirv] Add 6 Element Binary operators to TOSA Ext Inst Set (PR #179627)
Davide Grohmann
llvmlistbot at llvm.org
Tue Feb 24 01:20:52 PST 2026
================
@@ -62,6 +62,39 @@ class SPIRV_TosaOpWithComplexResult<string mnemonic, int opcode, list<Trait> tra
}];
}
+class SPIRV_TosaBinaryOp<string mnemonic, int opcode, list<Trait> traits = []> :
+ SPIRV_TosaOpWithResult<mnemonic, opcode, !listconcat(traits, [
+ AllElementTypesMatch<["input1", "input2"]>,
+ AllRanksMatch<["input1", "input2", "output"]>,
+ MatchBroadcastableShapes<"input1", "input2", "output">])> {
+
+ let extraClassDeclaration = extraBaseClassDeclaration#[{
+ ::mlir::TypedValue<::mlir::spirv::TensorArmType> getLHS() {
+ return getInput1();
+ }
+ ::mlir::TypedValue<::mlir::spirv::TensorArmType> getRHS() {
+ return getInput2();
+ }
+ ::mlir::spirv::TensorArmType getInput1Type() {
+ return cast<::mlir::spirv::TensorArmType>(getInput1().getType());
+ }
+ ::mlir::spirv::TensorArmType getInput2Type() {
+ return cast<::mlir::spirv::TensorArmType>(getInput2().getType());
+ }
+ ::mlir::spirv::TensorArmType getLHSType() {
+ return getInput1Type();
+ }
+ ::mlir::spirv::TensorArmType getRHSType() {
+ return getInput2Type();
+ }
+ }];
+}
+
+class SPIRV_TosaElementwiseBinaryOp<string mnemonic, int opcode, list<Trait> traits = []> :
+ SPIRV_TosaBinaryOp<mnemonic, opcode, !listconcat(traits, [
+ AllElementTypesMatch<["input1", "output"]>])> {
+}
----------------
davidegrohmann wrote:
They are not all the same for all elementwise binary operations, some have attributes.
https://github.com/llvm/llvm-project/pull/179627
More information about the Mlir-commits
mailing list