@@ -24,19 +24,31 @@ include "OneDNNGraphTypes.td"
24
24
class OneDNNGraph_Op<string mnemonic, list<Trait> traits = []> :
25
25
Op<OneDNNGraphDialect, mnemonic, traits>;
26
26
27
+ class OneDNNGraph_ElemwiseUnaryOp<string mnemonic, list<Trait> traits = []> :
28
+ OneDNNGraph_Op<mnemonic, traits # [SameOperandsAndResultType]> {
29
+ let arguments = (ins OneDNNGraph_LogicalTensor:$operand);
30
+ let results = (outs OneDNNGraph_LogicalTensor:$result);
31
+
32
+ let assemblyFormat =
33
+ "operands attr-dict `:` functional-type(operands, results)";
34
+ }
35
+
27
36
class OneDNNGraph_ElemwiseBinaryOp<string mnemonic, list<Trait> traits = []> :
28
37
OneDNNGraph_Op<mnemonic, traits # [SameOperandsAndResultElementType, InferTensorType]> {
29
38
let arguments = (ins OneDNNGraph_LogicalTensor:$input_0,
30
- OneDNNGraph_LogicalTensor:$input_1);
39
+ OneDNNGraph_LogicalTensor:$input_1,
40
+ DefaultValuedOptionalAttr<BoolAttr, "true">:$auto_broadcast);
31
41
let results = (outs OneDNNGraph_LogicalTensor:$result);
32
42
33
43
let assemblyFormat =
34
44
"operands attr-dict `:` functional-type(operands, results)";
35
45
}
36
46
37
- class OneDNNGraph_ElemwiseUnaryOp<string mnemonic, list<Trait> traits = []> :
38
- OneDNNGraph_Op<mnemonic, traits # [SameOperandsAndResultType]> {
39
- let arguments = (ins OneDNNGraph_LogicalTensor:$operand);
47
+ class OneDNNGraph_ReduceOp<string mnemonic, list<Trait> traits = []> :
48
+ OneDNNGraph_Op<mnemonic, traits # [SameOperandsAndResultElementType, InferTensorType]> {
49
+ let arguments = (ins OneDNNGraph_LogicalTensor:$operand,
50
+ DefaultValuedOptionalAttr<DenseI64ArrayAttr, "{}">:$axes
51
+ DefaultValuedOptionalAttr<BoolAttr, "false">:$keep_dims);
40
52
let results = (outs OneDNNGraph_LogicalTensor:$result);
41
53
42
54
let assemblyFormat =
@@ -47,35 +59,140 @@ class OneDNNGraph_ElemwiseUnaryOp<string mnemonic, list<Trait> traits = []> :
47
59
// OneDNNGraph op definitions
48
60
//===----------------------------------------------------------------------===//
49
61
62
+ // Matmul
63
+
50
64
def OneDNNGraph_MatMulOp :
51
65
OneDNNGraph_Op<"matmul", [SameOperandsAndResultElementType, InferTensorTypeAdaptor]> {
52
- let summary = "Generalized matrix multiplication";
66
+ let summary = [{
67
+ MatMul operation computes the product of two tensors with optional bias addition.
68
+ }];
53
69
let description = [{
54
- `https://spec. oneapi. io/onednn-graph/latest/ops/matrix/MatMul_1 .html`
70
+ `https://oneapi-src.github. io/oneDNN/dev_guide_op_matmul .html`
55
71
}];
56
72
57
73
let arguments = (ins OneDNNGraph_LogicalTensor:$input_a,
58
74
OneDNNGraph_LogicalTensor:$input_b,
59
75
Optional<OneDNNGraph_LogicalTensor>:$bias,
60
- DefaultValuedAttr <BoolAttr, "false">:$transpose_a,
61
- DefaultValuedAttr <BoolAttr, "false">:$transpose_b);
76
+ DefaultValuedOptionalAttr <BoolAttr, "false">:$transpose_a,
77
+ DefaultValuedOptionalAttr <BoolAttr, "false">:$transpose_b);
62
78
let results = (outs OneDNNGraph_LogicalTensor:$result);
63
79
64
80
let assemblyFormat =
65
81
"operands attr-dict `:` functional-type(operands, results)";
66
82
}
67
83
84
+ // Common Unary
85
+
68
86
def OneDNNGraph_ReLUOp : OneDNNGraph_ElemwiseUnaryOp<"relu"> {
69
87
let summary = "element-wise relu";
70
88
let description = [{
71
- `https://spec.oneapi.io/onednn-graph/latest/ops/activation/ReLU_1.html`
89
+ `https://oneapi-src.github.io/oneDNN/dev_guide_op_relu.html`
90
+ }];
91
+ }
92
+
93
+ def OneDNNGraph_SigmoidOp : OneDNNGraph_ElemwiseUnaryOp<"sigmoid"> {
94
+ let summary = "element-wise sigmoid";
95
+ let description = [{
96
+ `https://oneapi-src.github.io/oneDNN/dev_guide_op_sigmoid.html`
97
+ }];
98
+ }
99
+
100
+ // Special Unary
101
+
102
+ def OneDNNGraph_TypeCastOp : OneDNNGraph_Op<"type_cast", [SameOperandsAndResultShape]> {
103
+ let summary = [{
104
+ TypeCast operation performs element-wise cast from input data type
105
+ to the data type given by output tensor.
106
+ }];
107
+ let description = [{
108
+ `https://oneapi-src.github.io/oneDNN/dev_guide_op_typecast.html`
109
+ }];
110
+
111
+ let arguments = (ins OneDNNGraph_LogicalTensor:$operand);
112
+ let results = (outs OneDNNGraph_LogicalTensor:$result);
113
+
114
+ let assemblyFormat =
115
+ "operands attr-dict `:` functional-type(operands, results)";
116
+ }
117
+
118
+ def OneDNNGraph_PowOp : OneDNNGraph_Op<"pow", [SameOperandsAndResultType]> {
119
+ let summary = [{
120
+ Pow operation performs an element-wise power operation on a given input
121
+ tensor with a single value attribute beta as its exponent.
122
+ }];
123
+ let description = [{
124
+ `https://oneapi-src.github.io/oneDNN/dev_guide_op_pow.html`
72
125
}];
126
+
127
+ let arguments = (ins OneDNNGraph_LogicalTensor:$operand,
128
+ F32Attr:$beta);
129
+ let results = (outs OneDNNGraph_LogicalTensor:$result);
130
+
131
+ let assemblyFormat =
132
+ "operands attr-dict `:` functional-type(operands, results)";
73
133
}
74
134
135
+ // Common Binary
136
+
75
137
def OneDNNGraph_AddOp : OneDNNGraph_ElemwiseBinaryOp<"add", [Commutative]> {
76
- let summary = "element-wise addition with multi-directional broadcast";
138
+ let summary = [{
139
+ Add operation performs element-wise addition operation with two
140
+ given tensors applying multi-directional broadcast rules.
141
+ }];
142
+ let description = [{
143
+ `https://oneapi-src.github.io/oneDNN/dev_guide_op_add.html`
144
+ }];
145
+ }
146
+
147
+ def OneDNNGraph_MulOp : OneDNNGraph_ElemwiseBinaryOp<"mul", [Commutative]> {
148
+ let summary = [{
149
+ Multiply operation performs element-wise multiply operation with two
150
+ given tensors applying multi-directional broadcast rules.
151
+ }];
152
+ let description = [{
153
+ `https://oneapi-src.github.io/oneDNN/dev_guide_op_multiply.html`
154
+ }];
155
+ }
156
+
157
+ def OneDNNGraph_SubOp : OneDNNGraph_ElemwiseBinaryOp<"sub"> {
158
+ let summary = [{
159
+ Subtract operation performs element-wise subtraction operation with
160
+ two given tensors applying multi-directional broadcast rules.
161
+ }];
162
+ let description = [{
163
+ `https://oneapi-src.github.io/oneDNN/dev_guide_op_subtract.html`
164
+ }];
165
+ }
166
+
167
+ def OneDNNGraph_DivOp : OneDNNGraph_ElemwiseBinaryOp<"div"> {
168
+ let summary = [{
169
+ Divide operation performs element-wise division operation with two
170
+ given tensors applying multi-directional broadcast rules.
171
+ }];
172
+ let description = [{
173
+ `https://oneapi-src.github.io/oneDNN/dev_guide_op_divide.html`
174
+ }];
175
+ }
176
+
177
+ // Common Reduce
178
+
179
+ def OneDNNGraph_ReduceSumOp : OneDNNGraph_ReduceOp<"reduce_sum"> {
180
+ let summary = [{
181
+ ReduceSum operation performs the reduction with addition on a given
182
+ src data along dimensions specified by axes.
183
+ }];
184
+ let description = [{
185
+ `https://oneapi-src.github.io/oneDNN/dev_guide_op_reducesum.html`
186
+ }];
187
+ }
188
+
189
+ def OneDNNGraph_ReduceMeanOp : OneDNNGraph_ReduceOp<"reduce_mean"> {
190
+ let summary = [{
191
+ ReduceMean operation performs the reduction with finding the arithmetic
192
+ mean on a given src data along dimensions specified by axes.
193
+ }];
77
194
let description = [{
78
- `https://spec. oneapi. io/onednn-graph/latest/ops/arithmetic/Add_1 .html`
195
+ `https://oneapi-src.github. io/oneDNN/dev_guide_op_reducemean .html`
79
196
}];
80
197
}
81
198
0 commit comments