Skip to content

Commit

Permalink
test: self subtract testing
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Jan 2, 2025
1 parent 3cac288 commit e624c7b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/lit_tests/selfsubtract.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// RUN: enzymexlamlir-opt --pass-pipeline="builtin.module(enzyme-hlo-opt{no_nan=true})" %s | FileCheck %s --check-prefix=NONAN
// RUN: enzymexlamlir-opt --pass-pipeline="builtin.module(enzyme-hlo-opt{no_nan=false})" %s | FileCheck %s --check-prefix=NAN

module {
func.func @main(%arg0: tensor<3x4xf64>) -> tensor<3x4xf64> {
%0 = stablehlo.transpose %arg0, dims = [1, 0] : (tensor<3x4xf64>) -> tensor<4x3xf64>
%1 = stablehlo.subtract %0, %0 : tensor<4x3xf64>
%2 = stablehlo.transpose %1, dims = [1, 0] : (tensor<4x3xf64>) -> tensor<3x4xf64>
return %2 : tensor<3x4xf64>
}
}

// NONAN: func.func @main(%arg0: tensor<3x4xf64>) -> tensor<3x4xf64> {
// NONAN-NEXT: %cst = stablehlo.constant dense<0.000000e+00> : tensor<3x4xf64>
// NONAN-NEXT: return %cst : tensor<3x4xf64>
// NONAN-NEXT: }

// NAN: func.func @main(%arg0: tensor<3x4xf64>) -> tensor<3x4xf64> {
// NAN-NEXT: %0 = stablehlo.transpose %arg0, dims = [1, 0] : (tensor<3x4xf64>) -> tensor<4x3xf64>
// NAN-NEXT: %1 = stablehlo.subtract %0, %0 : tensor<4x3xf64>
// NAN-NEXT: %2 = stablehlo.transpose %1, dims = [1, 0] : (tensor<4x3xf64>) -> tensor<3x4xf64>
// NAN-NEXT: return %2 : tensor<3x4xf64>
// NAN-NEXT: }

0 comments on commit e624c7b

Please sign in to comment.