From 82a84557186f1a3ecb85dfc1c5f5b5d426070a12 Mon Sep 17 00:00:00 2001 From: Taiqi Zheng <56971484+taiqzheng@users.noreply.github.com> Date: Thu, 8 Jun 2023 08:48:20 +0800 Subject: [PATCH] [tests] Add rountrip tests for DAP and DIP operations. (#157) - [DAP] iir & fir - [DIP] corr2d & resize2d & rotate2d --- tests/Dialect/DAP/filters_roundtrip.mlir | 13 ++++++++ .../DIP/image_processing_roundtrip.mlir | 31 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/Dialect/DAP/filters_roundtrip.mlir create mode 100644 tests/Dialect/DIP/image_processing_roundtrip.mlir diff --git a/tests/Dialect/DAP/filters_roundtrip.mlir b/tests/Dialect/DAP/filters_roundtrip.mlir new file mode 100644 index 000000000..6f4698647 --- /dev/null +++ b/tests/Dialect/DAP/filters_roundtrip.mlir @@ -0,0 +1,13 @@ +// RUN: buddy-opt -verify-diagnostics %s | buddy-opt | FileCheck %s + +func.func @buddy_iir(%in : memref, %filter : memref, %out : memref) -> () { + // CHECK: dap.iir {{.*}} : memref, memref, memref + dap.iir %in, %filter, %out : memref, memref, memref + return +} + +func.func @buddy_fir(%in : memref, %filter : memref, %out : memref) -> () { + // CHECK: dap.fir {{.*}} : memref, memref, memref + dap.fir %in, %filter, %out : memref, memref, memref + return +} diff --git a/tests/Dialect/DIP/image_processing_roundtrip.mlir b/tests/Dialect/DIP/image_processing_roundtrip.mlir new file mode 100644 index 000000000..768962087 --- /dev/null +++ b/tests/Dialect/DIP/image_processing_roundtrip.mlir @@ -0,0 +1,31 @@ +// RUN: buddy-opt -verify-diagnostics %s | buddy-opt | FileCheck %s + +func.func @buddy_corr2d_CONSTANT_PADDING(%input : memref, %identity : memref, %output : memref, %kernelAnchorX : index, %kernelAnchorY : index, %c : f32) -> () { + // CHECK: dip.corr_2d {{.*}} : memref, memref, memref, index, index, f32 + dip.corr_2d %input, %identity, %output, %kernelAnchorX, %kernelAnchorY, %c : memref, memref, memref, index, index, f32 + return +} + +func.func @buddy_corr2d_REPLICATE_PADDING(%input : memref, %identity : memref, %output : memref, %kernelAnchorX : index, %kernelAnchorY : index, %c : f32) -> () { + // CHECK: dip.corr_2d {{.*}} : memref, memref, memref, index, index, f32 + dip.corr_2d %input, %identity, %output, %kernelAnchorX, %kernelAnchorY, %c : memref, memref, memref, index, index, f32 + return +} + +func.func @buddy_resize2d_NEAREST_NEIGHBOUR_INTERPOLATION(%input : memref, %horizontal_scaling_factor : f32, %vertical_scaling_factor : f32, %output : memref) -> () { + // CHECK: dip.resize_2d NEAREST_NEIGHBOUR_INTERPOLATION{{.*}} : memref, f32, f32, memref + dip.resize_2d NEAREST_NEIGHBOUR_INTERPOLATION %input, %horizontal_scaling_factor, %vertical_scaling_factor, %output : memref, f32, f32, memref + return +} + +func.func @buddy_resize2d_BILINEAR_INTERPOLATION(%input : memref, %horizontal_scaling_factor : f32, %vertical_scaling_factor : f32, %output : memref) -> () { + // CHECK: dip.resize_2d BILINEAR_INTERPOLATION{{.*}} : memref, f32, f32, memref + dip.resize_2d BILINEAR_INTERPOLATION %input, %horizontal_scaling_factor, %vertical_scaling_factor, %output : memref, f32, f32, memref + return +} + +func.func @buddy_rotate2d(%input : memref, %angle : f32, %output : memref) -> () { + // CHECK: dip.rotate_2d {{.*}} : memref, f32, memref + dip.rotate_2d %input, %angle, %output : memref, f32, memref + return +}