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