forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mlir][tensor] Introduce
TensorRelayoutOpInterface
(llvm#125823)
The newly introduced `TensorRelayoutOpInterface` is created specifically for `tensor.pack` + `tensor.unpack`. Although the interface is currently empty, it enables us to refactor the logic in `FoldTensorCastProducerOp` within the Tensor dialect as follows: ```cpp // OLD // Reject tensor::PackOp - there's dedicated pattern for that instead. if (!foldTensorCastPrecondition(op) || isa<tensor::PackOp, tensor::UnPackOp>(*op)) return failure(); ``` is replaced with: ```cpp // NEW // Reject tensor::PackOp - there's dedicated pattern for that instead. if (!foldTensorCastPrecondition(op) || isa<tensor::RelayoutOpInterface>(*op)) return failure(); ``` This will be crucial once `tensor.pack` + `tensor.pack` are replaced with `linalg.pack` + `linalg.unpack` (i.e. moved to Linalg): * llvm#123902, * https://discourse.llvm.org/t/rfc-move-tensor-pack-and-tensor-unpack-into-linalg/. Note that the interface itself will later be moved to the Linalg dialect. This decoupling ensures that the Tensor dialect does not require an understanding of Linalg ops, thus keeping the dependency lightweight. This PR is effectively a preparatory step for moving PackOp and UnpackOp to Linalg. Once that's completed, most CMake changes from this PR will be effectively reverted.
- Loading branch information
1 parent
85ec493
commit 7869ab4
Showing
6 changed files
with
49 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
add_mlir_dialect(TensorOps tensor) | ||
add_mlir_doc(TensorOps TensorOps Dialects/ -gen-dialect-doc) | ||
|
||
set(LLVM_TARGET_DEFINITIONS TensorInterfaces.td) | ||
mlir_tablegen(TensorInterfaces.h.inc -gen-op-interface-decls) | ||
mlir_tablegen(TensorInterfaces.cpp.inc -gen-op-interface-defs) | ||
add_public_tablegen_target(MLIRTensorInterfacesIncGen) | ||
add_dependencies(mlir-headers MLIRTensorInterfacesIncGen) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//===- TensorInterfaces.td - Tensor Interfaces Declaration -*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This is the definition file for the structured interface sfor Tensor ops. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef TENSOR_IR_TENSORINTERFACES | ||
#define TENSOR_IR_TENSORINTERFACES | ||
|
||
include "mlir/Interfaces/DestinationStyleOpInterface.td" | ||
include "mlir/IR/OpBase.td" | ||
|
||
// TODO: To be moved to LinalgInterfaces.td, see: | ||
// * https://github.com/llvm/llvm-project/pull/123902 | ||
// * https://discourse.llvm.org/t/rfc-move-tensor-pack-and-tensor-unpack-into-linalg/ | ||
def TensorRelayoutOpInterface : OpInterface<"RelayoutOpInterface"> { | ||
let description = [{ | ||
A Tensor (soon to be Linalg) relayout-op is either tensor.pack or | ||
tensor.unpack. | ||
|
||
While we could extend this interface with methods from Tensor_RelayoutOp, | ||
this is currently not needed and left as a TODO. | ||
}]; | ||
let cppNamespace = "::mlir::tensor"; | ||
} | ||
|
||
#endif // TENSOR_IR_TENSORINTERFACES |
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