Skip to content

Commit

Permalink
[tests] Add rountrip tests for DAP and DIP operations. (#157)
Browse files Browse the repository at this point in the history
- [DAP] iir & fir
- [DIP] corr2d & resize2d & rotate2d
  • Loading branch information
taiqzheng authored Jun 8, 2023
1 parent 91be3c2 commit 82a8455
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/Dialect/DAP/filters_roundtrip.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: buddy-opt -verify-diagnostics %s | buddy-opt | FileCheck %s

func.func @buddy_iir(%in : memref<?xf32>, %filter : memref<?x?xf32>, %out : memref<?xf32>) -> () {
// CHECK: dap.iir {{.*}} : memref<?xf32>, memref<?x?xf32>, memref<?xf32>
dap.iir %in, %filter, %out : memref<?xf32>, memref<?x?xf32>, memref<?xf32>
return
}

func.func @buddy_fir(%in : memref<?xf32>, %filter : memref<?xf32>, %out : memref<?xf32>) -> () {
// CHECK: dap.fir {{.*}} : memref<?xf32>, memref<?xf32>, memref<?xf32>
dap.fir %in, %filter, %out : memref<?xf32>, memref<?xf32>, memref<?xf32>
return
}
31 changes: 31 additions & 0 deletions tests/Dialect/DIP/image_processing_roundtrip.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// RUN: buddy-opt -verify-diagnostics %s | buddy-opt | FileCheck %s

func.func @buddy_corr2d_CONSTANT_PADDING(%input : memref<?x?xf32>, %identity : memref<?x?xf32>, %output : memref<?x?xf32>, %kernelAnchorX : index, %kernelAnchorY : index, %c : f32) -> () {
// CHECK: dip.corr_2d <CONSTANT_PADDING>{{.*}} : memref<?x?xf32>, memref<?x?xf32>, memref<?x?xf32>, index, index, f32
dip.corr_2d <CONSTANT_PADDING> %input, %identity, %output, %kernelAnchorX, %kernelAnchorY, %c : memref<?x?xf32>, memref<?x?xf32>, memref<?x?xf32>, index, index, f32
return
}

func.func @buddy_corr2d_REPLICATE_PADDING(%input : memref<?x?xf32>, %identity : memref<?x?xf32>, %output : memref<?x?xf32>, %kernelAnchorX : index, %kernelAnchorY : index, %c : f32) -> () {
// CHECK: dip.corr_2d <REPLICATE_PADDING>{{.*}} : memref<?x?xf32>, memref<?x?xf32>, memref<?x?xf32>, index, index, f32
dip.corr_2d <REPLICATE_PADDING> %input, %identity, %output, %kernelAnchorX, %kernelAnchorY, %c : memref<?x?xf32>, memref<?x?xf32>, memref<?x?xf32>, index, index, f32
return
}

func.func @buddy_resize2d_NEAREST_NEIGHBOUR_INTERPOLATION(%input : memref<?x?xf32>, %horizontal_scaling_factor : f32, %vertical_scaling_factor : f32, %output : memref<?x?xf32>) -> () {
// CHECK: dip.resize_2d NEAREST_NEIGHBOUR_INTERPOLATION{{.*}} : memref<?x?xf32>, f32, f32, memref<?x?xf32>
dip.resize_2d NEAREST_NEIGHBOUR_INTERPOLATION %input, %horizontal_scaling_factor, %vertical_scaling_factor, %output : memref<?x?xf32>, f32, f32, memref<?x?xf32>
return
}

func.func @buddy_resize2d_BILINEAR_INTERPOLATION(%input : memref<?x?xf32>, %horizontal_scaling_factor : f32, %vertical_scaling_factor : f32, %output : memref<?x?xf32>) -> () {
// CHECK: dip.resize_2d BILINEAR_INTERPOLATION{{.*}} : memref<?x?xf32>, f32, f32, memref<?x?xf32>
dip.resize_2d BILINEAR_INTERPOLATION %input, %horizontal_scaling_factor, %vertical_scaling_factor, %output : memref<?x?xf32>, f32, f32, memref<?x?xf32>
return
}

func.func @buddy_rotate2d(%input : memref<?x?xf32>, %angle : f32, %output : memref<?x?xf32>) -> () {
// CHECK: dip.rotate_2d {{.*}} : memref<?x?xf32>, f32, memref<?x?xf32>
dip.rotate_2d %input, %angle, %output : memref<?x?xf32>, f32, memref<?x?xf32>
return
}

0 comments on commit 82a8455

Please sign in to comment.