[PATCH] D76403: Add Builder::get{I32,I64}TensorAttr.
Sean Silva via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 18 20:37:00 PDT 2020
silvas updated this revision to Diff 251250.
silvas added a comment.
Address comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76403/new/
https://reviews.llvm.org/D76403
Files:
mlir/include/mlir/IR/Builders.h
mlir/lib/IR/Builders.cpp
Index: mlir/lib/IR/Builders.cpp
===================================================================
--- mlir/lib/IR/Builders.cpp
+++ mlir/lib/IR/Builders.cpp
@@ -109,6 +109,20 @@
values);
}
+DenseIntElementsAttr Builder::getI32TensorAttr(ArrayRef<int32_t> values) {
+ return DenseIntElementsAttr::get(
+ RankedTensorType::get(static_cast<int64_t>(values.size()),
+ getIntegerType(32)),
+ values);
+}
+
+DenseIntElementsAttr Builder::getI64TensorAttr(ArrayRef<int64_t> values) {
+ return DenseIntElementsAttr::get(
+ RankedTensorType::get(static_cast<int64_t>(values.size()),
+ getIntegerType(64)),
+ values);
+}
+
IntegerAttr Builder::getI32IntegerAttr(int32_t value) {
return IntegerAttr::get(getIntegerType(32), APInt(32, value));
}
Index: mlir/include/mlir/IR/Builders.h
===================================================================
--- mlir/include/mlir/IR/Builders.h
+++ mlir/include/mlir/IR/Builders.h
@@ -116,9 +116,16 @@
IntegerAttr getSI32IntegerAttr(int32_t value);
IntegerAttr getUI32IntegerAttr(uint32_t value);
+ /// Vector-typed DenseIntElementsAttr getters. `values` cannot be empty.
DenseIntElementsAttr getI32VectorAttr(ArrayRef<int32_t> values);
DenseIntElementsAttr getI64VectorAttr(ArrayRef<int64_t> values);
+ /// Tensor-typed DenseInteElementsAttr getters. `values` can be empty.
+ /// These are generally preferable for representing general lists of integers
+ /// as attributes.
+ DenseIntElementsAttr getI32TensorAttr(ArrayRef<int32_t> values);
+ DenseIntElementsAttr getI64TensorAttr(ArrayRef<int64_t> values);
+
ArrayAttr getAffineMapArrayAttr(ArrayRef<AffineMap> values);
ArrayAttr getI32ArrayAttr(ArrayRef<int32_t> values);
ArrayAttr getI64ArrayAttr(ArrayRef<int64_t> values);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76403.251250.patch
Type: text/x-patch
Size: 1834 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200319/80ecd227/attachment.bin>
More information about the llvm-commits
mailing list