summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR
diff options
context:
space:
mode:
authorUday Bondhugula <uday@polymagelabs.com>2019-11-22 21:47:47 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-11-22 22:09:31 -0800
commit6a101671b040f59b1fe2ae00244c08b20f2766d5 (patch)
treee5f949c7d29924371bfbb845dc7131e3b0fc7d34 /mlir/lib/IR
parentb8ee5634491e3b3b0a52dd50ccd44103c918d3fe (diff)
downloadbcm5719-llvm-6a101671b040f59b1fe2ae00244c08b20f2766d5.tar.gz
bcm5719-llvm-6a101671b040f59b1fe2ae00244c08b20f2766d5.zip
Make isValidSymbol more powerful
The check in isValidSymbol, as far as a DimOp result went, checked if the dim op was on a top-level memref. However, any alloc'ed, view, or subview memref would be fine as long as the corresponding dimension of that memref is either a static one or was in turn created using a valid symbol in the case of dynamic dimensions. Reported-by: Jose Gomez Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#252 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/252 from bondhugula:symbol 7b57dc394df9375e651f497231c6e4525a32a662 PiperOrigin-RevId: 282097114
Diffstat (limited to 'mlir/lib/IR')
-rw-r--r--mlir/lib/IR/StandardTypes.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/mlir/lib/IR/StandardTypes.cpp b/mlir/lib/IR/StandardTypes.cpp
index 3f3677cc05d..4347856de36 100644
--- a/mlir/lib/IR/StandardTypes.cpp
+++ b/mlir/lib/IR/StandardTypes.cpp
@@ -152,6 +152,12 @@ int64_t ShapedType::getDimSize(int64_t i) const {
return getShape()[i];
}
+unsigned ShapedType::getDynamicDimIndex(unsigned index) const {
+ assert(index < getRank() && "invalid index");
+ assert(ShapedType::isDynamic(getDimSize(index)) && "invalid index");
+ return llvm::count_if(getShape().take_front(index), ShapedType::isDynamic);
+}
+
/// Get the number of bits require to store a value of the given shaped type.
/// Compute the value recursively since tensors are allowed to have vectors as
/// elements.
OpenPOWER on IntegriCloud