@@ -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 = [{
@@ -769,7 +794,9 @@ def Tosa_MaximumOp : Tosa_ElementwiseOp<"maximum", [
769794//===----------------------------------------------------------------------===//
770795def Tosa_MinimumOp : Tosa_ElementwiseOp<"minimum", [
771796 Commutative,
772- SameOperandsAndResultElementType]> {
797+ ResultsBroadcastableShape,
798+ SameOperandsAndResultElementType,
799+ SameOperandsAndResultRank]> {
773800 let summary = "Elementwise Minimum";
774801
775802 let description = [{
@@ -810,7 +837,7 @@ def Tosa_MulOp : Tosa_ElementwiseOp<"mul", [
810837 let arguments = (ins
811838 Tosa_Tensor:$input1,
812839 Tosa_Tensor:$input2,
813- I8Attr :$shift
840+ Optional<TosaTensorRankOf<[Tosa_Int8], [1]>> :$shift
814841 );
815842
816843 let results = (outs
@@ -824,7 +851,10 @@ def Tosa_MulOp : Tosa_ElementwiseOp<"mul", [
824851//===----------------------------------------------------------------------===//
825852// Operator: pow
826853//===----------------------------------------------------------------------===//
827- def Tosa_PowOp : Tosa_ElementwiseOp<"pow", [SameOperandsAndResultElementType]> {
854+ def Tosa_PowOp : Tosa_ElementwiseOp<"pow", [
855+ ResultsBroadcastableShape,
856+ SameOperandsAndResultElementType,
857+ SameOperandsAndResultRank]> {
828858 let summary = "Computes the power of one value to another.";
829859
830860 let description = [{
@@ -845,7 +875,10 @@ def Tosa_PowOp : Tosa_ElementwiseOp<"pow", [SameOperandsAndResultElementType]> {
845875//===----------------------------------------------------------------------===//
846876// Operator: sub
847877//===----------------------------------------------------------------------===//
848- def Tosa_SubOp : Tosa_ElementwiseOp<"sub", [SameOperandsAndResultElementType]> {
878+ def Tosa_SubOp : Tosa_ElementwiseOp<"sub", [
879+ ResultsBroadcastableShape,
880+ SameOperandsAndResultElementType,
881+ SameOperandsAndResultRank]> {
849882 let summary = "Elementwise subtraction operator";
850883
851884 let description = [{
@@ -1196,7 +1229,9 @@ def Tosa_SinOp : Tosa_ElementwiseUnaryOp<"sin"> {
11961229//===----------------------------------------------------------------------===//
11971230// Operator: select
11981231//===----------------------------------------------------------------------===//
1199- def Tosa_SelectOp : Tosa_ElementwiseOp<"select"> {
1232+ def Tosa_SelectOp : Tosa_ElementwiseOp<"select", [
1233+ ResultsBroadcastableShape,
1234+ SameOperandsAndResultRank]> {
12001235 let summary = "Elementwise select operator";
12011236
12021237 let description = [{
@@ -1232,7 +1267,9 @@ def Tosa_SelectOp : Tosa_ElementwiseOp<"select"> {
12321267def Tosa_EqualOp : Tosa_ElementwiseOp<"equal", [
12331268 InferTensorType,
12341269 Commutative,
1235- SameOperandsElementType]> {
1270+ ResultsBroadcastableShape,
1271+ SameOperandsElementType,
1272+ SameOperandsAndResultRank]> {
12361273 let summary = "Returns the truth value of (x == y) element-wise.";
12371274
12381275 let description = [{
@@ -1260,7 +1297,10 @@ def Tosa_EqualOp : Tosa_ElementwiseOp<"equal", [
12601297//===----------------------------------------------------------------------===//
12611298// Operator: greater
12621299//===----------------------------------------------------------------------===//
1263- def Tosa_GreaterOp : Tosa_ElementwiseOp<"greater", [SameOperandsElementType]> {
1300+ def Tosa_GreaterOp : Tosa_ElementwiseOp<"greater", [
1301+ ResultsBroadcastableShape,
1302+ SameOperandsElementType,
1303+ SameOperandsAndResultRank]> {
12641304 let summary = "Returns the truth value of (x > y) element-wise.";
12651305
12661306 let description = [{
@@ -1282,8 +1322,11 @@ def Tosa_GreaterOp : Tosa_ElementwiseOp<"greater", [SameOperandsElementType]> {
12821322//===----------------------------------------------------------------------===//
12831323// Operator: greater_equal
12841324//===----------------------------------------------------------------------===//
1285- def Tosa_GreaterEqualOp : Tosa_ElementwiseOp<"greater_equal",
1286- [SameOperandsElementType]> {
1325+ def Tosa_GreaterEqualOp : Tosa_ElementwiseOp<"greater_equal", [
1326+ ResultsBroadcastableShape,
1327+ SameOperandsElementType,
1328+ SameOperandsAndResultRank
1329+ ]> {
12871330 let summary = "Returns the truth value of (x >= y) element-wise.";
12881331
12891332 let description = [{
0 commit comments