1*af972f01STai Ly// RUN: mlir-opt %s | mlir-opt | FileCheck %s 2*af972f01STai Ly// RUN: mlir-opt %s --mlir-print-op-generic | mlir-opt | FileCheck %s 3*af972f01STai Ly 4*af972f01STai Ly 5*af972f01STai Ly// ----- 6*af972f01STai Ly// CHECK-LABEL: @test_variable_scalar( 7*af972f01STai Ly// CHECK-SAME: %[[ADD_VAL:.*]]: tensor<f32>) { 8*af972f01STai Lyfunc.func @test_variable_scalar(%arg0: tensor<f32>) -> () { 9*af972f01STai Ly // CHECK: tosa.variable @stored_var = dense<3.140000e+00> : tensor<f32> 10*af972f01STai Ly tosa.variable @stored_var = dense<3.14> : tensor<f32> 11*af972f01STai Ly // CHECK: %[[STORED_VAL:.*]] = tosa.variable.read @stored_var : tensor<f32> 12*af972f01STai Ly %0 = tosa.variable.read @stored_var : tensor<f32> 13*af972f01STai Ly // CHECK: %[[RESULT_ADD:.*]] = tosa.add %[[ADD_VAL]], %[[STORED_VAL]] : (tensor<f32>, tensor<f32>) -> tensor<f32> 14*af972f01STai Ly %1 = "tosa.add"(%arg0, %0) : (tensor<f32>, tensor<f32>) -> tensor<f32> 15*af972f01STai Ly // CHECK: tosa.variable.write @stored_var, %[[RESULT_ADD]] : tensor<f32> 16*af972f01STai Ly tosa.variable.write @stored_var, %1 : tensor<f32> 17*af972f01STai Ly return 18*af972f01STai Ly} 19*af972f01STai Ly 20*af972f01STai Ly// ----- 21*af972f01STai Ly// CHECK-LABEL: @test_variable_tensor( 22*af972f01STai Ly// CHECK-SAME: %[[ADD_VAL:.*]]: tensor<2x4x8xi32>) { 23*af972f01STai Lyfunc.func @test_variable_tensor(%arg0: tensor<2x4x8xi32>) -> () { 24*af972f01STai Ly // CHECK: tosa.variable @stored_var = dense<-1> : tensor<2x4x8xi32> 25*af972f01STai Ly tosa.variable @stored_var = dense<-1> : tensor<2x4x8xi32> 26*af972f01STai Ly // CHECK: %[[STORED_VAL:.*]] = tosa.variable.read @stored_var : tensor<2x4x8xi32> 27*af972f01STai Ly %0 = tosa.variable.read @stored_var : tensor<2x4x8xi32> 28*af972f01STai Ly // CHECK: %[[RESULT_ADD:.*]] = tosa.add %[[ADD_VAL]], %[[STORED_VAL]] : (tensor<2x4x8xi32>, tensor<2x4x8xi32>) -> tensor<2x4x8xi32> 29*af972f01STai Ly %1 = "tosa.add"(%arg0, %0) : (tensor<2x4x8xi32>, tensor<2x4x8xi32>) -> tensor<2x4x8xi32> 30*af972f01STai Ly // CHECK: tosa.variable.write @stored_var, %[[RESULT_ADD]] : tensor<2x4x8xi32> 31*af972f01STai Ly tosa.variable.write @stored_var, %1 : tensor<2x4x8xi32> 32*af972f01STai Ly return 33*af972f01STai Ly} 34