Convert `shape.shape` to `tensor<?xindex>` when lowering the `shape` to the
`std` dialect.
Differential Revision: https://reviews.llvm.org/D81161
// Add default pass-through conversion.
addConversion([&](Type type) { return type; });
addConversion([ctx](shape::SizeType type) { return IndexType::get(ctx); });
+ addConversion([ctx](shape::ShapeType type) {
+ return RankedTensorType::get({ShapedType::kDynamicSize},
+ IndexType::get(ctx));
+ });
}
};
%size = shape.index_to_size %index
return %size : !shape.size
}
+
+// -----
+
+// Convert `shape` to `tensor<?xindex>` type.
+// CHECK-LABEL: @shape_id
+// CHECK-SAME: (%[[SHAPE:.*]]: tensor<?xindex>)
+func @shape_id(%shape : !shape.shape) -> !shape.shape {
+ // CHECK: return %[[SHAPE]] : tensor<?xindex>
+ return %shape : !shape.shape
+}