mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 20:09:23 +08:00
Fix comments to review
This commit is contained in:
parent
b0b77b3047
commit
a6fbd8287c
@ -89,13 +89,17 @@ struct ParamDesc {
|
||||
cv::optional<cv::gapi::wip::onevpl::Device> vpl_preproc_device;
|
||||
cv::optional<cv::gapi::wip::onevpl::Context> vpl_preproc_ctx;
|
||||
|
||||
using precision_t = int;
|
||||
using precision_map_t = std::unordered_map<std::string, int>;
|
||||
// NB: cv::util::monostate is default value that means precision wasn't specified.
|
||||
using precision_variant_t = cv::util::variant<cv::util::monostate,
|
||||
precision_t,
|
||||
precision_map_t>;
|
||||
precision_variant_t output_precision;
|
||||
using PrecisionT = int;
|
||||
using PrecisionMapT = std::unordered_map<std::string, PrecisionT>;
|
||||
// NB: This parameter can contain:
|
||||
// 1. cv::util::monostate - Don't specify precision, but use default from IR/Blob.
|
||||
// 2. PrecisionT (CV_8U, CV_32F, ...) - Specifies precision for all output layers.
|
||||
// 3. PrecisionMapT ({{"layer0", CV_32F}, {"layer1", CV_16F}} - Specifies precision for certain output layer.
|
||||
// cv::util::monostate is default value that means precision wasn't specified.
|
||||
using PrecisionVariantT = cv::util::variant<cv::util::monostate,
|
||||
PrecisionT,
|
||||
PrecisionMapT>;
|
||||
PrecisionVariantT output_precision;
|
||||
|
||||
};
|
||||
} // namespace detail
|
||||
@ -366,21 +370,23 @@ public:
|
||||
|
||||
The function is used to set an output precision for model.
|
||||
|
||||
@param precision Precision in OpenCV format.
|
||||
@param precision Precision in OpenCV format (CV_8U, CV_32F, ...)
|
||||
will be applied to all output layers.
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
Params<Net>& cfgOutputPrecision(detail::ParamDesc::precision_t precision) {
|
||||
Params<Net>& cfgOutputPrecision(detail::ParamDesc::PrecisionT precision) {
|
||||
desc.output_precision = precision;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @overload
|
||||
|
||||
@param precision_map Map of pairs: name of corresponding output layer and its precision
|
||||
@param precision_map Map of pairs: name of corresponding output layer
|
||||
and its precision in OpenCV format (CV_8U, CV_32F, ...)
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
Params<Net>&
|
||||
cfgOutputPrecision(detail::ParamDesc::precision_map_t precision_map) {
|
||||
cfgOutputPrecision(detail::ParamDesc::PrecisionMapT precision_map) {
|
||||
desc.output_precision = precision_map;
|
||||
return *this;
|
||||
}
|
||||
@ -511,14 +517,14 @@ public:
|
||||
}
|
||||
|
||||
/** @see ie::Params::cfgOutputPrecision */
|
||||
Params& cfgOutputPrecision(detail::ParamDesc::precision_t precision) {
|
||||
Params& cfgOutputPrecision(detail::ParamDesc::PrecisionT precision) {
|
||||
desc.output_precision = precision;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @overload */
|
||||
Params&
|
||||
cfgOutputPrecision(detail::ParamDesc::precision_map_t precision_map) {
|
||||
cfgOutputPrecision(detail::ParamDesc::PrecisionMapT precision_map) {
|
||||
desc.output_precision = precision_map;
|
||||
return *this;
|
||||
}
|
||||
|
@ -201,10 +201,10 @@ inline void copyFromIE(const IE::Blob::Ptr &blob, MatType &mat) {
|
||||
const auto ie_type = toCV(desc.getPrecision());
|
||||
if (ie_type != mat.type()) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed while copying blob from IE to OCV: "
|
||||
<< "Blobs have different data types.\n"
|
||||
<< "IE type: " << ie_type << "\n"
|
||||
<< "OCV type: " << mat.type() << std::endl;
|
||||
ss << "Failed to copy blob from IE to OCV: "
|
||||
<< "Blobs have different data types "
|
||||
<< "(IE type: " << ie_type
|
||||
<< " vs OCV type: " << mat.type() << ")." << std::endl;
|
||||
throw std::logic_error(ss.str());
|
||||
}
|
||||
switch (blob->getTensorDesc().getPrecision()) {
|
||||
@ -1140,29 +1140,25 @@ static IE::PreProcessInfo configurePreProcInfo(const IE::InputInfo::CPtr& ii,
|
||||
}
|
||||
|
||||
using namespace cv::gapi::ie::detail;
|
||||
static void configureOutputPrecision(const IE::OutputsDataMap &outputs_info,
|
||||
const ParamDesc::precision_variant_t &output_precision) {
|
||||
switch (output_precision.index()) {
|
||||
case ParamDesc::precision_variant_t::index_of<ParamDesc::precision_t>(): {
|
||||
auto precision = toIE(cv::util::get<ParamDesc::precision_t>(output_precision));
|
||||
for (auto it : outputs_info) {
|
||||
it.second->setPrecision(precision);
|
||||
static void configureOutputPrecision(const IE::OutputsDataMap &outputs_info,
|
||||
const ParamDesc::PrecisionVariantT &output_precision) {
|
||||
cv::util::visit(cv::util::overload_lambdas(
|
||||
[&outputs_info](ParamDesc::PrecisionT cvdepth) {
|
||||
auto precision = toIE(cvdepth);
|
||||
for (auto it : outputs_info) {
|
||||
it.second->setPrecision(precision);
|
||||
}
|
||||
},
|
||||
[&outputs_info](const ParamDesc::PrecisionMapT& precision_map) {
|
||||
for (auto it : precision_map) {
|
||||
outputs_info.at(it.first)->setPrecision(toIE(it.second));
|
||||
}
|
||||
},
|
||||
[&outputs_info](cv::util::monostate) {
|
||||
// Do nothing.
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ParamDesc::precision_variant_t::index_of<ParamDesc::precision_map_t>(): {
|
||||
const auto& precision_map =
|
||||
cv::util::get<ParamDesc::precision_map_t>(output_precision);
|
||||
for (auto it : precision_map) {
|
||||
outputs_info.at(it.first)->setPrecision(toIE(it.second));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ParamDesc::precision_variant_t::index_of<cv::util::monostate>(): {
|
||||
// Do nothing;
|
||||
break;
|
||||
}
|
||||
}
|
||||
), output_precision
|
||||
);
|
||||
}
|
||||
|
||||
// NB: This is a callback used by async infer
|
||||
|
Loading…
Reference in New Issue
Block a user