forked from OSchip/llvm-project
[MLIR] Add type conversion for `shape.shape`
Convert `shape.shape` to `tensor<?xindex>` when lowering the `shape` to the `std` dialect. Differential Revision: https://reviews.llvm.org/D81161
This commit is contained in:
parent
67b4afc41a
commit
867bc41e85
|
@ -56,6 +56,10 @@ public:
|
|||
// 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));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -29,3 +29,13 @@ func @index_to_size(%index : index) -> !shape.size {
|
|||
%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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue