Skip to content

Commit 21992a7

Browse files
author
Longsheng Du
committed
add def
1 parent 51ac048 commit 21992a7

File tree

1 file changed

+128
-11
lines changed

1 file changed

+128
-11
lines changed

include/gc/Dialect/OneDNNGraph/OneDNNGraphOps.td

Lines changed: 128 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,31 @@ include "OneDNNGraphTypes.td"
2424
class OneDNNGraph_Op<string mnemonic, list<Trait> traits = []> :
2525
Op<OneDNNGraphDialect, mnemonic, traits>;
2626

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+
2736
class OneDNNGraph_ElemwiseBinaryOp<string mnemonic, list<Trait> traits = []> :
2837
OneDNNGraph_Op<mnemonic, traits # [SameOperandsAndResultElementType, InferTensorType]> {
2938
let arguments = (ins OneDNNGraph_LogicalTensor:$input_0,
30-
OneDNNGraph_LogicalTensor:$input_1);
39+
OneDNNGraph_LogicalTensor:$input_1,
40+
DefaultValuedOptionalAttr<BoolAttr, "true">:$auto_broadcast);
3141
let results = (outs OneDNNGraph_LogicalTensor:$result);
3242

3343
let assemblyFormat =
3444
"operands attr-dict `:` functional-type(operands, results)";
3545
}
3646

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);
4052
let results = (outs OneDNNGraph_LogicalTensor:$result);
4153

4254
let assemblyFormat =
@@ -47,35 +59,140 @@ class OneDNNGraph_ElemwiseUnaryOp<string mnemonic, list<Trait> traits = []> :
4759
// OneDNNGraph op definitions
4860
//===----------------------------------------------------------------------===//
4961

62+
// Matmul
63+
5064
def OneDNNGraph_MatMulOp :
5165
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+
}];
5369
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`
5571
}];
5672

5773
let arguments = (ins OneDNNGraph_LogicalTensor:$input_a,
5874
OneDNNGraph_LogicalTensor:$input_b,
5975
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);
6278
let results = (outs OneDNNGraph_LogicalTensor:$result);
6379

6480
let assemblyFormat =
6581
"operands attr-dict `:` functional-type(operands, results)";
6682
}
6783

84+
// Common Unary
85+
6886
def OneDNNGraph_ReLUOp : OneDNNGraph_ElemwiseUnaryOp<"relu"> {
6987
let summary = "element-wise relu";
7088
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`
72125
}];
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)";
73133
}
74134

135+
// Common Binary
136+
75137
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+
}];
77194
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`
79196
}];
80197
}
81198

0 commit comments

Comments
 (0)