Files
TheRock/compiler/amd-llvm/mlir/test/mlir-runner/global-memref.mlir
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

109 lines
3.4 KiB
MLIR

// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-arith-to-llvm),finalize-memref-to-llvm,convert-func-to-llvm,reconcile-unrealized-casts)" | mlir-runner -e main -entry-point-result=void -shared-libs=%mlir_runner_utils,%mlir_c_runner_utils | FileCheck %s
// XFAIL: system-aix
func.func private @printMemrefF32(memref<*xf32>) attributes { llvm.emit_c_interface }
func.func private @printMemrefI32(memref<*xi32>) attributes { llvm.emit_c_interface }
func.func private @printNewline() -> ()
memref.global "private" @gv0 : memref<4xf32> = dense<[0.0, 1.0, 2.0, 3.0]>
func.func @test1DMemref() {
%0 = memref.get_global @gv0 : memref<4xf32>
%U = memref.cast %0 : memref<4xf32> to memref<*xf32>
// CHECK: rank = 1
// CHECK: offset = 0
// CHECK: sizes = [4]
// CHECK: strides = [1]
// CHECK: [0, 1, 2, 3]
call @printMemrefF32(%U) : (memref<*xf32>) -> ()
call @printNewline() : () -> ()
// Overwrite some of the elements.
%c0 = arith.constant 0 : index
%c2 = arith.constant 2 : index
%fp0 = arith.constant 4.0 : f32
%fp1 = arith.constant 5.0 : f32
memref.store %fp0, %0[%c0] : memref<4xf32>
memref.store %fp1, %0[%c2] : memref<4xf32>
// CHECK: rank = 1
// CHECK: offset = 0
// CHECK: sizes = [4]
// CHECK: strides = [1]
// CHECK: [4, 1, 5, 3]
call @printMemrefF32(%U) : (memref<*xf32>) -> ()
call @printNewline() : () -> ()
return
}
memref.global constant @gv1 : memref<3x2xi32> = dense<[[0, 1],[2, 3],[4, 5]]>
func.func @testConstantMemref() {
%0 = memref.get_global @gv1 : memref<3x2xi32>
%U = memref.cast %0 : memref<3x2xi32> to memref<*xi32>
// CHECK: rank = 2
// CHECK: offset = 0
// CHECK: sizes = [3, 2]
// CHECK: strides = [2, 1]
// CHECK: [0, 1]
// CHECK: [2, 3]
// CHECK: [4, 5]
call @printMemrefI32(%U) : (memref<*xi32>) -> ()
call @printNewline() : () -> ()
return
}
memref.global "private" @gv2 : memref<4x2xf32> = dense<[[0.0, 1.0], [2.0, 3.0], [4.0, 5.0], [6.0, 7.0]]>
func.func @test2DMemref() {
%0 = memref.get_global @gv2 : memref<4x2xf32>
%U = memref.cast %0 : memref<4x2xf32> to memref<*xf32>
// CHECK: rank = 2
// CHECK: offset = 0
// CHECK: sizes = [4, 2]
// CHECK: strides = [2, 1]
// CHECK: [0, 1]
// CHECK: [2, 3]
// CHECK: [4, 5]
// CHECK: [6, 7]
call @printMemrefF32(%U) : (memref<*xf32>) -> ()
call @printNewline() : () -> ()
// Overwrite the 1.0 (at index [0, 1]) with 10.0
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
%fp10 = arith.constant 10.0 : f32
memref.store %fp10, %0[%c0, %c1] : memref<4x2xf32>
// CHECK: rank = 2
// CHECK: offset = 0
// CHECK: sizes = [4, 2]
// CHECK: strides = [2, 1]
// CHECK: [0, 10]
// CHECK: [2, 3]
// CHECK: [4, 5]
// CHECK: [6, 7]
call @printMemrefF32(%U) : (memref<*xf32>) -> ()
call @printNewline() : () -> ()
return
}
memref.global @gv3 : memref<i32> = dense<11>
func.func @testScalarMemref() {
%0 = memref.get_global @gv3 : memref<i32>
%U = memref.cast %0 : memref<i32> to memref<*xi32>
// CHECK: rank = 0
// CHECK: offset = 0
// CHECK: sizes = []
// CHECK: strides = []
// CHECK: [11]
call @printMemrefI32(%U) : (memref<*xi32>) -> ()
call @printNewline() : () -> ()
return
}
func.func @main() -> () {
call @test1DMemref() : () -> ()
call @testConstantMemref() : () -> ()
call @test2DMemref() : () -> ()
call @testScalarMemref() : () -> ()
return
}