CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
108 lines
5.2 KiB
MLIR
108 lines
5.2 KiB
MLIR
// RUN: mlir-opt --expand-realloc %s --split-input-file --verify-diagnostics | FileCheck %s
|
|
// RUN: mlir-opt --expand-realloc=emit-deallocs=false %s --split-input-file --verify-diagnostics | FileCheck %s --check-prefix=NODEALLOC
|
|
|
|
func.func @reallow_lowering_example(%init_size: index, %new_size: index) -> memref<?xf32> {
|
|
%alloc = memref.alloc(%init_size) : memref<?xf32>
|
|
%realloc = memref.realloc %alloc (%new_size) {alignment = 8}: memref<?xf32> to memref<?xf32>
|
|
return %realloc : memref<?xf32>
|
|
}
|
|
|
|
// CHECK-LABEL: func @reallow_lowering_example
|
|
// CHECK-SAME: ([[INIT_SIZE:%.+]]: index, [[NEW_SIZE:%.+]]: index)
|
|
// CHECK-NEXT: [[OLD_ALLOC:%.+]] = memref.alloc([[INIT_SIZE]]) : memref<?xf32>
|
|
// CHECK-NEXT: [[C0:%.+]] = arith.constant 0
|
|
// CHECK-NEXT: [[CURR_SIZE:%.+]] = memref.dim [[OLD_ALLOC]], [[C0]]
|
|
// CHECK-NEXT: [[COND:%.+]] = arith.cmpi ult, [[CURR_SIZE]], [[NEW_SIZE]]
|
|
// CHECK-NEXT: [[REALLOC:%.+]] = scf.if [[COND]]
|
|
// CHECK-NEXT: [[NEW_ALLOC:%.+]] = memref.alloc([[NEW_SIZE]]) {alignment = 8 : i64} : memref<?xf32>
|
|
// CHECK-NEXT: [[SUBVIEW:%.+]] = memref.subview [[NEW_ALLOC]][0] [[[CURR_SIZE]]] [1]
|
|
// CHECK-NEXT: memref.copy [[OLD_ALLOC]], [[SUBVIEW]]
|
|
// CHECK-NEXT: memref.dealloc [[OLD_ALLOC]]
|
|
// CHECK-NEXT: scf.yield [[NEW_ALLOC]]
|
|
// CHECK: [[CAST:%.+]] = memref.reinterpret_cast [[OLD_ALLOC]] to offset: [0], sizes: [[[NEW_SIZE]]], strides: [1] : memref<?xf32> to memref<?xf32>
|
|
// CHECK-NEXT: scf.yield [[CAST]]
|
|
// CHECK: return [[REALLOC]]
|
|
|
|
// NODEALLOC-LABEL: func @reallow_lowering_example
|
|
// NODEALLOC-NOT: dealloc
|
|
|
|
// -----
|
|
|
|
func.func @reallow_lowering_example() -> memref<4xf32> {
|
|
%alloc = memref.alloc() : memref<2xf32>
|
|
%realloc = memref.realloc %alloc {alignment = 8}: memref<2xf32> to memref<4xf32>
|
|
return %realloc : memref<4xf32>
|
|
}
|
|
|
|
// CHECK-LABEL: func @reallow_lowering_example
|
|
// CHECK-NEXT: [[OLD_ALLOC:%.+]] = memref.alloc() : memref<2xf32>
|
|
// CHECK-NEXT: [[CURR_SIZE:%.+]] = arith.constant 2
|
|
// CHECK-NEXT: [[NEW_SIZE:%.+]] = arith.constant 4
|
|
// CHECK-NEXT: [[COND:%.+]] = arith.cmpi ult, [[CURR_SIZE]], [[NEW_SIZE]]
|
|
// CHECK-NEXT: [[REALLOC:%.+]] = scf.if [[COND]]
|
|
// CHECK-NEXT: [[NEW_ALLOC:%.+]] = memref.alloc() {alignment = 8 : i64} : memref<4xf32>
|
|
// CHECK-NEXT: [[SUBVIEW:%.+]] = memref.subview [[NEW_ALLOC]][0] [2] [1]
|
|
// CHECK-NEXT: memref.copy [[OLD_ALLOC]], [[SUBVIEW]]
|
|
// CHECK-NEXT: memref.dealloc [[OLD_ALLOC]]
|
|
// CHECK-NEXT: scf.yield [[NEW_ALLOC]]
|
|
// CHECK: [[CAST:%.+]] = memref.reinterpret_cast [[OLD_ALLOC]] to offset: [0], sizes: [4], strides: [1] : memref<2xf32> to memref<4xf32>
|
|
// CHECK-NEXT: scf.yield [[CAST]]
|
|
// CHECK: return [[REALLOC]]
|
|
|
|
// NODEALLOC-LABEL: func @reallow_lowering_example
|
|
// NODEALLOC-NOT: dealloc
|
|
|
|
// -----
|
|
|
|
func.func @reallow_lowering_example(%init_size: index) -> memref<4xf32> {
|
|
%alloc = memref.alloc(%init_size) : memref<?xf32>
|
|
%realloc = memref.realloc %alloc : memref<?xf32> to memref<4xf32>
|
|
return %realloc : memref<4xf32>
|
|
}
|
|
|
|
// CHECK-LABEL: func @reallow_lowering_example
|
|
// CHECK-SAME: ([[INIT_SIZE:%.+]]: index)
|
|
// CHECK-NEXT: [[OLD_ALLOC:%.+]] = memref.alloc([[INIT_SIZE]]) : memref<?xf32>
|
|
// CHECK-NEXT: [[C0:%.+]] = arith.constant 0
|
|
// CHECK-NEXT: [[CURR_SIZE:%.+]] = memref.dim [[OLD_ALLOC]], [[C0]]
|
|
// CHECK-NEXT: [[NEW_SIZE:%.+]] = arith.constant 4
|
|
// CHECK-NEXT: [[COND:%.+]] = arith.cmpi ult, [[CURR_SIZE]], [[NEW_SIZE]]
|
|
// CHECK-NEXT: [[REALLOC:%.+]] = scf.if [[COND]]
|
|
// CHECK-NEXT: [[NEW_ALLOC:%.+]] = memref.alloc() : memref<4xf32>
|
|
// CHECK-NEXT: [[SUBVIEW:%.+]] = memref.subview [[NEW_ALLOC]][0] [[[CURR_SIZE]]] [1]
|
|
// CHECK-NEXT: memref.copy [[OLD_ALLOC]], [[SUBVIEW]]
|
|
// CHECK-NEXT: memref.dealloc [[OLD_ALLOC]]
|
|
// CHECK-NEXT: scf.yield [[NEW_ALLOC]]
|
|
// CHECK: [[CAST:%.+]] = memref.reinterpret_cast [[OLD_ALLOC]] to offset: [0], sizes: [4], strides: [1] : memref<?xf32> to memref<4xf32>
|
|
// CHECK-NEXT: scf.yield [[CAST]]
|
|
// CHECK: return [[REALLOC]]
|
|
|
|
// NODEALLOC-LABEL: func @reallow_lowering_example
|
|
// NODEALLOC-NOT: dealloc
|
|
|
|
// -----
|
|
|
|
func.func @reallow_lowering_example(%new_size: index) -> memref<?xf32> {
|
|
%alloc = memref.alloc() : memref<2xf32>
|
|
%realloc = memref.realloc %alloc(%new_size) : memref<2xf32> to memref<?xf32>
|
|
return %realloc : memref<?xf32>
|
|
}
|
|
|
|
// CHECK-LABEL: func @reallow_lowering_example
|
|
// CHECK-SAME: ([[NEW_SIZE:%.+]]: index)
|
|
// CHECK-NEXT: [[OLD_ALLOC:%.+]] = memref.alloc() : memref<2xf32>
|
|
// CHECK-NEXT: [[CURR_SIZE:%.+]] = arith.constant 2
|
|
// CHECK-NEXT: [[COND:%.+]] = arith.cmpi ult, [[CURR_SIZE]], [[NEW_SIZE]]
|
|
// CHECK-NEXT: [[REALLOC:%.+]] = scf.if [[COND]]
|
|
// CHECK-NEXT: [[NEW_ALLOC:%.+]] = memref.alloc([[NEW_SIZE]]) : memref<?xf32>
|
|
// CHECK-NEXT: [[SUBVIEW:%.+]] = memref.subview [[NEW_ALLOC]][0] [2] [1]
|
|
// CHECK-NEXT: memref.copy [[OLD_ALLOC]], [[SUBVIEW]]
|
|
// CHECK-NEXT: memref.dealloc [[OLD_ALLOC]]
|
|
// CHECK-NEXT: scf.yield [[NEW_ALLOC]]
|
|
// CHECK: [[CAST:%.+]] = memref.reinterpret_cast [[OLD_ALLOC]] to offset: [0], sizes: [[[NEW_SIZE]]], strides: [1] : memref<2xf32> to memref<?xf32>
|
|
// CHECK-NEXT: scf.yield [[CAST]]
|
|
// CHECK: return [[REALLOC]]
|
|
|
|
// NODEALLOC-LABEL: func @reallow_lowering_example
|
|
// NODEALLOC-NOT: dealloc
|