Skip to content

Commit 57a74d2

Browse files
committed
[benchmarks/ImageProcessing] Use dip.mlir directly instead of stand-alone compilation
1 parent 895a817 commit 57a74d2

7 files changed

+67
-378
lines changed

benchmarks/ImageProcessing/BuddyConv2D.mlir

-25
This file was deleted.

benchmarks/ImageProcessing/BuddyConv2DBenchmark.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ using namespace std;
2929

3030
// Declare the conv2d C interface.
3131
extern "C" {
32-
void _mlir_ciface_buddy_conv_2d(Img<float, 2> *inputBuddyConv2D,
33-
MemRef<float, 2> *kernelBuddyConv2D,
34-
MemRef<float, 2> *outputBuddyConv2D);
32+
void _mlir_ciface_conv_2d(Img<float, 2> *inputBuddyConv2D,
33+
MemRef<float, 2> *kernelBuddyConv2D,
34+
MemRef<float, 2> *outputBuddyConv2D);
3535
}
3636

3737
// Read input image.
@@ -80,8 +80,8 @@ static void Buddy_Conv2D(benchmark::State &state) {
8080

8181
for (auto _ : state) {
8282
for (int i = 0; i < state.range(0); ++i) {
83-
_mlir_ciface_buddy_conv_2d(&inputBuddyConv2D, &kernelBuddyConv2D,
84-
&outputBuddyConv2D);
83+
_mlir_ciface_conv_2d(&inputBuddyConv2D, &kernelBuddyConv2D,
84+
&outputBuddyConv2D);
8585
}
8686
}
8787
}
@@ -96,7 +96,7 @@ void generateResultBuddyConv2D(char **argv) {
9696
MemRef<float, 2> kernel(kernelDataBuddyConv2D, sizesKernelBuddyConv2D);
9797
MemRef<float, 2> output(sizesOutputBuddyConv2D);
9898
// Run the 2D convolution.
99-
_mlir_ciface_buddy_conv_2d(&input, &kernel, &output);
99+
_mlir_ciface_conv_2d(&input, &kernel, &output);
100100

101101
// Define a cv::Mat with the output of the convolution.
102102
Mat outputImage(outputRowsBuddyConv2D, outputColsBuddyConv2D, CV_32FC1,

benchmarks/ImageProcessing/BuddyCorr2D.mlir

-39
This file was deleted.

benchmarks/ImageProcessing/BuddyCorr2DBenchmark.cpp

+19-29
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,12 @@
2222
#include <benchmark/benchmark.h>
2323
#include <buddy/core/Container.h>
2424
#include <buddy/core/ImageContainer.h>
25+
#include <buddy/dip/dip.h>
2526
#include <opencv2/opencv.hpp>
2627

2728
using namespace cv;
2829
using namespace std;
2930

30-
// Declare the conv2d C interface.
31-
extern "C" {
32-
void _mlir_ciface_corr_2d_constant_padding(Img<float, 2> *inputBuddyCorr2D,
33-
MemRef<float, 2> *kernelBuddyCorr2D,
34-
MemRef<float, 2> *outputBuddyCorr2D,
35-
unsigned int centerX,
36-
unsigned int centerY,
37-
float constantValue);
38-
39-
void _mlir_ciface_corr_2d_replicate_padding(Img<float, 2> *inputBuddyCorr2D,
40-
MemRef<float, 2> *kernelBuddyCorr2D,
41-
MemRef<float, 2> *outputBuddyCorr2D,
42-
unsigned int centerX,
43-
unsigned int centerY,
44-
float constantValue);
45-
}
46-
4731
// Declare input image.
4832
Mat inputImageBuddyCorr2D;
4933

@@ -100,9 +84,11 @@ static void Buddy_Corr2D_Constant_Padding(benchmark::State &state) {
10084

10185
for (auto _ : state) {
10286
for (int i = 0; i < state.range(0); ++i) {
103-
_mlir_ciface_corr_2d_constant_padding(
104-
&inputBuddyCorr2D, &kernelBuddyCorr2D, &outputBuddyCorr2D,
105-
1 /* Center X */, 1 /* Center Y */, 0.0f /* Constant Value */);
87+
// Call the MLIR Corr2D function.
88+
dip::Corr2D(&inputBuddyCorr2D, &kernelBuddyCorr2D, &outputBuddyCorr2D,
89+
1 /* Center X */, 1 /* Center Y */,
90+
dip::BOUNDARY_OPTION::CONSTANT_PADDING,
91+
0.0f /* Constant Value*/);
10692
}
10793
}
10894
}
@@ -116,9 +102,11 @@ static void Buddy_Corr2D_Replicate_Padding(benchmark::State &state) {
116102

117103
for (auto _ : state) {
118104
for (int i = 0; i < state.range(0); ++i) {
119-
_mlir_ciface_corr_2d_replicate_padding(
120-
&inputBuddyCorr2D, &kernelBuddyCorr2D, &outputBuddyCorr2D,
121-
1 /* Center X */, 1 /* Center Y */, 0.0f /* Constant Value */);
105+
// Call the MLIR Corr2D function.
106+
dip::Corr2D(&inputBuddyCorr2D, &kernelBuddyCorr2D, &outputBuddyCorr2D,
107+
1 /* Center X */, 1 /* Center Y */,
108+
dip::BOUNDARY_OPTION::REPLICATE_PADDING,
109+
0.0f /* Constant Value*/);
122110
}
123111
}
124112
}
@@ -144,13 +132,15 @@ void generateResultBuddyCorr2D(char **argv) {
144132
MemRef<float, 2> output(sizesOutputBuddyCorr2D);
145133
// Run the 2D correlation.
146134
if (static_cast<string>(argv[3]) == "REPLICATE_PADDING") {
147-
_mlir_ciface_corr_2d_replicate_padding(&input, &kernel, &output,
148-
1 /* Center X */, 1 /* Center Y */,
149-
0.0f /* Constant Value */);
135+
// Call the MLIR Corr2D function.
136+
dip::Corr2D(&input, &kernel, &output, 1 /* Center X */, 1 /* Center Y */,
137+
dip::BOUNDARY_OPTION::REPLICATE_PADDING,
138+
0.0f /* Constant Value*/);
150139
} else {
151-
_mlir_ciface_corr_2d_constant_padding(&input, &kernel, &output,
152-
1 /* Center X */, 1 /* Center Y */,
153-
0.0f /* Constant Value */);
140+
// Call the MLIR Corr2D function.
141+
dip::Corr2D(&input, &kernel, &output, 1 /* Center X */, 1 /* Center Y */,
142+
dip::BOUNDARY_OPTION::CONSTANT_PADDING,
143+
0.0f /* Constant Value*/);
154144
}
155145

156146
// Define a cv::Mat with the output of the correlation.

benchmarks/ImageProcessing/BuddyMorph2D.mlir

-103
This file was deleted.

0 commit comments

Comments
 (0)