Skip to content

Commit

Permalink
Move filter_by_ranges to unnamed namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
eshiryae committed Dec 16, 2024
1 parent 132936b commit c16b4de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
29 changes: 15 additions & 14 deletions src/cpp/src/whisper/whisper_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,23 @@

#include "whisper_utils.hpp"

namespace ov {
namespace {

namespace genai {
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) {
Expand All @@ -20,18 +33,6 @@ void infer_with_perf_metrics(ov::InferRequest& request, ov::genai::RawPerfMetric
raw_metrics.m_batch_sizes.emplace_back(1);
}


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;
}

void filter_non_segment_metrics(ov::genai::RawPerfMetrics& raw_metrics,
size_t offset,
std::vector<std::pair<size_t, size_t>>& ranges) {
Expand Down
5 changes: 0 additions & 5 deletions src/cpp/src/whisper/whisper_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@
#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);

template <typename T>
void filter_by_ranges(std::vector<T>& value, size_t offset, std::vector<std::pair<size_t, size_t>>& ranges);

void filter_non_segment_metrics(ov::genai::RawPerfMetrics& raw_metrics,
size_t offset,
std::vector<std::pair<size_t, size_t>>& ranges);
Expand Down

0 comments on commit c16b4de

Please sign in to comment.