-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[mlir][linalg] Implement Winograd Conv2D. #94470
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
276ed89
[mlir][linalg] Implement Conv2D using Winograd Conv2D algorithm
Hsiangkai dc00c79
[mlir][linalg] Add transform operator for Winograd Conv2D algorithm
Hsiangkai 14ce369
[mlir][linalg] Decompose winograd operators
Hsiangkai 5fd211c
[mlir][linalg] Implement TilingInterface for winograd operators
Hsiangkai 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,4 +154,133 @@ def Linalg_SoftmaxOp : Linalg_Op<"softmax", | |
let hasVerifier = 1; | ||
} | ||
|
||
def Linalg_WinogradFilterTransformOp : Linalg_Op<"winograd_filter_transform", | ||
[DeclareOpInterfaceMethods<TilingInterface, | ||
["getIterationDomain", | ||
"getLoopIteratorTypes", | ||
"getResultTilePosition", | ||
"getTiledImplementation"]>]> { | ||
let summary = "Winograd filter transform operator"; | ||
let description = [{ | ||
Winograd Conv2D algorithm will convert linalg Conv2D operator into batched | ||
matrix multiply. Before the matrix multiply, it will convert filter and | ||
input into a format suitable for batched matrix multiply. After the matrix | ||
multiply, it will convert output to the final result tensor. | ||
|
||
The algorithm F(m x m, r x r) is | ||
|
||
Y = A^T x [(G x g x G^T) @ (B^T x d x B)] x A | ||
|
||
The size of output Y is m x m. The size of filter g is r x r. The size of | ||
input d is (m + r - 1) x (m + r - 1). A^T, A, G^T, G, B^T, and B are | ||
transformation matrices. | ||
|
||
This operator is defined to represent the high level concept of filter | ||
transformation (G x g x G^T) in the Winograd Conv2D algorithm. | ||
}]; | ||
|
||
let arguments = (ins AnyRankedTensor:$filter, | ||
AnyRankedTensor:$output, | ||
I64Attr:$m, | ||
I64Attr:$r | ||
Comment on lines
+184
to
+185
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use more descriptive names. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
); | ||
|
||
let results = (outs AnyRankedTensor:$result); | ||
let assemblyFormat = [{ | ||
attr-dict | ||
`m` `(` $m `)` | ||
`r` `(` $r `)` | ||
`ins` `(` $filter `:` type($filter) `)` | ||
`outs` `(` $output `:` type($output) `)` | ||
`->` type($result) | ||
}]; | ||
let hasVerifier = 1; | ||
} | ||
|
||
def Linalg_WinogradInputTransformOp : Linalg_Op<"winograd_input_transform", | ||
[DeclareOpInterfaceMethods<TilingInterface, | ||
["getIterationDomain", | ||
"getLoopIteratorTypes", | ||
"getResultTilePosition", | ||
"getTiledImplementation"]>]> { | ||
let summary = "Winograd input transform operator"; | ||
let description = [{ | ||
Winograd Conv2D algorithm will convert linalg Conv2D operator into batched | ||
matrix multiply. Before the matrix multiply, it will convert filter and | ||
input into a format suitable for batched matrix multiply. After the matrix | ||
multiply, it will convert output to the final result tensor. | ||
|
||
The algorithm F(m x m, r x r) is | ||
|
||
Y = A^T x [(G x g x G^T) @ (B^T x d x B)] x A | ||
|
||
The size of output Y is m x m. The size of filter g is r x r. The size of | ||
input d is (m + r - 1) x (m + r - 1). A^T, A, G^T, G, B^T, and B are | ||
transformation matrices. | ||
|
||
This operator is defined to represent the high level concept of input | ||
transformation (B^T x d x B) in the Winograd Conv2D algorithm. | ||
}]; | ||
|
||
let arguments = (ins AnyRankedTensor:$input, | ||
AnyRankedTensor:$output, | ||
I64Attr:$m, | ||
I64Attr:$r | ||
); | ||
|
||
let results = (outs AnyRankedTensor:$result); | ||
let assemblyFormat = [{ | ||
attr-dict | ||
`m` `(` $m `)` | ||
`r` `(` $r `)` | ||
`ins` `(` $input `:` type($input) `)` | ||
`outs` `(` $output `:` type($output) `)` | ||
`->` type($result) | ||
}]; | ||
let hasVerifier = 1; | ||
} | ||
|
||
def Linalg_WinogradOutputTransformOp : Linalg_Op<"winograd_output_transform", | ||
[DeclareOpInterfaceMethods<TilingInterface, | ||
["getIterationDomain", | ||
"getLoopIteratorTypes", | ||
"getResultTilePosition", | ||
"getTiledImplementation"]>]> { | ||
let summary = "Winograd output transform operator"; | ||
let description = [{ | ||
Winograd Conv2D algorithm will convert linalg Conv2D operator into batched | ||
matrix multiply. Before the matrix multiply, it will convert filter and | ||
input into a format suitable for batched matrix multiply. After the matrix | ||
multiply, it will convert output to the final result tensor. | ||
|
||
The algorithm F(m x m, r x r) is | ||
|
||
Y = A^T x [(G x g x G^T) @ (B^T x d x B)] x A | ||
|
||
The size of output Y is m x m. The size of filter g is r x r. The size of | ||
input d is (m + r - 1) x (m + r - 1). A^T, A, G^T, G, B^T, and B are | ||
transformation matrices. | ||
|
||
This operator is defined to represent the high level concept of output | ||
transformation (A^T x y x A) in the Winograd Conv2D algorithm. | ||
}]; | ||
|
||
let arguments = (ins AnyRankedTensor:$value, | ||
AnyRankedTensor:$output, | ||
I64Attr:$m, | ||
I64Attr:$r | ||
); | ||
|
||
let results = (outs AnyRankedTensor:$result); | ||
let assemblyFormat = [{ | ||
attr-dict | ||
`m` `(` $m `)` | ||
`r` `(` $r `)` | ||
`ins` `(` $value `:` type($value) `)` | ||
`outs` `(` $output `:` type($output) `)` | ||
`->` type($result) | ||
}]; | ||
let hasVerifier = 1; | ||
} | ||
|
||
#endif // LINALG_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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.