brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · af52bef Raw
89 lines · plain
1// RUN: mlir-opt %s -split-input-file -test-acc-support | FileCheck %s2 3// Test with direct variable names4func.func @test_direct_var_name() {5  // Create a memref with acc.var_name attribute6  %0 = memref.alloca() {acc.var_name = #acc.var_name<"my_variable">} : memref<10xi32>7 8  %1 = memref.cast %0 {test.var_name} : memref<10xi32> to memref<10xi32>9 10  // CHECK: op=%{{.*}} = memref.cast %{{.*}} {test.var_name} : memref<10xi32> to memref<10xi32>11  // CHECK-NEXT: getVariableName="my_variable"12 13  return14}15 16// -----17 18// Test through memref.cast19func.func @test_through_cast() {20  // Create a 5x2 memref with acc.var_name attribute21  %0 = memref.alloca() {acc.var_name = #acc.var_name<"casted_variable">} : memref<5x2xi32>22 23  // Cast to dynamic dimensions24  %1 = memref.cast %0 : memref<5x2xi32> to memref<?x?xi32>25 26  // Mark with test attribute - should find name through cast27  %2 = memref.cast %1 {test.var_name} : memref<?x?xi32> to memref<5x2xi32>28 29  // CHECK: op=%{{.*}} = memref.cast %{{.*}} {test.var_name} : memref<?x?xi32> to memref<5x2xi32>30  // CHECK-NEXT: getVariableName="casted_variable"31 32  return33}34 35// -----36 37// Test with no variable name38func.func @test_no_var_name() {39  // Create a memref without acc.var_name attribute40  %0 = memref.alloca() : memref<10xi32>41 42  // Mark with test attribute - should find empty string43  %1 = memref.cast %0 {test.var_name} : memref<10xi32> to memref<10xi32>44 45  // CHECK: op=%{{.*}} = memref.cast %{{.*}} {test.var_name} : memref<10xi32> to memref<10xi32>46  // CHECK-NEXT: getVariableName=""47 48  return49}50 51// -----52 53// Test through multiple casts54func.func @test_multiple_casts() {55  // Create a memref with acc.var_name attribute56  %0 = memref.alloca() {acc.var_name = #acc.var_name<"multi_cast">} : memref<10xi32>57 58  // Multiple casts59  %1 = memref.cast %0 : memref<10xi32> to memref<?xi32>60  %2 = memref.cast %1 : memref<?xi32> to memref<10xi32>61 62  // Mark with test attribute - should find name through multiple casts63  %3 = memref.cast %2 {test.var_name} : memref<10xi32> to memref<10xi32>64 65  // CHECK: op=%{{.*}} = memref.cast %{{.*}} {test.var_name} : memref<10xi32> to memref<10xi32>66  // CHECK-NEXT: getVariableName="multi_cast"67 68  return69}70 71// -----72 73// Test with acc.copyin operation74func.func @test_copyin_name() {75  // Create a memref76  %0 = memref.alloca() : memref<10xf32>77 78  // Create an acc.copyin operation with a name79  %1 = acc.copyin varPtr(%0 : memref<10xf32>) -> memref<10xf32> {name = "input_data"}80 81  // Mark with test attribute - should find name from copyin operation82  %2 = memref.cast %1 {test.var_name} : memref<10xf32> to memref<?xf32>83 84  // CHECK: op=%{{.*}} = memref.cast %{{.*}} {test.var_name} : memref<10xf32> to memref<?xf32>85  // CHECK-NEXT: getVariableName="input_data"86 87  return88}89