Enable log information. Disable NPU in U9

This commit is contained in:
2026-04-21 15:48:27 +10:00
parent 00f6e2f852
commit 97d814936d
18 changed files with 301 additions and 54 deletions

View File

@@ -1,4 +1,5 @@
#include "ANSFR.h"
#include "OpenVINODeviceConfig.h"
#include <opencv2/imgcodecs.hpp>
#include "ANSOVFaceDetector.h"
#include "SCRFDFaceDetector.h"
@@ -2695,8 +2696,12 @@ namespace ANSCENTER {
for (const auto& d : available_devices) {
ANS_DBG("ANSFR", " OpenVINO device: %s", d.c_str());
}
// Prioritize devices: NPU > GPU > CPU
std::vector<std::string> priority_devices = { "NPU","GPU","CPU" };
// Prioritize devices: NPU > GPU > CPU. NPU gated behind runtime switch
// (OPENVINO_ENABLE_NPU=1) — see OpenVINODeviceConfig.h.
std::vector<std::string> priority_devices;
if (IsOpenVINONpuEnabled()) priority_devices.push_back("NPU");
priority_devices.push_back("GPU");
priority_devices.push_back("CPU");
for (const auto& device : priority_devices) {
if (std::find(available_devices.begin(), available_devices.end(), device) != available_devices.end()) {
ANS_DBG("ANSFR", "GetOpenVINODevice: selected %s", device.c_str());

View File

@@ -1,4 +1,5 @@
#include "ANSLPR_CPU.h"
#include "OpenVINODeviceConfig.h"
#include "ANSYOLOV10OVOD.h"
#include "ANSOPENVINOOD.h"
#include "ANSTENSORRTOD.h"
@@ -119,8 +120,10 @@ namespace ANSCENTER {
std::vector<std::string> available_devices = _core.get_available_devices();
bool device_found = false;
std::string deviceName = "CPU";
// Search for NPU
auto it = std::find(available_devices.begin(), available_devices.end(), "NPU");
// Search for NPU (gated by OPENVINO_ENABLE_NPU — see OpenVINODeviceConfig.h)
auto it = IsOpenVINONpuEnabled()
? std::find(available_devices.begin(), available_devices.end(), "NPU")
: available_devices.end();
if (it != available_devices.end()) {
_core.set_property("NPU", ov::hint::performance_mode(ov::hint::PerformanceMode::LATENCY));
_core.set_property("GPU", ov::hint::performance_mode(ov::hint::PerformanceMode::LATENCY));

View File

@@ -1,4 +1,5 @@
#include "BYTETracker.h"
#include "ANSLicense.h" // ANS_DBG for tracker-state-size diagnostic
#include <algorithm>
#include <cstddef>
#include <limits>
@@ -322,6 +323,24 @@ std::vector<ByteTrack::BYTETracker::STrackPtr> ByteTrack::BYTETracker::update(co
tracked_stracks_ = tracked_stracks_out;
lost_stracks_ = lost_stracks_out;
// Diagnostic: report tracker state size at most once every 60 s per instance.
// removed_stracks_ is append-only in this implementation — watch it grow.
{
static thread_local std::chrono::steady_clock::time_point s_nextLog{};
auto now = std::chrono::steady_clock::now();
if (now >= s_nextLog) {
s_nextLog = now + std::chrono::seconds(60);
ANS_DBG("ANSMOT",
"BYTETracker state this=%p frame=%zu nextId=%zu tracked=%zu lost=%zu removed=%zu",
(void*)this,
frame_id_,
track_id_count_,
tracked_stracks_.size(),
lost_stracks_.size(),
removed_stracks_.size());
}
}
std::vector<STrackPtr> output_stracks;
for (const auto &track : tracked_stracks_)
{

View File

@@ -1,5 +1,6 @@
#pragma once
#include "ANSODEngine.h"
#include "OpenVINODeviceConfig.h"
#include "ANSYOLOOD.h"
#include "ANSTENSORRTOD.h"
#include "ANSTENSORRTCL.h"
@@ -333,8 +334,10 @@ namespace ANSCENTER
std::vector<std::string> available_devices = core.get_available_devices();
bool device_found = false;
std::string deviceName = "CPU";
// Search for NPU
auto it = std::find(available_devices.begin(), available_devices.end(), "NPU");
// Search for NPU (gated by OPENVINO_ENABLE_NPU — see OpenVINODeviceConfig.h)
auto it = IsOpenVINONpuEnabled()
? std::find(available_devices.begin(), available_devices.end(), "NPU")
: available_devices.end();
if (it != available_devices.end()) {
core.set_property("NPU", ov::hint::performance_mode(ov::hint::PerformanceMode::LATENCY));
core.set_property("GPU", ov::hint::performance_mode(ov::hint::PerformanceMode::LATENCY));
@@ -1414,7 +1417,7 @@ namespace ANSCENTER
};
std::vector<std::unordered_map<std::string, std::string>> try_configs;
if (!s_npuProbed || s_npuAvailable) {
if (IsOpenVINONpuEnabled() && (!s_npuProbed || s_npuAvailable)) {
try_configs.push_back(makeConfig("AUTO:NPU,GPU"));
}
try_configs.push_back(makeConfig("GPU.0"));

View File

@@ -4,6 +4,7 @@
#include <json.hpp>
#include "ANSODEngine.h"
#include "ANSLicense.h" // ANS_DBG macro
#include "OpenVINODeviceConfig.h"
#include "ANSYOLOOD.h"
#include "ANSTENSORRTOD.h"
#include "ANSTENSORRTCL.h"
@@ -354,8 +355,10 @@ namespace ANSCENTER
std::vector<std::string> available_devices = core.get_available_devices();
bool device_found = false;
std::string deviceName = "CPU";
// Search for NPU
auto it = std::find(available_devices.begin(), available_devices.end(), "NPU");
// Search for NPU (gated by OPENVINO_ENABLE_NPU — see OpenVINODeviceConfig.h)
auto it = IsOpenVINONpuEnabled()
? std::find(available_devices.begin(), available_devices.end(), "NPU")
: available_devices.end();
if (it != available_devices.end()) {
core.set_property("NPU", ov::hint::performance_mode(ov::hint::PerformanceMode::LATENCY));
core.set_property("GPU", ov::hint::performance_mode(ov::hint::PerformanceMode::LATENCY));

View File

@@ -1,5 +1,6 @@
#include"ANSONNXCL.h"
#include "EPLoader.h"
#include "OpenVINODeviceConfig.h"
namespace ANSCENTER
{
@@ -143,20 +144,26 @@ namespace ANSCENTER
const std::string numberOfThreads = "1";
const std::string numberOfStreams = "1";
std::vector<std::unordered_map<std::string, std::string>> try_configs = {
{ {"device_type","AUTO:NPU,GPU"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","False"} },
std::vector<std::unordered_map<std::string, std::string>> try_configs;
// NPU gated by OPENVINO_ENABLE_NPU — see OpenVINODeviceConfig.h
if (IsOpenVINONpuEnabled()) {
try_configs.push_back(
{ {"device_type","AUTO:NPU,GPU"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","False"} });
}
try_configs.push_back(
{ {"device_type","GPU.0"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","False"} },
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","False"} });
try_configs.push_back(
{ {"device_type","GPU.1"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","False"} },
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","False"} });
try_configs.push_back(
{ {"device_type","AUTO:GPU,CPU"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","False"} }
};
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","False"} });
for (const auto& config : try_configs) {
try {

View File

@@ -1,5 +1,6 @@
#include "ANSOPENVINOCL.h"
#include "Utility.h"
#include "OpenVINODeviceConfig.h"
namespace ANSCENTER
{
bool OPENVINOCL::OptimizeModel(bool fp16, std::string& optimizedModelFolder) {
@@ -369,8 +370,10 @@ namespace ANSCENTER
std::vector<std::string> available_devices = core.get_available_devices();
bool device_found = false;
// Search for NPU
auto it = std::find(available_devices.begin(), available_devices.end(), "NPU");
// Search for NPU (gated by OPENVINO_ENABLE_NPU — see OpenVINODeviceConfig.h)
auto it = IsOpenVINONpuEnabled()
? std::find(available_devices.begin(), available_devices.end(), "NPU")
: available_devices.end();
if (it != available_devices.end()) {
core.set_property("NPU", ov::hint::performance_mode(ov::hint::PerformanceMode::LATENCY));
core.set_property("GPU", ov::hint::performance_mode(ov::hint::PerformanceMode::LATENCY));

View File

@@ -1,5 +1,6 @@
#include "ANSOPENVINOOD.h"
#include "Utility.h"
#include "OpenVINODeviceConfig.h"
namespace ANSCENTER
{
bool OPENVINOOD::OptimizeModel(bool fp16, std::string& optimizedModelFolder) {
@@ -437,8 +438,11 @@ namespace ANSCENTER
ov::Core core;
// Step 2: Get Available Devices and Log
std::vector<std::string> available_devices = core.get_available_devices();
// Define device priority: NPU > GPU > CPU
std::vector<std::string> priority_devices = { "NPU", "GPU" };
// Define device priority: NPU > GPU > CPU. NPU gated by
// OPENVINO_ENABLE_NPU — see OpenVINODeviceConfig.h.
std::vector<std::string> priority_devices;
if (IsOpenVINONpuEnabled()) priority_devices.push_back("NPU");
priority_devices.push_back("GPU");
bool device_found = false;
// Iterate over prioritized devices

View File

@@ -1,4 +1,5 @@
#include "ANSOVSEG.h"
#include "OpenVINODeviceConfig.h"
namespace ANSCENTER {
bool ANSOVSEG::OptimizeModel(bool fp16, std::string& optimizedModelFolder) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
@@ -493,8 +494,11 @@ namespace ANSCENTER {
ov::Core core;
// Step 2: Get Available Devices and Log
std::vector<std::string> available_devices = core.get_available_devices();
// Define device priority: NPU > GPU > CPU
std::vector<std::string> priority_devices = { "NPU", "GPU" };
// Define device priority: NPU > GPU > CPU. NPU gated by
// OPENVINO_ENABLE_NPU — see OpenVINODeviceConfig.h.
std::vector<std::string> priority_devices;
if (IsOpenVINONpuEnabled()) priority_devices.push_back("NPU");
priority_devices.push_back("GPU");
bool device_found = false;
// Iterate over prioritized devices

View File

@@ -1,5 +1,6 @@
#include "ANSYOLO12OD.h"
#include "EPLoader.h"
#include "OpenVINODeviceConfig.h"
#ifdef USEONNXOV
#endif
@@ -365,20 +366,26 @@ namespace ANSCENTER {
const std::string numberOfThreads = "8";
const std::string numberOfStreams = "8";
std::vector<std::unordered_map<std::string, std::string>> try_configs = {
{ {"device_type","AUTO:NPU,GPU"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} },
std::vector<std::unordered_map<std::string, std::string>> try_configs;
// NPU gated by OPENVINO_ENABLE_NPU — see OpenVINODeviceConfig.h
if (IsOpenVINONpuEnabled()) {
try_configs.push_back(
{ {"device_type","AUTO:NPU,GPU"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} });
}
try_configs.push_back(
{ {"device_type","GPU.0"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} },
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} });
try_configs.push_back(
{ {"device_type","GPU.1"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} },
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} });
try_configs.push_back(
{ {"device_type","AUTO:GPU,CPU"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} }
};
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} });
for (const auto& config : try_configs) {
try {

View File

@@ -1,6 +1,7 @@
#include "ANSYOLOOD.h"
#include "Utility.h"
#include "EPLoader.h"
#include "OpenVINODeviceConfig.h"
#include "ANSGpuFrameRegistry.h"
#include "NV12PreprocessHelper.h" // tl_currentGpuFrame()
#ifdef USEONNXOV
@@ -303,20 +304,26 @@ namespace ANSCENTER
const std::string numberOfThreads = "8";
const std::string numberOfStreams = "8";
std::vector<std::unordered_map<std::string, std::string>> try_configs = {
{ {"device_type","AUTO:NPU,GPU"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} },
std::vector<std::unordered_map<std::string, std::string>> try_configs;
// NPU gated by OPENVINO_ENABLE_NPU — see OpenVINODeviceConfig.h
if (IsOpenVINONpuEnabled()) {
try_configs.push_back(
{ {"device_type","AUTO:NPU,GPU"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} });
}
try_configs.push_back(
{ {"device_type","GPU.0"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} },
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} });
try_configs.push_back(
{ {"device_type","GPU.1"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} },
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} });
try_configs.push_back(
{ {"device_type","AUTO:GPU,CPU"}, {"precision",precision},
{"num_of_threads",numberOfThreads}, {"num_streams",numberOfStreams},
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} }
};
{"enable_opencl_throttling","False"}, {"enable_qdq_optimizer","True"} });
for (const auto& config : try_configs) {
try {