[Mlir-commits] [mlir] [mlir][spirv] Add integration test for `vector.deinterleave` (PR #95469)

Jakub Kuderski llvmlistbot at llvm.org
Thu Jun 13 14:19:34 PDT 2024


================
@@ -0,0 +1,81 @@
+// RUN: mlir-vulkan-runner %s \
+// RUN:  --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils \
+// RUN:  --entry-point-result=void | FileCheck %s
+
+// CHECK: [0, 2]
+// CHECK: [1, 3]
+module attributes {
+  gpu.container_module,
+  spirv.target_env = #spirv.target_env<
+    #spirv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, #spirv.resource_limits<>>
+} {
+  gpu.module @kernels {
+    gpu.func @kernel_vector_deinterleave(%arg0 : memref<4xi32>, %arg1 : memref<2xi32>, %arg2 : memref<2xi32>)
+      kernel attributes { spirv.entry_point_abi = #spirv.entry_point_abi<workgroup_size = [1, 1, 1]>} {
+      %idx0 = arith.constant 0 : index
+      %idx1 = arith.constant 1 : index
+      %idx2 = arith.constant 2 : index
+      %idx3 = arith.constant 3 : index
+      %idx4 = arith.constant 4 : index
+
+      %src = arith.constant dense<[0, 0, 0, 0]> : vector<4xi32>
+
+      %val0 = memref.load %arg0[%idx0] : memref<4xi32>
+      %val1 = memref.load %arg0[%idx1] : memref<4xi32>
+      %val2 = memref.load %arg0[%idx2] : memref<4xi32>
+      %val3 = memref.load %arg0[%idx3] : memref<4xi32>
+
+      %src0 = vector.insertelement %val0, %src[%idx0 : index] : vector<4xi32>
+      %src1 = vector.insertelement %val1, %src0[%idx1 : index] : vector<4xi32>
+      %src2 = vector.insertelement %val2, %src1[%idx2 : index] : vector<4xi32>
+      %src3 = vector.insertelement %val3, %src2[%idx3 : index] : vector<4xi32>
----------------
kuhar wrote:

use `vector.insert` and `.extract` -- these are preferred since the offsets are passed as attributes

https://github.com/llvm/llvm-project/pull/95469


More information about the Mlir-commits mailing list