Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the DTW benchmark. #98

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions cpp/zimt/dtw_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,42 @@ TEST(DTW, ChainDTWTest) {
}

void BM_DTW(benchmark::State& state) {
const hwy::AlignedNDArray<float, 2> spec_a(
hwy::AlignedNDArray<float, 2> spec_a(
{static_cast<size_t>(state.range(0)), 1024});
const hwy::AlignedNDArray<float, 2> spec_b(
hwy::AlignedNDArray<float, 2> spec_b(
{static_cast<size_t>(state.range(0)), 1024});
for (size_t step_index = 0; step_index < spec_a.shape()[0]; ++step_index) {
for (size_t channel_index = 0; channel_index < spec_a.shape()[1];
++channel_index) {
spec_a[{step_index}][channel_index] = 1.0;
}
}

for (auto s : state) {
DTW(spec_a, spec_b);
}
state.SetItemsProcessed(state.range(0) * state.iterations());
}
BENCHMARK_RANGE(BM_DTW, 1000, 10000);
BENCHMARK_RANGE(BM_DTW, 100, 1000);

void BM_ChainDTW(benchmark::State& state) {
const hwy::AlignedNDArray<float, 2> spec_a(
hwy::AlignedNDArray<float, 2> spec_a(
{static_cast<size_t>(state.range(0)), 1024});
const hwy::AlignedNDArray<float, 2> spec_b(
hwy::AlignedNDArray<float, 2> spec_b(
{static_cast<size_t>(state.range(0)), 1024});
for (size_t step_index = 0; step_index < spec_a.shape()[0]; ++step_index) {
for (size_t channel_index = 0; channel_index < spec_a.shape()[1];
++channel_index) {
spec_a[{step_index}][channel_index] = 1.0;
}
}

for (auto s : state) {
ChainDTW(spec_a, spec_b, 2000);
ChainDTW(spec_a, spec_b, 200);
}
state.SetItemsProcessed(state.range(0) * state.iterations());
}
BENCHMARK_RANGE(BM_ChainDTW, 1000, 50000);
BENCHMARK_RANGE(BM_ChainDTW, 100, 5000);

} // namespace

Expand Down
Loading