Skip to content

Commit

Permalink
Remove duplicate enum class for angle type.
Browse files Browse the repository at this point in the history
  • Loading branch information
taiqzheng committed May 31, 2023
1 parent 2052341 commit 7c2e0c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 9 additions & 12 deletions benchmarks/ImageProcessing/BuddyRotate2DBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ float BuddyRotate2DAngle;
// Define sizes of input.
intptr_t sizesInputBuddyRotate2D[2];

// Declare Angle option supported.
enum AngleOption { ANGLE_DEGREE, ANGLE_RADIAN };

// Define Angle option selected.
AngleOption AngleType;
dip::ANGLE_TYPE AngleType;

void initializeBuddyRotate2D(char **argv) {
inputImageBuddyRotate2D = imread(argv[1], IMREAD_GRAYSCALE);
Expand All @@ -49,9 +46,9 @@ void initializeBuddyRotate2D(char **argv) {
sizesInputBuddyRotate2D[1] = inputImageBuddyRotate2D.cols;

if (static_cast<string>(argv[2]) == "DEGREE") {
AngleType = ANGLE_DEGREE;
AngleType = dip::ANGLE_TYPE::DEGREE;
} else {
AngleType = ANGLE_RADIAN;
AngleType = dip::ANGLE_TYPE::RADIAN;
}

std::string argAngle = argv[3];
Expand All @@ -62,7 +59,7 @@ void initializeBuddyRotate2D(char **argv) {
}
}

static void Buddy_Rotate2D_ANGLE_DEGREE(benchmark::State &state) {
static void Buddy_Rotate2D_DEGREE(benchmark::State &state) {
// Define the MemRef descriptor for input.
Img<float, 2> inputBuddyRotate2D(inputImageBuddyRotate2D);

Expand Down Expand Up @@ -90,8 +87,8 @@ static void Buddy_Rotate2D_ANGLE_RADIAN(benchmark::State &state) {

// Register benchmarking function.
void registerBenchmarkBuddyRotate2D() {
if (AngleType == ANGLE_DEGREE) {
BENCHMARK(Buddy_Rotate2D_ANGLE_DEGREE)
if (AngleType == dip::ANGLE_TYPE::DEGREE) {
BENCHMARK(Buddy_Rotate2D_DEGREE)
->Arg(1)
->Unit(benchmark::kMillisecond);
} else {
Expand All @@ -106,8 +103,8 @@ void generateResultBuddyRotate2D() {
// Define the MemRef descriptor for input.
Img<float, 2> input(inputImageBuddyRotate2D);
MemRef<float, 2> output(sizesInputBuddyRotate2D);
// Run the resize 2D operation.
if (AngleType == ANGLE_DEGREE) {
// Run the rotate 2D operation.
if (AngleType == dip::ANGLE_TYPE::DEGREE) {
// Call the MLIR Rotate2D function.
output = dip::Rotate2D(&input, BuddyRotate2DAngle,
dip::ANGLE_TYPE::DEGREE);
Expand All @@ -117,7 +114,7 @@ void generateResultBuddyRotate2D() {
dip::ANGLE_TYPE::RADIAN);
}

// Define a cv::Mat with the output of the resize operation.
// Define a cv::Mat with the output of the rotate operation.
Mat outputImage(output.getSizes()[0], output.getSizes()[1], CV_32FC1,
output.getData());

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/ImageProcessing/OpenCVRotate2DBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void registerBenchmarkOpenCVRotate2D() {

// Generate result image.
void generateResultOpenCVRotate2D() {
// Run the resize 2D operation.
// Run the rotate 2D operation.
if (OpenCVAngleType == ANGLE_DEGREE && OpenCVRunRotate == true) {
cv::rotate(inputImageOpenCVRotate2D, outputImageOpenCVRotate2D, OpenCVRotate2DAngle);

Expand Down

0 comments on commit 7c2e0c9

Please sign in to comment.