-
Notifications
You must be signed in to change notification settings - Fork 17
[Dialect] Add basic oneDNN Graph dialect #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dd69e61
tmp remove
cd43162
rebase
8a1d971
Merge branch 'main' into longsheng/add_onednn_graph
861e546
fix
6a77167
fix test
ff2fd3b
Merge branch 'main' into longsheng/add_onednn_graph
08cf9cd
fix
aec0484
Merge branch 'main' into longsheng/add_onednn_graph
LongshengDu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
add_subdirectory(OnednnGraph) | ||
add_subdirectory(OneDNNGraph) | ||
add_subdirectory(Microkernel) | ||
add_subdirectory(Linalgx) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
add_mlir_dialect(OneDNNGraphOps onednn_graph) | ||
add_mlir_doc(OneDNNGraphOps OneDNNGraphOps gc/Dialect/OneDNNGraph/ -gen-op-doc) | ||
add_mlir_doc(OneDNNGraphDialect OneDNNGraphDialect gc/Dialect/OneDNNGraph/ -gen-dialect-doc) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
//===- OneDNNGraphOps.td - OneDNN input dialect ops --------*- tablegen -*-===// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef ONEDNNGRAPH_OPS | ||
#define ONEDNNGRAPH_OPS | ||
|
||
include "mlir/Interfaces/InferTypeOpInterface.td" | ||
include "mlir/Interfaces/SideEffectInterfaces.td" | ||
include "mlir/Interfaces/DestinationStyleOpInterface.td" | ||
include "mlir/IR/AttrTypeBase.td" | ||
include "mlir/IR/OpBase.td" | ||
include "OneDNNGraphDialect.td" | ||
include "OneDNNGraphTypes.td" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Base OneDNNGraph operation definition. | ||
//===----------------------------------------------------------------------===// | ||
|
||
class OneDNNGraph_Op<string mnemonic, list<Trait> traits = []> : | ||
Op<OneDNNGraphDialect, mnemonic, traits>; | ||
|
||
class OneDNNGraph_ElemwiseBinaryOp<string mnemonic, list<Trait> traits = []> : | ||
OneDNNGraph_Op<mnemonic, traits # [SameOperandsAndResultElementType, InferTensorType]> { | ||
let arguments = (ins OneDNNGraph_LogicalTensor:$input_0, | ||
OneDNNGraph_LogicalTensor:$input_1); | ||
let results = (outs OneDNNGraph_LogicalTensor:$result); | ||
|
||
let assemblyFormat = | ||
"operands attr-dict `:` functional-type(operands, results)"; | ||
} | ||
|
||
class OneDNNGraph_ElemwiseUnaryOp<string mnemonic, list<Trait> traits = []> : | ||
OneDNNGraph_Op<mnemonic, traits # [SameOperandsAndResultType]> { | ||
let arguments = (ins OneDNNGraph_LogicalTensor:$operand); | ||
let results = (outs OneDNNGraph_LogicalTensor:$result); | ||
|
||
let assemblyFormat = | ||
"operands attr-dict `:` functional-type(operands, results)"; | ||
} | ||
|
||
//===----------------------------------------------------------------------===// | ||
// OneDNNGraph op definitions | ||
//===----------------------------------------------------------------------===// | ||
|
||
def OneDNNGraph_MatMulOp : | ||
OneDNNGraph_Op<"matmul", [SameOperandsAndResultElementType, InferTensorTypeAdaptor]> { | ||
let summary = "Generalized matrix multiplication"; | ||
let description = [{ | ||
`https://spec.oneapi.io/onednn-graph/latest/ops/matrix/MatMul_1.html` | ||
}]; | ||
|
||
let arguments = (ins OneDNNGraph_LogicalTensor:$input_a, | ||
OneDNNGraph_LogicalTensor:$input_b, | ||
Optional<OneDNNGraph_LogicalTensor>:$bias, | ||
DefaultValuedAttr<BoolAttr, "false">:$transpose_a, | ||
DefaultValuedAttr<BoolAttr, "false">:$transpose_b); | ||
let results = (outs OneDNNGraph_LogicalTensor:$result); | ||
|
||
let assemblyFormat = | ||
"operands attr-dict `:` functional-type(operands, results)"; | ||
} | ||
|
||
def OneDNNGraph_ReLUOp : OneDNNGraph_ElemwiseUnaryOp<"relu"> { | ||
let summary = "element-wise relu"; | ||
let description = [{ | ||
`https://spec.oneapi.io/onednn-graph/latest/ops/activation/ReLU_1.html` | ||
}]; | ||
} | ||
|
||
def OneDNNGraph_AddOp : OneDNNGraph_ElemwiseBinaryOp<"add", [Commutative]> { | ||
let summary = "element-wise addition with multi-directional broadcast"; | ||
let description = [{ | ||
`https://spec.oneapi.io/onednn-graph/latest/ops/arithmetic/Add_1.html` | ||
}]; | ||
} | ||
|
||
#endif // ONEDNNGRAPH_OPS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//===- OneDNNGraphTypes.h - OneDNN input dialect types ----------*- C++ -*-===// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef ONEDNNGRAPH_ONEDNNGRAPHTYPES_H | ||
#define ONEDNNGRAPH_ONEDNNGRAPHTYPES_H | ||
|
||
#include "mlir/IR/BuiltinTypes.h" | ||
|
||
#define GET_TYPEDEF_CLASSES | ||
#include "gc/Dialect/OneDNNGraph/OneDNNGraphOpsTypes.h.inc" | ||
|
||
#endif // ONEDNNGRAPH_ONEDNNGRAPHTYPES_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===- OneDNNGraphTypes.h - OneDNN input dialect types -----*- tablegen -*-===// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef ONEDNNGRAPH_TYPES | ||
#define ONEDNNGRAPH_TYPES | ||
|
||
include "mlir/IR/BuiltinTypes.td" | ||
include "mlir/IR/AttrTypeBase.td" | ||
include "OneDNNGraphDialect.td" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// OneDNNGraph type definitions | ||
//===----------------------------------------------------------------------===// | ||
|
||
def OneDNNGraph_DataType : AnyTypeOf<[ | ||
F16, | ||
BF16, | ||
F32, | ||
SI<32>, | ||
SI<8>, | ||
UI<8>]>; | ||
|
||
def OneDNNGraph_LogicalTensor : TensorOf<[OneDNNGraph_DataType]>; | ||
|
||
#endif // ONEDNNGRAPH_TYPES |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
add_subdirectory(Linalgx) | ||
add_subdirectory(Microkernel) | ||
add_subdirectory(OnednnGraph) | ||
add_subdirectory(OneDNNGraph) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
add_mlir_dialect_library(MLIROneDNNGraph | ||
OneDNNGraphDialect.cpp | ||
OneDNNGraphOps.cpp | ||
|
||
ADDITIONAL_HEADER_DIRS | ||
${PROJECT_SOURCE_DIR}/include/gc/Dialect/OneDNNGraph | ||
|
||
DEPENDS | ||
MLIROneDNNGraphOpsIncGen | ||
|
||
LINK_LIBS PUBLIC | ||
MLIRIR | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//===- OneDNNGraphDialect.h - OneDNN input dialect --------------*- C++ -*-===// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "gc/Dialect/OneDNNGraph/OneDNNGraphDialect.h" | ||
#include "gc/Dialect/OneDNNGraph/OneDNNGraphOps.h" | ||
#include "gc/Dialect/OneDNNGraph/OneDNNGraphTypes.h" | ||
|
||
using namespace mlir; | ||
using namespace mlir::onednn_graph; | ||
|
||
#include "gc/Dialect/OneDNNGraph/OneDNNGraphOpsDialect.cpp.inc" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// OneDNNGraph dialect. | ||
//===----------------------------------------------------------------------===// | ||
|
||
void OneDNNGraphDialect::initialize() { | ||
addOperations< | ||
#define GET_OP_LIST | ||
#include "gc/Dialect/OneDNNGraph/OneDNNGraphOps.cpp.inc" | ||
>(); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think making assembly format explicit would be better.