Skip to content

Commit 1fd76a8

Browse files
committed
Check
1 parent b5b61d4 commit 1fd76a8

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

src/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ cc_library(
701701
"@mediapipe//mediapipe/calculators/tensor:image_to_tensor_calculator",
702702
"@mediapipe//mediapipe/modules/holistic_landmark:holistic_landmark_cpu",
703703
"libovmsmediapipe_utils",
704+
"@mediapipe//mediapipe/framework:thread_pool_executor",
704705
"@mediapipe//mediapipe/calculators/geti/inference:inference_calculators",
705706
"@mediapipe//mediapipe/calculators/geti/utils:utils",
706707
"@mediapipe//mediapipe/calculators/geti/utils:emptylabel_calculators",

src/mediapipe_internal/mediapipegraphdefinition.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ MediapipeGraphDefinition::MediapipeGraphDefinition(const std::string name,
191191
reporter(std::make_unique<MediapipeServableMetricReporter>(metricConfig, registry, name)) {
192192
mgconfig = config;
193193
passKfsRequestFlag = false;
194+
if (!sharedThreadPool) {
195+
SPDLOG_ERROR("Created shared Thread Pool XXX");
196+
sharedThreadPool = std::make_shared<mediapipe::ThreadPoolExecutor>(std::thread::hardware_concurrency()); // TODO FIXME should be in MP factory
197+
}
194198
}
195199

196200
Status MediapipeGraphDefinition::createInputsInfo() {
@@ -474,4 +478,5 @@ Status MediapipeGraphDefinition::initializeNodes() {
474478
}
475479
return StatusCode::OK;
476480
}
481+
std::shared_ptr<mediapipe::ThreadPoolExecutor> sharedThreadPool; // TODO FIXME should be in MP factory
477482
} // namespace ovms

src/mediapipe_internal/mediapipegraphdefinition.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "mediapipe/framework/calculator_graph.h"
3838
#include "mediapipe/framework/port/parse_text_proto.h"
3939
#include "mediapipe/framework/port/status.h"
40+
#include "mediapipe/framework/thread_pool_executor.h"
4041
#pragma GCC diagnostic pop
4142
#pragma warning(pop)
4243

@@ -57,6 +58,7 @@ class GenAiServable;
5758
using PythonNodeResourcesMap = std::unordered_map<std::string, std::shared_ptr<PythonNodeResources>>;
5859
using GenAiServableMap = std::unordered_map<std::string, std::shared_ptr<GenAiServable>>;
5960

61+
extern std::shared_ptr<mediapipe::ThreadPoolExecutor> sharedThreadPool;
6062
class MediapipeGraphDefinition {
6163
friend MediapipeGraphDefinitionUnloadGuard;
6264

src/mediapipe_internal/mediapipegraphexecutor.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <vector>
2525

2626
#include "../execution_context.hpp"
27+
#include "../logging.hpp"
2728
#include "../model_metric_reporter.hpp"
2829
#include "../profiler.hpp"
2930
#include "../status.hpp"
@@ -109,13 +110,17 @@ class MediapipeGraphExecutor {
109110
MetricCounterGuard failedRequestsGuard(this->mediapipeServableMetricReporter->getRequestsMetric(executionContext, false));
110111
MetricGaugeGuard currentGraphsGuard(this->mediapipeServableMetricReporter->currentGraphs.get());
111112
::mediapipe::CalculatorGraph graph;
113+
SPDLOG_ERROR("SetExecutor XXX");
114+
std::ignore = graph.SetExecutor("", sharedThreadPool); // TODO FIXME
115+
SPDLOG_ERROR("Start unary KServe request mediapipe graph: {} initializationXXXbegin", this->name);
112116
MP_RETURN_ON_FAIL(graph.Initialize(this->config), std::string("failed initialization of MediaPipe graph: ") + this->name, StatusCode::MEDIAPIPE_GRAPH_INITIALIZATION_ERROR);
113117
enum : unsigned int {
114118
PROCESS,
115119
TIMER_END2
116120
};
117121
Timer<TIMER_END2> timer;
118122
timer.start(PROCESS);
123+
SPDLOG_ERROR("Start unary KServe request mediapipe graph: {} initializationXXXend", this->name);
119124
std::unordered_map<std::string, ::mediapipe::OutputStreamPoller> outputPollers;
120125
for (auto& name : this->outputNames) {
121126
if (name.empty()) {
@@ -136,7 +141,9 @@ class MediapipeGraphExecutor {
136141
inputSidePackets[PYTHON_SESSION_SIDE_PACKET_TAG] = mediapipe::MakePacket<PythonNodeResourcesMap>(this->pythonNodeResourcesMap).At(STARTING_TIMESTAMP);
137142
inputSidePackets[LLM_SESSION_SIDE_PACKET_TAG] = mediapipe::MakePacket<GenAiServableMap>(this->llmNodeResourcesMap).At(STARTING_TIMESTAMP);
138143
#endif
144+
SPDLOG_ERROR("Start unary KServe request mediapipe graph: {} startRunXXXbegin", this->name);
139145
MP_RETURN_ON_FAIL(graph.StartRun(inputSidePackets), std::string("start MediaPipe graph: ") + this->name, StatusCode::MEDIAPIPE_GRAPH_START_ERROR);
146+
SPDLOG_ERROR("Start unary KServe request mediapipe graph: {} startRunXXXend", this->name);
140147

141148
::mediapipe::Packet packet;
142149
std::set<std::string> outputPollersWithReceivedPacket;
@@ -231,7 +238,9 @@ class MediapipeGraphExecutor {
231238
{
232239
OVMS_PROFILE_SCOPE("Mediapipe graph initialization");
233240
// Init
241+
SPDLOG_DEBUG("Start unary KServe request mediapipe graph: {} initializationXXX", this->name);
234242
MP_RETURN_ON_FAIL(graph.Initialize(this->config), "graph initialization", StatusCode::MEDIAPIPE_GRAPH_INITIALIZATION_ERROR);
243+
SPDLOG_DEBUG("Start unary KServe request mediapipe graph: {} initializationXXX ended", this->name);
235244
}
236245
enum : unsigned int {
237246
PROCESS,

0 commit comments

Comments
 (0)