xref: /llvm-project/mlir/test/Dialect/Tosa/constant_folding.mlir (revision 729f958c4f7548c2d5be5f024b7254cd3ea25c64)
1// RUN: mlir-opt --test-constant-fold %s | FileCheck %s
2
3// CHECK-LABEL: func @test_const
4func.func @test_const(%arg0 : index) -> tensor<4xi32> {
5  // CHECK: tosa.const
6  %0 = "tosa.const"() {value = dense<[3, 0, 1, 2]> : tensor<4xi32>} : () -> tensor<4xi32>
7  return %0 : tensor<4xi32>
8}
9
10// CHECK-LABEL: func @test_const_i64
11func.func @test_const_i64(%arg0 : index) -> tensor<4xi64> {
12  // CHECK: tosa.const
13  %0 = "tosa.const"() {value = dense<[3, 0, 1, 2]> : tensor<4xi64>} : () -> tensor<4xi64>
14  return %0 : tensor<4xi64>
15}
16
17// CHECK-LABEL: func @try_fold_equal_with_unranked_tensor
18func.func @try_fold_equal_with_unranked_tensor(%arg0: tensor<4xi32>, %arg1: tensor<1xi32>) {
19  // CHECK: tosa.equal
20  // CHECK-NEXT: return
21  %0 = tosa.equal %arg0, %arg1 : (tensor<4xi32>, tensor<1xi32>) -> tensor<*xi1>
22  return
23}
24