-
Notifications
You must be signed in to change notification settings - Fork 193
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
Changes from 4 commits
4a9b94a
9c37beb
132936b
c16b4de
c24986f
5f20d30
af6059a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (C) 2023-2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "whisper_utils.hpp" | ||
|
||
namespace { | ||
|
||
template <typename T> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Why not? |
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. identation is broken |
||
} // namespace genai | ||
} // namespace ov |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2023-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 |
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.
I believe just
2024