22
22
#include < benchmark/benchmark.h>
23
23
#include < buddy/core/Container.h>
24
24
#include < buddy/core/ImageContainer.h>
25
+ #include < buddy/dip/dip.h>
25
26
#include < opencv2/opencv.hpp>
26
27
27
28
using namespace cv ;
28
29
using namespace std ;
29
30
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
-
47
31
// Declare input image.
48
32
Mat inputImageBuddyCorr2D;
49
33
@@ -100,9 +84,11 @@ static void Buddy_Corr2D_Constant_Padding(benchmark::State &state) {
100
84
101
85
for (auto _ : state) {
102
86
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*/ );
106
92
}
107
93
}
108
94
}
@@ -116,9 +102,11 @@ static void Buddy_Corr2D_Replicate_Padding(benchmark::State &state) {
116
102
117
103
for (auto _ : state) {
118
104
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*/ );
122
110
}
123
111
}
124
112
}
@@ -144,13 +132,15 @@ void generateResultBuddyCorr2D(char **argv) {
144
132
MemRef<float , 2 > output (sizesOutputBuddyCorr2D);
145
133
// Run the 2D correlation.
146
134
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*/ );
150
139
} 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*/ );
154
144
}
155
145
156
146
// Define a cv::Mat with the output of the correlation.
0 commit comments