Skip to content

Commit 65f6023

Browse files
authored
Merge branch 'main' into sum-pooling-bench
2 parents 4ada498 + e511e25 commit 65f6023

20 files changed

Lines changed: 229 additions & 16 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior.
15+
16+
**Expected behavior**
17+
A clear and concise description of what you expected to happen.
18+
19+
**Screenshots**
20+
If applicable, add screenshots to help explain your problem.
21+
22+
**Desktop (please complete the following information):**
23+
- OS: [e.g. Ubuntu]
24+
- Version [e.g. 20.04]
25+
26+
**Additional context**
27+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context about the feature request here.

CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ endif()
1616

1717
project(buddy-benchmark LANGUAGES CXX C)
1818

19-
set(CMAKE_CXX_STANDARD 14)
19+
set(CMAKE_CXX_STANDARD 17)
2020
set(CMAKE_CXX_STANDARD_REQUIRED YES)
2121
set(CMAKE_CXX_FLAGS "-no-pie")
2222
set(CMAKE_C_FLAGS "-no-pie")
@@ -104,15 +104,19 @@ endif()
104104
# Find OpenCV
105105
#-------------------------------------------------------------------------------
106106

107-
find_package(OpenCV REQUIRED CONFIG)
108-
include_directories(${OpenCV_INCLUDE_DIRS})
107+
if(DEFINED IMAGE_PROCESSING_BENCHMARKS OR DEEP_LEARNING_BENCHMARKS)
108+
find_package(OpenCV REQUIRED CONFIG)
109+
include_directories(${OpenCV_INCLUDE_DIRS})
110+
endif()
109111

110112
#-------------------------------------------------------------------------------
111113
# Find PNG
112114
#-------------------------------------------------------------------------------
113115

114-
find_package(PNG REQUIRED)
115-
include_directories(${PNG_INCLUDE_DIR})
116+
if(DEFINED IMAGE_PROCESSING_BENCHMARKS OR DEEP_LEARNING_BENCHMARKS)
117+
find_package(PNG REQUIRED)
118+
include_directories(${PNG_INCLUDE_DIR})
119+
endif()
116120

117121
#-------------------------------------------------------------------------------
118122
# Hardware detection

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,24 @@ Run the DepthwiseConv2DNhwcHwc operation benchmark:
9494
$ cd <path to build>/bin && ./depthwise-conv-2d-nhwc-hwc-benchmark
9595
```
9696

97+
## Audio Processing Benchmark
98+
99+
Currently, the audio processing benchmark includes the following frameworks or optimizers:
100+
101+
- KFR ([link](https://github.com/kfrlib/kfr))
102+
103+
*Note: Please replace the `/PATH/TO/*` with your local path.*
104+
105+
```
106+
$ cd buddy-benchmark
107+
$ mkdir build && cd build
108+
$ cmake -G Ninja .. \
109+
-DAUDIO_PROCESSING_BENCHMARKS=ON \
110+
-DCMAKE_CXX_COMPILER=clang++ \
111+
-DKFR_DIR=/PATH/TO/KFR/SOURCE/CODE \
112+
$ ninja audio-processing-benchmark
113+
```
114+
97115
## Testing
98116

99117
```
5.72 MB
Binary file not shown.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#-------------------------------------------------------------------------------
2+
# Audio Processing Benchmark Target
3+
#-------------------------------------------------------------------------------
4+
5+
add_subdirectory(${KFR_DIR} ./kfr)
6+
7+
include_directories(${KFR_DIR}/include)
8+
9+
add_executable(audio-processing-benchmark
10+
KFRFir.cpp
11+
Main.cpp
12+
)
13+
14+
target_link_directories(audio-processing-benchmark PRIVATE ${KFR_DIR}/build/)
15+
target_link_libraries(audio-processing-benchmark
16+
PRIVATE
17+
kfr_io
18+
kfr_dft
19+
GoogleBenchmark
20+
)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//===- KFRFir.cpp ---------------------------------------------------------===//
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
//
17+
// This file implements the benchmark for KFR Fir function.
18+
//
19+
//===----------------------------------------------------------------------===//
20+
21+
#include <benchmark/benchmark.h>
22+
#include <kfr/base.hpp>
23+
#include <kfr/dft.hpp>
24+
#include <kfr/dsp.hpp>
25+
#include <kfr/io.hpp>
26+
27+
using namespace kfr;
28+
29+
univector<fbase, 1023> taps127;
30+
univector<float, 2000000> aud;
31+
univector<float> result;
32+
33+
// Initialize univector.
34+
void initializeKFRFir() {
35+
expression_pointer<fbase> kaiser =
36+
to_pointer(window_kaiser(taps127.size(), 3.0));
37+
fir_lowpass(taps127, 0.2, kaiser, true);
38+
audio_reader_wav<float> reader(open_file_for_reading(
39+
"../../benchmarks/AudioProcessing/Audios/NASA_Mars.wav"));
40+
reader.read(aud.data(), aud.size());
41+
}
42+
43+
// Benchmarking function.
44+
static void KFR_FIR(benchmark::State &state) {
45+
for (auto _ : state) {
46+
for (int i = 0; i < state.range(0); ++i) {
47+
result = kfr::fir(aud, taps127);
48+
}
49+
}
50+
}
51+
52+
// Register benchmarking function.
53+
BENCHMARK(KFR_FIR)->Arg(1);
54+
55+
// Generate result wav file.
56+
void generateResultKFRFir() {
57+
univector<float> generateResult = kfr::fir(aud, taps127);
58+
59+
audio_writer_wav<float> writer(open_file_for_writing("./ResultKFRFir.wav"),
60+
audio_format{1 /* channel */,
61+
audio_sample_type::i24,
62+
100000 /* sample rate */});
63+
writer.write(generateResult.data(), generateResult.size());
64+
println("Sample Rate = ", writer.format().samplerate);
65+
println("Channels = ", writer.format().channels);
66+
println("Length = ", writer.format().length);
67+
println("Duration (s) = ",
68+
writer.format().length / writer.format().samplerate);
69+
println("Bit depth = ", audio_sample_bit_depth(writer.format().type));
70+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===- Main.cpp -----------------------------------------------------------===//
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
//
17+
// This is the main file of the audio processing benchmark.
18+
//
19+
//===----------------------------------------------------------------------===//
20+
21+
#include <benchmark/benchmark.h>
22+
23+
void initializeKFRFir();
24+
25+
void generateResultKFRFir();
26+
27+
int main(int argc, char **argv) {
28+
initializeKFRFir();
29+
::benchmark::Initialize(&argc, argv);
30+
::benchmark::RunSpecifiedBenchmarks();
31+
generateResultKFRFir();
32+
return 0;
33+
}

benchmarks/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ endif()
55
if(DEEP_LEARNING_BENCHMARKS)
66
add_subdirectory(DeepLearning)
77
endif()
8+
9+
if(AUDIO_PROCESSING_BENCHMARKS)
10+
add_subdirectory(AudioProcessing)
11+
endif()

benchmarks/DeepLearning/Models/Inception-V3/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ add_buddy_model_benchmark(inception-v3-benchmark
1818
-memref-expand -arith-expand
1919
--convert-memref-to-llvm
2020
--convert-math-to-llvm
21-
--convert-std-to-llvm='emit-c-wrappers=1'
21+
--convert-func-to-llvm='emit-c-wrappers=1'
2222
--reconcile-unrealized-casts
2323
SOURCE Main.cpp InceptionBenchmark.cpp
2424
)

0 commit comments

Comments
 (0)