Skip to content

[mlir][tensor] Document dest operand #71726

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 6 commits into from
Nov 13, 2023
Merged

[mlir][tensor] Document dest operand #71726

merged 6 commits into from
Nov 13, 2023

Conversation

rikhuijzer
Copy link
Member

Based on the tips from @ubfx and @joker-eph in #70030, this patch suggest to introduce the dest operand in the tensor dialect description. To do so, this patch also suggests to move some things around to make it more clear how the paragraphs relate to each other.

@llvmbot
Copy link
Member

llvmbot commented Nov 8, 2023

@llvm/pr-subscribers-mlir-tensor

@llvm/pr-subscribers-mlir

Author: Rik Huijzer (rikhuijzer)

Changes

Based on the tips from @ubfx and @joker-eph in #70030, this patch suggest to introduce the dest operand in the tensor dialect description. To do so, this patch also suggests to move some things around to make it more clear how the paragraphs relate to each other.


Full diff: https://github.com/llvm/llvm-project/pull/71726.diff

1 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Tensor/IR/TensorBase.td (+18-16)
diff --git a/mlir/include/mlir/Dialect/Tensor/IR/TensorBase.td b/mlir/include/mlir/Dialect/Tensor/IR/TensorBase.td
index 1231c0a67bc305f..768edec27a755a6 100644
--- a/mlir/include/mlir/Dialect/Tensor/IR/TensorBase.td
+++ b/mlir/include/mlir/Dialect/Tensor/IR/TensorBase.td
@@ -18,31 +18,33 @@ def Tensor_Dialect : Dialect {
   let description = [{
     The `tensor` dialect is intended to hold core tensor creation and
     manipulation ops, which are not strongly associated with any particular
-    other dialect or domain abstraction. The primary smoke test of this is ops
-    that make sense for any tensor element type.
-
-    We leave it to other dialects to hold the vast swath of possible
-    computations one might want to do on a tensor.
-
-    The `tensor` type is (for better or for worse) used to represent all kinds
-    of things, and supports an open-ended set of element types. Examples:
+    other dialect or domain abstraction. The primary inclusion criteria for ops
+    in this dialect is that they make sense for any tensor element type. When
+    this is not the case, the op is left to live in other dialects. Examples of
+    element types that could be supported by the `tensor` dialect include:
 
     - representing large, dense aggregations of primitive types, suitable for
       high-performance numerical computing.
-    - representing shapes in the `shape` dialect, which consist of small
-      1D tensors of `index` data type.
+    - representing shapes in the `shape` dialect, which consist of small 1D
+      tensors of `index` data type.
     - representing aggregations of strings or “variant” types.
-    - representing large, sparse aggregations of primitive types, suitable
-      for high-performance numerical computing.
+    - representing large, sparse aggregations of primitive types, suitable for
+      high-performance numerical computing.
 
-    Thus, for the `tensor` dialect, we prefer for now to constrain the
-    scope as much as possible. The expectation is that at some point
+    Because of this broad element type support, we prefer for now to keep the
+    `tensor` dialect as small as possible. The expectation is that at some point
     in the future, the `tensor` dialect’s scope may be broadened through a
     careful discussion of the tradeoffs.
 
-    The `tensor` type is actually a builtin type (it lives in the builtin
-    dialect), and does not live in this dialect.
+    One exception to the above is the `tensor` type itself, which is actually a
+    builtin type (it lives in the builtin dialect), and does not live in this
+    dialect.
 
+    Finally, many ops in the the dialect use the `dest` operand. This is an
+    operand that is used to encode information for bufferization via the
+    `DestinationStyleOpInterface`, see the [Destination Passing Style](
+    https://mlir.llvm.org/docs/Bufferization/#destination-passing-style)
+    documentation for more information.
   }];
 
   let hasCanonicalizer = 1;

Co-authored-by: Matthias Springer <[email protected]>
Co-authored-by: Mehdi Amini <[email protected]>
Co-authored-by: Felix Schneider <[email protected]>
@rikhuijzer
Copy link
Member Author

Ah sorry for being so dense before. I think destination-passing style finally clicked for me now. The tensor is immutable (and therefore copied), but the underlying storage may be mutated.

Copy link
Collaborator

@joker-eph joker-eph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG (with one edit)

@rikhuijzer rikhuijzer merged commit dc5bdcb into llvm:main Nov 13, 2023
@rikhuijzer rikhuijzer deleted the rh/document-dest-operand branch November 13, 2023 15:37
Radu2k pushed a commit to Radu2k/llvm-project-forked-fp that referenced this pull request Nov 13, 2023
Based on the tips from @ubfx and @joker-eph in
llvm#70030, this patch suggest to
introduce the `dest` operand in the `tensor` dialect description. To do
so, this patch also suggests to move some things around to make it more
clear how the paragraphs relate to each other.

---------

Co-authored-by: Matthias Springer <[email protected]>
Co-authored-by: Mehdi Amini <[email protected]>
Co-authored-by: Felix Schneider <[email protected]>
zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Nov 20, 2023
Based on the tips from @ubfx and @joker-eph in
llvm#70030, this patch suggest to
introduce the `dest` operand in the `tensor` dialect description. To do
so, this patch also suggests to move some things around to make it more
clear how the paragraphs relate to each other.

---------

Co-authored-by: Matthias Springer <[email protected]>
Co-authored-by: Mehdi Amini <[email protected]>
Co-authored-by: Felix Schneider <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants