[Mlir-commits] [mlir] 0e185ce - [mlir] NFC - Address post-commit comments
Nicolas Vasilache
llvmlistbot at llvm.org
Fri Nov 12 07:05:20 PST 2021
Author: Nicolas Vasilache
Date: 2021-11-12T15:01:29Z
New Revision: 0e185ceafb91c00382a31835215d3bae9d819613
URL: https://github.com/llvm/llvm-project/commit/0e185ceafb91c00382a31835215d3bae9d819613
DIFF: https://github.com/llvm/llvm-project/commit/0e185ceafb91c00382a31835215d3bae9d819613.diff
LOG: [mlir] NFC - Address post-commit comments
Address comments from https://reviews.llvm.org/D113745
which landed as aa3731806723a2a12914aecda2af6e40e1903702
Added:
Modified:
mlir/include/mlir/Dialect/Tensor/IR/Tensor.h
mlir/include/mlir/IR/BuiltinTypes.h
mlir/include/mlir/IR/BuiltinTypes.td
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h b/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h
index f9e3014838a1..778bf67621f2 100644
--- a/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h
+++ b/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h
@@ -87,13 +87,16 @@ bool canFoldIntoConsumerOp(CastOp castOp);
LogicalResult foldTensorCast(Operation *op);
/// Create a rank-reducing ExtractSliceOp @[0 .. 0] with strides [1 .. 1] and
-/// appropriate sizes to reduce the rank of `tensor` to `targetType`.
+/// appropriate sizes (i.e. `tensor.getSizes()`) to reduce the rank of `tensor`
+/// to that of `targetType`.
Value createCanonicalRankReducingExtractSliceOp(OpBuilder &b, Location loc,
Value tensor,
RankedTensorType targetType);
/// Create a rank-reducing InsertSliceOp @[0 .. 0] with strides [1 .. 1] and
-/// appropriate sizes to increase the rank of `tensor` to `dest`.
+/// appropriate sizes (i.e. `dest.getSizes()`). The result is a new tensor with
+/// rank increased to that of `dest`, obtained by inserting `tensor` into `dest`
+/// at the canonical [0 .. 0] position.
Value createCanonicalRankReducingInsertSliceOp(OpBuilder &b, Location loc,
Value tensor, Value dest);
diff --git a/mlir/include/mlir/IR/BuiltinTypes.h b/mlir/include/mlir/IR/BuiltinTypes.h
index fb8dbd8a6c5b..0e2541db9951 100644
--- a/mlir/include/mlir/IR/BuiltinTypes.h
+++ b/mlir/include/mlir/IR/BuiltinTypes.h
@@ -204,21 +204,21 @@ class BaseMemRefType : public ShapedType {
namespace mlir {
//===----------------------------------------------------------------------===//
-// RankedTensorType
+// MemRefType
//===----------------------------------------------------------------------===//
/// This is a builder type that keeps local references to arguments. Arguments
-/// that are passed into the builder must out-live the builder.
-class RankedTensorType::Builder {
+/// that are passed into the builder must outlive the builder.
+class MemRefType::Builder {
public:
- /// Build from another RankedTensorType.
- explicit Builder(RankedTensorType other)
+ // Build from another MemRefType.
+ explicit Builder(MemRefType other)
: shape(other.getShape()), elementType(other.getElementType()),
- encoding(other.getEncoding()) {}
+ layout(other.getLayout()), memorySpace(other.getMemorySpace()) {}
- /// Build from scratch.
- Builder(ArrayRef<int64_t> shape, Type elementType, Attribute encoding)
- : shape(shape), elementType(elementType), encoding(encoding) {}
+ // Build from scratch.
+ Builder(ArrayRef<int64_t> shape, Type elementType)
+ : shape(shape), elementType(elementType) {}
Builder &setShape(ArrayRef<int64_t> newShape) {
shape = newShape;
@@ -230,45 +230,46 @@ class RankedTensorType::Builder {
return *this;
}
- Builder &setEncoding(Attribute newEncoding) {
- encoding = newEncoding;
+ Builder &setLayout(MemRefLayoutAttrInterface newLayout) {
+ layout = newLayout;
return *this;
}
- /// Create a new RankedTensor by erasing a dim from shape.
- // Note: the newly created type has ownership of a new shape vector.
- RankedTensorType dropDim(unsigned dim) {
- SmallVector<int64_t, 4> newShape(shape.begin(), shape.end());
- newShape.erase(newShape.begin() + dim);
- return setShape(newShape);
+ Builder &setMemorySpace(Attribute newMemorySpace) {
+ memorySpace = newMemorySpace;
+ return *this;
}
- operator RankedTensorType() {
- return RankedTensorType::get(shape, elementType, encoding);
+ // [deprecated] `setMemorySpace(Attribute)` should be used instead.
+ Builder &setMemorySpace(unsigned newMemorySpace);
+
+ operator MemRefType() {
+ return MemRefType::get(shape, elementType, layout, memorySpace);
}
private:
ArrayRef<int64_t> shape;
Type elementType;
- Attribute encoding;
+ MemRefLayoutAttrInterface layout;
+ Attribute memorySpace;
};
//===----------------------------------------------------------------------===//
-// MemRefType
+// RankedTensorType
//===----------------------------------------------------------------------===//
/// This is a builder type that keeps local references to arguments. Arguments
-/// that are passed into the builder must out-live the builder.
-class MemRefType::Builder {
+/// that are passed into the builder must outlive the builder.
+class RankedTensorType::Builder {
public:
- // Build from another MemRefType.
- explicit Builder(MemRefType other)
+ /// Build from another RankedTensorType.
+ explicit Builder(RankedTensorType other)
: shape(other.getShape()), elementType(other.getElementType()),
- layout(other.getLayout()), memorySpace(other.getMemorySpace()) {}
+ encoding(other.getEncoding()) {}
- // Build from scratch.
- Builder(ArrayRef<int64_t> shape, Type elementType)
- : shape(shape), elementType(elementType) {}
+ /// Build from scratch.
+ Builder(ArrayRef<int64_t> shape, Type elementType, Attribute encoding)
+ : shape(shape), elementType(elementType), encoding(encoding) {}
Builder &setShape(ArrayRef<int64_t> newShape) {
shape = newShape;
@@ -280,28 +281,26 @@ class MemRefType::Builder {
return *this;
}
- Builder &setLayout(MemRefLayoutAttrInterface newLayout) {
- layout = newLayout;
+ Builder &setEncoding(Attribute newEncoding) {
+ encoding = newEncoding;
return *this;
}
- Builder &setMemorySpace(Attribute newMemorySpace) {
- memorySpace = newMemorySpace;
- return *this;
+ /// Create a new RankedTensorType by erasing a dim from shape.
+ RankedTensorType dropDim(unsigned dim) {
+ SmallVector<int64_t, 4> newShape(shape.begin(), shape.end());
+ newShape.erase(newShape.begin() + dim);
+ return setShape(newShape);
}
- // [deprecated] `setMemorySpace(Attribute)` should be used instead.
- Builder &setMemorySpace(unsigned newMemorySpace);
-
- operator MemRefType() {
- return MemRefType::get(shape, elementType, layout, memorySpace);
+ operator RankedTensorType() {
+ return RankedTensorType::get(shape, elementType, encoding);
}
private:
ArrayRef<int64_t> shape;
Type elementType;
- MemRefLayoutAttrInterface layout;
- Attribute memorySpace;
+ Attribute encoding;
};
/// Given an `originalShape` and a `reducedShape` assumed to be a subset of
diff --git a/mlir/include/mlir/IR/BuiltinTypes.td b/mlir/include/mlir/IR/BuiltinTypes.td
index c05ff6480592..b3b23d590180 100644
--- a/mlir/include/mlir/IR/BuiltinTypes.td
+++ b/mlir/include/mlir/IR/BuiltinTypes.td
@@ -542,7 +542,7 @@ def Builtin_MemRef : Builtin_Type<"MemRef", [
];
let extraClassDeclaration = [{
/// This is a builder type that keeps local references to arguments.
- /// Arguments that are passed into the builder must out-live the builder.
+ /// Arguments that are passed into the builder must outlive the builder.
class Builder;
/// [deprecated] Returns the memory space in old raw integer representation.
@@ -703,7 +703,7 @@ def Builtin_RankedTensor : Builtin_Type<"RankedTensor", [
];
let extraClassDeclaration = [{
/// This is a builder type that keeps local references to arguments.
- /// Arguments that are passed into the builder must out-live the builder.
+ /// Arguments that are passed into the builder must outlive the builder.
class Builder;
}];
let skipDefaultBuilders = 1;
More information about the Mlir-commits
mailing list