@@ -482,7 +482,9 @@ def Tosa_ErfOp : Tosa_ElementwiseUnaryOp<"erf"> {
482482//===----------------------------------------------------------------------===//
483483def Tosa_AddOp : Tosa_ElementwiseOp<"add", [
484484 Commutative,
485- SameOperandsAndResultElementType]> {
485+ ResultsBroadcastableShape,
486+ SameOperandsAndResultElementType,
487+ SameOperandsAndResultRank]> {
486488 let summary = "Elementwise addition operator";
487489
488490 let description = [{
@@ -515,8 +517,10 @@ def Tosa_AddOp : Tosa_ElementwiseOp<"add", [
515517//===----------------------------------------------------------------------===//
516518// Operator: arithmetic_right_shift
517519//===----------------------------------------------------------------------===//
518- def Tosa_ArithmeticRightShiftOp : Tosa_ElementwiseOp<"arithmetic_right_shift",
519- [SameOperandsAndResultElementType]> {
520+ def Tosa_ArithmeticRightShiftOp : Tosa_ElementwiseOp<"arithmetic_right_shift", [
521+ ResultsBroadcastableShape,
522+ SameOperandsAndResultElementType,
523+ SameOperandsAndResultRank]> {
520524 let summary = "Elementwise Arithmetic Right Shift";
521525
522526 let description = [{
@@ -540,7 +544,9 @@ def Tosa_ArithmeticRightShiftOp : Tosa_ElementwiseOp<"arithmetic_right_shift",
540544//===----------------------------------------------------------------------===//
541545def Tosa_BitwiseAndOp : Tosa_ElementwiseOp<"bitwise_and", [
542546 Commutative,
543- SameOperandsAndResultElementType]> {
547+ ResultsBroadcastableShape,
548+ SameOperandsAndResultElementType,
549+ SameOperandsAndResultRank]> {
544550 let summary = "Bitwise AND operator";
545551
546552 let description = [{
@@ -563,7 +569,9 @@ def Tosa_BitwiseAndOp : Tosa_ElementwiseOp<"bitwise_and", [
563569//===----------------------------------------------------------------------===//
564570def Tosa_BitwiseOrOp : Tosa_ElementwiseOp<"bitwise_or", [
565571 Commutative,
566- SameOperandsAndResultElementType]> {
572+ ResultsBroadcastableShape,
573+ SameOperandsAndResultElementType,
574+ SameOperandsAndResultRank]> {
567575 let summary = "Bitwise OR operator";
568576
569577 let description = [{
@@ -586,7 +594,9 @@ def Tosa_BitwiseOrOp : Tosa_ElementwiseOp<"bitwise_or", [
586594//===----------------------------------------------------------------------===//
587595def Tosa_BitwiseXorOp : Tosa_ElementwiseOp<"bitwise_xor", [
588596 Commutative,
589- SameOperandsAndResultElementType]> {
597+ ResultsBroadcastableShape,
598+ SameOperandsAndResultElementType,
599+ SameOperandsAndResultRank]> {
590600 let summary = "Bitwise XOR operator";
591601
592602 let description = [{
@@ -607,7 +617,10 @@ def Tosa_BitwiseXorOp : Tosa_ElementwiseOp<"bitwise_xor", [
607617//===----------------------------------------------------------------------===//
608618// Operator: int_div
609619//===----------------------------------------------------------------------===//
610- def Tosa_IntDivOp : Tosa_ElementwiseOp<"int_div", [SameOperandsAndResultElementType]> {
620+ def Tosa_IntDivOp : Tosa_ElementwiseOp<"int_div", [
621+ ResultsBroadcastableShape,
622+ SameOperandsAndResultRank,
623+ SameOperandsAndResultElementType]> {
611624 let summary = "Integer divide operator";
612625
613626 let description = [{
@@ -632,7 +645,9 @@ def Tosa_IntDivOp : Tosa_ElementwiseOp<"int_div", [SameOperandsAndResultElementT
632645//===----------------------------------------------------------------------===//
633646def Tosa_LogicalAndOp : Tosa_ElementwiseOp<"logical_and", [
634647 Commutative,
635- SameOperandsAndResultElementType]> {
648+ ResultsBroadcastableShape,
649+ SameOperandsAndResultElementType,
650+ SameOperandsAndResultRank]> {
636651 let summary = "Returns the truth value of x AND y element-wise.";
637652
638653 let description = [{
@@ -653,8 +668,10 @@ def Tosa_LogicalAndOp : Tosa_ElementwiseOp<"logical_and", [
653668//===----------------------------------------------------------------------===//
654669// Operator: logical_left_shift
655670//===----------------------------------------------------------------------===//
656- def Tosa_LogicalLeftShiftOp : Tosa_ElementwiseOp<"logical_left_shift",
657- [SameOperandsAndResultElementType]> {
671+ def Tosa_LogicalLeftShiftOp : Tosa_ElementwiseOp<"logical_left_shift", [
672+ ResultsBroadcastableShape,
673+ SameOperandsAndResultElementType,
674+ SameOperandsAndResultRank]> {
658675 let summary = "Elementwise Logical Left Shift";
659676
660677 let description = [{
@@ -675,8 +692,10 @@ def Tosa_LogicalLeftShiftOp : Tosa_ElementwiseOp<"logical_left_shift",
675692//===----------------------------------------------------------------------===//
676693// Operator: logical_right_shift
677694//===----------------------------------------------------------------------===//
678- def Tosa_LogicalRightShiftOp : Tosa_ElementwiseOp<"logical_right_shift",
679- [SameOperandsAndResultElementType]> {
695+ def Tosa_LogicalRightShiftOp : Tosa_ElementwiseOp<"logical_right_shift", [
696+ ResultsBroadcastableShape,
697+ SameOperandsAndResultElementType,
698+ SameOperandsAndResultRank]> {
680699 let summary = "Elementwise Logical Right Shift";
681700
682701 let description = [{
@@ -699,7 +718,9 @@ def Tosa_LogicalRightShiftOp : Tosa_ElementwiseOp<"logical_right_shift",
699718//===----------------------------------------------------------------------===//
700719def Tosa_LogicalOrOp : Tosa_ElementwiseOp<"logical_or", [
701720 Commutative,
702- SameOperandsAndResultElementType]> {
721+ ResultsBroadcastableShape,
722+ SameOperandsAndResultElementType,
723+ SameOperandsAndResultRank]> {
703724 let summary = "Returns the truth value of x OR y element-wise.";
704725
705726 let description = [{
@@ -722,7 +743,9 @@ def Tosa_LogicalOrOp : Tosa_ElementwiseOp<"logical_or", [
722743//===----------------------------------------------------------------------===//
723744def Tosa_LogicalXorOp : Tosa_ElementwiseOp<"logical_xor", [
724745 Commutative,
725- SameOperandsAndResultElementType]> {
746+ ResultsBroadcastableShape,
747+ SameOperandsAndResultElementType,
748+ SameOperandsAndResultRank]> {
726749 let summary = "Returns the truth value of x XOR y element-wise.";
727750
728751 let description = [{
@@ -745,7 +768,9 @@ def Tosa_LogicalXorOp : Tosa_ElementwiseOp<"logical_xor", [
745768//===----------------------------------------------------------------------===//
746769def Tosa_MaximumOp : Tosa_ElementwiseOp<"maximum", [
747770 Commutative,
748- SameOperandsAndResultElementType]> {
771+ ResultsBroadcastableShape,
772+ SameOperandsAndResultElementType,
773+ SameOperandsAndResultRank]> {
749774 let summary = "Elementwise Maximum";
750775
751776 let description = [{
@@ -771,7 +796,9 @@ def Tosa_MaximumOp : Tosa_ElementwiseOp<"maximum", [
771796//===----------------------------------------------------------------------===//
772797def Tosa_MinimumOp : Tosa_ElementwiseOp<"minimum", [
773798 Commutative,
774- SameOperandsAndResultElementType]> {
799+ ResultsBroadcastableShape,
800+ SameOperandsAndResultElementType,
801+ SameOperandsAndResultRank]> {
775802 let summary = "Elementwise Minimum";
776803
777804 let description = [{
@@ -814,7 +841,7 @@ def Tosa_MulOp : Tosa_ElementwiseOp<"mul", [
814841 let arguments = (ins
815842 Tosa_Tensor:$input1,
816843 Tosa_Tensor:$input2,
817- I8Attr :$shift
844+ Optional<TosaTensorRankOf<[Tosa_Int8], [1]>> :$shift
818845 );
819846
820847 let results = (outs
@@ -828,7 +855,10 @@ def Tosa_MulOp : Tosa_ElementwiseOp<"mul", [
828855//===----------------------------------------------------------------------===//
829856// Operator: pow
830857//===----------------------------------------------------------------------===//
831- def Tosa_PowOp : Tosa_ElementwiseOp<"pow", [SameOperandsAndResultElementType]> {
858+ def Tosa_PowOp : Tosa_ElementwiseOp<"pow", [
859+ ResultsBroadcastableShape,
860+ SameOperandsAndResultElementType,
861+ SameOperandsAndResultRank]> {
832862 let summary = "Computes the power of one value to another.";
833863
834864 let description = [{
@@ -851,7 +881,10 @@ def Tosa_PowOp : Tosa_ElementwiseOp<"pow", [SameOperandsAndResultElementType]> {
851881//===----------------------------------------------------------------------===//
852882// Operator: sub
853883//===----------------------------------------------------------------------===//
854- def Tosa_SubOp : Tosa_ElementwiseOp<"sub", [SameOperandsAndResultElementType]> {
884+ def Tosa_SubOp : Tosa_ElementwiseOp<"sub", [
885+ ResultsBroadcastableShape,
886+ SameOperandsAndResultElementType,
887+ SameOperandsAndResultRank]> {
855888 let summary = "Elementwise subtraction operator";
856889
857890 let description = [{
@@ -1202,7 +1235,9 @@ def Tosa_SinOp : Tosa_ElementwiseUnaryOp<"sin"> {
12021235//===----------------------------------------------------------------------===//
12031236// Operator: select
12041237//===----------------------------------------------------------------------===//
1205- def Tosa_SelectOp : Tosa_ElementwiseOp<"select"> {
1238+ def Tosa_SelectOp : Tosa_ElementwiseOp<"select", [
1239+ ResultsBroadcastableShape,
1240+ SameOperandsAndResultRank]> {
12061241 let summary = "Elementwise select operator";
12071242
12081243 let description = [{
@@ -1238,7 +1273,9 @@ def Tosa_SelectOp : Tosa_ElementwiseOp<"select"> {
12381273def Tosa_EqualOp : Tosa_ElementwiseOp<"equal", [
12391274 InferTensorType,
12401275 Commutative,
1241- SameOperandsElementType]> {
1276+ ResultsBroadcastableShape,
1277+ SameOperandsElementType,
1278+ SameOperandsAndResultRank]> {
12421279 let summary = "Returns the truth value of (x == y) element-wise.";
12431280
12441281 let description = [{
@@ -1266,7 +1303,10 @@ def Tosa_EqualOp : Tosa_ElementwiseOp<"equal", [
12661303//===----------------------------------------------------------------------===//
12671304// Operator: greater
12681305//===----------------------------------------------------------------------===//
1269- def Tosa_GreaterOp : Tosa_ElementwiseOp<"greater", [SameOperandsElementType]> {
1306+ def Tosa_GreaterOp : Tosa_ElementwiseOp<"greater", [
1307+ ResultsBroadcastableShape,
1308+ SameOperandsElementType,
1309+ SameOperandsAndResultRank]> {
12701310 let summary = "Returns the truth value of (x > y) element-wise.";
12711311
12721312 let description = [{
@@ -1288,8 +1328,11 @@ def Tosa_GreaterOp : Tosa_ElementwiseOp<"greater", [SameOperandsElementType]> {
12881328//===----------------------------------------------------------------------===//
12891329// Operator: greater_equal
12901330//===----------------------------------------------------------------------===//
1291- def Tosa_GreaterEqualOp : Tosa_ElementwiseOp<"greater_equal",
1292- [SameOperandsElementType]> {
1331+ def Tosa_GreaterEqualOp : Tosa_ElementwiseOp<"greater_equal", [
1332+ ResultsBroadcastableShape,
1333+ SameOperandsElementType,
1334+ SameOperandsAndResultRank
1335+ ]> {
12931336 let summary = "Returns the truth value of (x >= y) element-wise.";
12941337
12951338 let description = [{
0 commit comments