Changeset View
Changeset View
Standalone View
Standalone View
mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir
Show All 33 Lines | |||||
// Convert `shape` to `tensor<?xindex>` type. | // Convert `shape` to `tensor<?xindex>` type. | ||||
// CHECK-LABEL: @shape_id | // CHECK-LABEL: @shape_id | ||||
// CHECK-SAME: (%[[SHAPE:.*]]: tensor<?xindex>) | // CHECK-SAME: (%[[SHAPE:.*]]: tensor<?xindex>) | ||||
func @shape_id(%shape : !shape.shape) -> !shape.shape { | func @shape_id(%shape : !shape.shape) -> !shape.shape { | ||||
// CHECK: return %[[SHAPE]] : tensor<?xindex> | // CHECK: return %[[SHAPE]] : tensor<?xindex> | ||||
return %shape : !shape.shape | return %shape : !shape.shape | ||||
} | } | ||||
// ----- | |||||
// Lower `to_extent_tensor` operation to no-op. | |||||
// CHECK-LABEL: @to_extent_tensor | |||||
// CHECK-SAME: (%[[SHAPE:.*]]: tensor<?xindex>) -> tensor<?xindex> | |||||
func @to_extent_tensor(%shape : !shape.shape) -> tensor<?xindex> { | |||||
// CHECK-NEXT: return %[[SHAPE]] : tensor<?xindex> | |||||
%tensor = "shape.to_extent_tensor"(%shape) : (!shape.shape) -> tensor<?xindex> | |||||
return %tensor : tensor<?xindex> | |||||
} | |||||
// ----- | |||||
// Lower `from_extent_tensor` operation to no-op. | |||||
// CHECK-LABEL: @from_extent_tensor | |||||
// CHECK-SAME: (%[[TENSOR:.*]]: tensor<?xindex>) -> tensor<?xindex> | |||||
func @from_extent_tensor(%tensor : tensor<?xindex>) -> !shape.shape { | |||||
// CHECK-NEXT: return %[[TENSOR]] : tensor<?xindex> | |||||
%shape = "shape.from_extent_tensor"(%tensor) | |||||
: (tensor<?xindex>) -> !shape.shape | |||||
return %shape : !shape.shape | |||||
} |