This has been missing in the original definition of shaped types.
Reviewed By: gysit
Differential Revision: https://reviews.llvm.org/D113025
},
"Returns whether the given value is used as a placeholder for dynamic "
"strides and offsets in shaped types.");
+ c.def_property_readonly(
+ "shape",
+ [](PyShapedType &self) {
+ self.requireHasRank();
+
+ std::vector<int64_t> shape;
+ int64_t rank = mlirShapedTypeGetRank(self);
+ shape.reserve(rank);
+ for (int64_t i = 0; i < rank; ++i)
+ shape.push_back(mlirShapedTypeGetDimSize(self, i));
+ return shape;
+ },
+ "Returns the shape of the ranked shaped type as a list of integers.");
}
private:
# Encoding should be None.
assert RankedTensorType.get(shape, f32).encoding is None
+ tensor = RankedTensorType.get(shape, f32)
+ assert tensor.shape == shape
+
# CHECK-LABEL: TEST: testUnrankedTensorType
@run
else:
print("Exception not produced")
+ assert memref.shape == shape
+
# CHECK-LABEL: TEST: testUnrankedMemRefType
@run