-
Notifications
You must be signed in to change notification settings - Fork 191
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
Add perf metrics support for WhisperStaticPipeline #1337
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4a9b94a
Add perf metrics support for WhisperStaticPipeline
eshiryae 9c37beb
Added whisper metric and non segment tokens filtering
eshiryae 132936b
Move common functions to utils
eshiryae c16b4de
Move filter_by_ranges to unnamed namespace
eshiryae c24986f
Minor changes
eshiryae 5f20d30
Merge branch 'master' into b_perf_metrics
eshiryae af6059a
Merge branch 'master' into b_perf_metrics
eshiryae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "whisper_utils.hpp" | ||
|
||
namespace { | ||
|
||
template <typename T> | ||
void filter_by_ranges(std::vector<T>& value, size_t offset, std::vector<std::pair<size_t, size_t>>& ranges) { | ||
OPENVINO_ASSERT(ranges.empty() || value.size() >= (offset + ranges.back().second)); | ||
std::vector<T> result{value.begin(), value.begin() + offset}; | ||
for (auto [start, end] : ranges) { | ||
result.insert(result.end(), value.begin() + offset + start, value.begin() + offset + end); | ||
} | ||
|
||
value = result; | ||
} | ||
|
||
} // namespace | ||
|
||
namespace ov { | ||
namespace genai { | ||
namespace utils { | ||
|
||
void infer_with_perf_metrics(ov::InferRequest& request, ov::genai::RawPerfMetrics& raw_metrics) { | ||
const auto infer_start = std::chrono::steady_clock::now(); | ||
request.infer(); | ||
const auto infer_end = std::chrono::steady_clock::now(); | ||
const auto infer_ms = ov::genai::PerfMetrics::get_microsec(infer_end - infer_start); | ||
raw_metrics.m_inference_durations[0] += MicroSeconds(infer_ms); | ||
raw_metrics.m_token_infer_durations.emplace_back(infer_ms); | ||
raw_metrics.m_new_token_times.emplace_back(infer_end); | ||
raw_metrics.m_batch_sizes.emplace_back(1); | ||
} | ||
|
||
void filter_non_segment_metrics(ov::genai::RawPerfMetrics& raw_metrics, | ||
size_t offset, | ||
std::vector<std::pair<size_t, size_t>>& ranges) { | ||
filter_by_ranges(raw_metrics.m_token_infer_durations, offset, ranges); | ||
filter_by_ranges(raw_metrics.m_new_token_times, offset, ranges); | ||
filter_by_ranges(raw_metrics.m_batch_sizes, offset, ranges); | ||
} | ||
|
||
} // namespace utils | ||
} // namespace genai | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include <openvino/openvino.hpp> | ||
|
||
#include "openvino/genai/perf_metrics.hpp" | ||
|
||
namespace ov { | ||
namespace genai { | ||
namespace utils { | ||
|
||
void infer_with_perf_metrics(ov::InferRequest& request, ov::genai::RawPerfMetrics& raw_metrics); | ||
|
||
void filter_non_segment_metrics(ov::genai::RawPerfMetrics& raw_metrics, | ||
size_t offset, | ||
std::vector<std::pair<size_t, size_t>>& ranges); | ||
|
||
} // namespace utils | ||
} // namespace genai | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, in doesn't have sense to put templated function into anonym namespace, does it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not?
Example from static pipeline: https://github.com/openvinotoolkit/openvino.genai/blob/master/src/cpp/src/whisper_pipeline_static.cpp#L32