fix:make zerocolor edge
This commit is contained in:
@@ -51,12 +51,6 @@ public:
|
||||
GAPI_WRAP
|
||||
PyParams& cfgDisableMemPattern();
|
||||
|
||||
GAPI_WRAP
|
||||
PyParams& cfgSessionOptions(const std::map<std::string, std::string>& options);
|
||||
|
||||
GAPI_WRAP
|
||||
PyParams& cfgOptLevel(const int opt_level);
|
||||
|
||||
GBackend backend() const;
|
||||
std::string tag() const;
|
||||
cv::util::any params() const;
|
||||
|
||||
@@ -15,12 +15,10 @@
|
||||
|
||||
#include <opencv2/gapi/opencv_includes.hpp>
|
||||
#include <opencv2/gapi/util/any.hpp>
|
||||
#include <opencv2/gapi/util/optional.hpp>
|
||||
|
||||
#include <opencv2/core/cvdef.h> // GAPI_EXPORTS
|
||||
#include <opencv2/gapi/gkernel.hpp> // GKernelPackage
|
||||
#include <opencv2/gapi/infer.hpp> // Generic
|
||||
#include <opencv2/gapi/infer/workload_type.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace gapi {
|
||||
@@ -353,10 +351,8 @@ struct ParamDesc {
|
||||
std::unordered_map<std::string, std::pair<cv::Scalar, cv::Scalar> > generic_mstd;
|
||||
std::unordered_map<std::string, bool> generic_norm;
|
||||
|
||||
std::map<std::string, std::string> session_options;
|
||||
std::vector<cv::gapi::onnx::ep::EP> execution_providers;
|
||||
bool disable_mem_pattern;
|
||||
cv::util::optional<int> opt_level;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
@@ -638,30 +634,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Configures session options for ONNX Runtime.
|
||||
|
||||
This function is used to set various session options for the ONNX Runtime
|
||||
session by accepting a map of key-value pairs.
|
||||
|
||||
@param options A map of session option to be applied to the ONNX Runtime session.
|
||||
@return the reference on modified object.
|
||||
*/
|
||||
Params<Net>& cfgSessionOptions(const std::map<std::string, std::string>& options) {
|
||||
desc.session_options.insert(options.begin(), options.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Configures optimization level for ONNX Runtime.
|
||||
|
||||
@param opt_level [optimization level]: Valid values are 0 (disable), 1 (basic), 2 (extended), 99 (all).
|
||||
Please see onnxruntime_c_api.h (enum GraphOptimizationLevel) for the full list of all optimization levels.
|
||||
@return the reference on modified object.
|
||||
*/
|
||||
Params<Net>& cfgOptLevel(const int opt_level) {
|
||||
desc.opt_level = cv::util::make_optional(opt_level);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// BEGIN(G-API's network parametrization API)
|
||||
GBackend backend() const { return cv::gapi::onnx::backend(); }
|
||||
std::string tag() const { return Net::tag(); }
|
||||
@@ -689,7 +661,7 @@ public:
|
||||
@param model_path path to model file (.onnx file).
|
||||
*/
|
||||
Params(const std::string& tag, const std::string& model_path)
|
||||
: desc{ model_path, 0u, 0u, {}, {}, {}, {}, {}, {}, {}, {}, {}, true, {}, {}, {}, {}, false, {} }, m_tag(tag) {}
|
||||
: desc{model_path, 0u, 0u, {}, {}, {}, {}, {}, {}, {}, {}, {}, true, {}, {}, {}, false }, m_tag(tag) {}
|
||||
|
||||
/** @see onnx::Params::cfgMeanStdDev. */
|
||||
void cfgMeanStdDev(const std::string &layer,
|
||||
@@ -733,16 +705,6 @@ public:
|
||||
desc.disable_mem_pattern = true;
|
||||
}
|
||||
|
||||
/** @see onnx::Params::cfgSessionOptions. */
|
||||
void cfgSessionOptions(const std::map<std::string, std::string>& options) {
|
||||
desc.session_options.insert(options.begin(), options.end());
|
||||
}
|
||||
|
||||
/** @see onnx::Params::cfgOptLevel. */
|
||||
void cfgOptLevel(const int opt_level) {
|
||||
desc.opt_level = cv::util::make_optional(opt_level);
|
||||
}
|
||||
|
||||
// BEGIN(G-API's network parametrization API)
|
||||
GBackend backend() const { return cv::gapi::onnx::backend(); }
|
||||
std::string tag() const { return m_tag; }
|
||||
@@ -753,16 +715,8 @@ protected:
|
||||
std::string m_tag;
|
||||
};
|
||||
|
||||
class WorkloadTypeONNX : public WorkloadType {};
|
||||
using WorkloadTypeONNXPtr = std::shared_ptr<cv::gapi::onnx::WorkloadTypeONNX>;
|
||||
|
||||
} // namespace onnx
|
||||
} // namespace gapi
|
||||
namespace detail {
|
||||
template<> struct CompileArgTag<cv::gapi::onnx::WorkloadTypeONNXPtr> {
|
||||
static const char* tag() { return "gapi.onnx.workload_type"; }
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_INFER_HPP
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <opencv2/gapi/own/exports.hpp> // GAPI_EXPORTS
|
||||
#include <opencv2/gapi/gkernel.hpp> // GKernelType[M], GBackend
|
||||
#include <opencv2/gapi/infer.hpp> // Generic
|
||||
#include <opencv2/gapi/infer/workload_type.hpp>
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -67,8 +66,6 @@ struct ParamDesc {
|
||||
LayerVariantAttr<std::vector<float>> scale_values;
|
||||
|
||||
LayerVariantAttr<int> interpolation;
|
||||
|
||||
bool clamp_outputs = false;
|
||||
};
|
||||
|
||||
struct CompiledModel {
|
||||
@@ -102,8 +99,6 @@ struct ParamDesc {
|
||||
PluginConfigT config;
|
||||
|
||||
size_t nireq = 1;
|
||||
|
||||
bool ensure_named_tensors = false;
|
||||
};
|
||||
|
||||
// NB: Just helper to avoid code duplication.
|
||||
@@ -210,24 +205,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Ensures the model has named tensors.
|
||||
|
||||
This function is used to ensure that all tensors in the model have names.
|
||||
It goes through all input and output nodes of the model and sets the names
|
||||
if they are not set. This is neccessary for models with nameless tensors.
|
||||
|
||||
If a tensor does not have a name, it will be assigned a default name
|
||||
based on the producer node's friendly name. If the producer node has multiple
|
||||
outputs, the name will be in the form "node_name:N", where N is the output index.
|
||||
|
||||
@param flag If true, then it guarantees that all tensors will have names.
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
Params<Net>& cfgEnsureNamedTensors(bool flag = true) {
|
||||
m_desc.ensure_named_tensors = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Specifies tensor layout for an input layer.
|
||||
|
||||
The function is used to set tensor layout for an input layer.
|
||||
@@ -359,24 +336,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Enables or disables clamping of model outputs in the PrePostProcessor.
|
||||
|
||||
By default, output values are clamped to the valid range for the output precision
|
||||
by the device or plugin. Enabling this option moves clamping to the PrePostProcessor stage.
|
||||
|
||||
@note This feature is only available with OpenVINO 2025.2 and newer.
|
||||
|
||||
@param flag If true, clamping is performed in the PrePostProcessor;
|
||||
otherwise, it is handled by the device or plugin.
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
Params<Net>&
|
||||
cfgClampOutputs(bool flag = true) {
|
||||
detail::getModelToSetAttrOrThrow(m_desc.kind, "clamp outputs")
|
||||
.clamp_outputs = std::move(flag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Specifies the new shape for input layers.
|
||||
|
||||
The function is used to set new shape for input layers.
|
||||
@@ -565,12 +524,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ov::Params::cfgEnsureNamedTensors. */
|
||||
Params& cfgEnsureNamedTensors(bool flag = true) {
|
||||
m_desc.ensure_named_tensors = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ov::Params::cfgInputTensorLayout. */
|
||||
Params& cfgInputTensorLayout(std::string layout) {
|
||||
detail::getModelToSetAttrOrThrow(m_desc.kind, "input tensor layout")
|
||||
@@ -646,14 +599,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ov::Params::cfgClampOutputs. */
|
||||
Params&
|
||||
cfgClampOutputs(bool flag = true) {
|
||||
detail::getModelToSetAttrOrThrow(m_desc.kind, "clamp outputs")
|
||||
.clamp_outputs = std::move(flag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ov::Params::cfgReshape. */
|
||||
Params& cfgReshape(std::vector<size_t> new_shape) {
|
||||
detail::getModelToSetAttrOrThrow(m_desc.kind, "reshape")
|
||||
@@ -746,9 +691,6 @@ namespace wip { namespace ov {
|
||||
*/
|
||||
struct benchmark_mode { };
|
||||
|
||||
class WorkloadTypeOV : public WorkloadType {};
|
||||
using WorkloadTypeOVPtr = std::shared_ptr<cv::gapi::wip::ov::WorkloadTypeOV>;
|
||||
|
||||
} // namespace ov
|
||||
} // namespace wip
|
||||
|
||||
@@ -760,10 +702,6 @@ namespace detail
|
||||
{
|
||||
static const char* tag() { return "gapi.wip.ov.benchmark_mode"; }
|
||||
};
|
||||
template<> struct CompileArgTag<cv::gapi::wip::ov::WorkloadTypeOVPtr>
|
||||
{
|
||||
static const char* tag() { return "gapi.wip.ov.workload_type"; }
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace cv
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
//
|
||||
// Copyright (C) 2025 Intel Corporation
|
||||
|
||||
#ifndef OPENCV_WORKLOADTYPE_HPP
|
||||
#define OPENCV_WORKLOADTYPE_HPP
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
using Callback = std::function<void(const std::string &type)>;
|
||||
|
||||
class WorkloadListener {
|
||||
Callback callback;
|
||||
public:
|
||||
uint64_t id;
|
||||
WorkloadListener(const Callback &cb, uint64_t listener_id) : callback(cb), id(listener_id) {}
|
||||
|
||||
void operator()(const std::string &type) const {
|
||||
if (callback) {
|
||||
callback(type);
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const WorkloadListener& other) const {
|
||||
return id == other.id;
|
||||
}
|
||||
};
|
||||
|
||||
class WorkloadType {
|
||||
std::vector<WorkloadListener> listeners;
|
||||
uint64_t nextId = 1;
|
||||
public:
|
||||
uint64_t addListener(const Callback &cb) {
|
||||
uint64_t id = nextId++;
|
||||
listeners.emplace_back(cb, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void removeListener(uint64_t id) {
|
||||
auto it = std::remove_if(listeners.begin(), listeners.end(),
|
||||
[id](const WorkloadListener& entry) { return entry.id == id; });
|
||||
if (it != listeners.end()) {
|
||||
listeners.erase(it, listeners.end());
|
||||
}
|
||||
}
|
||||
|
||||
void set(const std::string &type) {
|
||||
for (const auto &listener : listeners) {
|
||||
listener(type);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // OPENCV_WORKLOADTYPE_HPP
|
||||
Reference in New Issue
Block a user