[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:
Frederik Gossen 2020-06-08 09:33:24 +00:00
parent 67b4afc41a
commit 867bc41e85
2 changed files with 14 additions and 0 deletions

View File

@ -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));
});
}
};

View File

@ -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
}