forked from iree-org/iree
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Encoding] Introduce EncodingLayoutAttrInterface. (iree-org#19216)
The revisions introduces a new attribute interface in the Encoding dialect. The interface is used to query layout information needed to materialize encoding attributes. Any backend can implement the interface to interpret an encoding layout based on their needs. The current expectation of the interface is to propagate layout information from backends to the host compilation or other targets. The expectation can be adjusted as long as we identify additional needs for encodings/layouts. It is a step towards iree-org#17924 --------- Signed-off-by: hanhanW <[email protected]>
- Loading branch information
Showing
5 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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
49 changes: 49 additions & 0 deletions
49
compiler/src/iree/compiler/Dialect/Encoding/IR/EncodingInterfaces.td
This file contains 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,49 @@ | ||
// Copyright 2024 The IREE Authors | ||
// | ||
// 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 IREE_DIALECT_ENCODING_INTERFACES | ||
#define IREE_DIALECT_ENCODING_INTERFACES | ||
|
||
include "iree/compiler/Dialect/Encoding/IR/EncodingBase.td" | ||
include "mlir/IR/BuiltinAttributeInterfaces.td" | ||
|
||
def IREEEncoding_EncodingLayoutAttrInterface : | ||
AttrInterface<"EncodingLayoutAttrInterface"> { | ||
let cppNamespace = "::mlir::iree_compiler::IREE::Encoding"; | ||
let description = [{ | ||
Interface used to query layout information needed to materialize encoding | ||
attributes. | ||
|
||
Any backend can implement the interface to interpret an encoding layout | ||
based on their needs. | ||
|
||
TBD. The current expectation of the interface is to propagate layout | ||
information from backends to the host compliation or other targets. | ||
}]; | ||
|
||
let methods = [ | ||
InterfaceMethod< | ||
/*desc=*/[{ | ||
Returns the storage size (in bytes) for the tensor types with an | ||
optional encoding. | ||
}], | ||
/*retTy=*/"::mlir::OpFoldResult", | ||
/*methodName=*/"calculateStorageSizeInBytes", | ||
/*args=*/(ins | ||
"::mlir::OpBuilder &":$builder, | ||
"RankedTensorType":$type, | ||
"ValueRange":$dynamicDims | ||
), | ||
/*methodBody=*/"", | ||
/*defaultImplementation=*/[{ | ||
assert(false && "unimplemented interface method"); | ||
return {}; | ||
}] | ||
> | ||
]; | ||
} | ||
|
||
#endif // IREE_DIALECT_ENCODING_INTERFACES |
This file contains 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