Merge pull request #20169 from TolyaTalamanov:at/doc-generic-type

[G-API] Generic type documentation

* Put doc about generic type

* Fix comments to review
pull/20244/head
Anatoliy Talamanov 4 years ago committed by GitHub
parent d9ed9a9a83
commit bdc8e9118b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      modules/gapi/include/opencv2/gapi/infer.hpp
  2. 50
      modules/gapi/include/opencv2/gapi/infer/ie.hpp

@ -531,7 +531,11 @@ typename Net::Result infer(Args&&... args) {
} }
/** /**
* @brief Special network type * @brief Generic network type: input and output layers are configured dynamically at runtime
*
* Unlike the network types defined with G_API_NET macro, this one
* doesn't fix number of network inputs and outputs at the compilation stage
* thus providing user with an opportunity to program them in runtime.
*/ */
struct Generic { }; struct Generic { };

@ -196,9 +196,24 @@ protected:
detail::ParamDesc desc; detail::ParamDesc desc;
}; };
/*
* @brief This structure provides functions for generic network type that
* fill inference parameters.
* @see struct Generic
*/
template<> template<>
class Params<cv::gapi::Generic> { class Params<cv::gapi::Generic> {
public: public:
/** @brief Class constructor.
Constructs Params based on model information and sets default values for other
inference description parameters. Model is loaded and compiled using OpenVINO Toolkit.
@param tag string tag of the network for which these parameters are intended.
@param model path to topology IR (.xml file).
@param weights path to weights (.bin file).
@param device target device to use.
*/
Params(const std::string &tag, Params(const std::string &tag,
const std::string &model, const std::string &model,
const std::string &weights, const std::string &weights,
@ -206,22 +221,34 @@ public:
: desc{ model, weights, device, {}, {}, {}, 0u, 0u, detail::ParamDesc::Kind::Load, true, {}, {}, {}, 1u}, m_tag(tag) { : desc{ model, weights, device, {}, {}, {}, 0u, 0u, detail::ParamDesc::Kind::Load, true, {}, {}, {}, 1u}, m_tag(tag) {
}; };
/** @overload
This constructor for pre-compiled networks. Model is imported from pre-compiled
blob.
@param tag string tag of the network for which these parameters are intended.
@param model path to model.
@param device target device to use.
*/
Params(const std::string &tag, Params(const std::string &tag,
const std::string &model, const std::string &model,
const std::string &device) const std::string &device)
: desc{ model, {}, device, {}, {}, {}, 0u, 0u, detail::ParamDesc::Kind::Import, true, {}, {}, {}, 1u}, m_tag(tag) { : desc{ model, {}, device, {}, {}, {}, 0u, 0u, detail::ParamDesc::Kind::Import, true, {}, {}, {}, 1u}, m_tag(tag) {
}; };
Params& pluginConfig(IEConfig&& cfg) { /** @see ie::Params::pluginConfig. */
desc.config = std::move(cfg); Params& pluginConfig(const IEConfig& cfg) {
desc.config = cfg;
return *this; return *this;
} }
Params& pluginConfig(const IEConfig& cfg) { /** @overload */
desc.config = cfg; Params& pluginConfig(IEConfig&& cfg) {
desc.config = std::move(cfg);
return *this; return *this;
} }
/** @see ie::Params::constInput. */
Params& constInput(const std::string &layer_name, Params& constInput(const std::string &layer_name,
const cv::Mat &data, const cv::Mat &data,
TraitAs hint = TraitAs::TENSOR) { TraitAs hint = TraitAs::TENSOR) {
@ -229,37 +256,44 @@ public:
return *this; return *this;
} }
/** @see ie::Params::cfgNumRequests. */
Params& cfgNumRequests(size_t nireq) { Params& cfgNumRequests(size_t nireq) {
GAPI_Assert(nireq > 0 && "Number of infer requests must be greater than zero!"); GAPI_Assert(nireq > 0 && "Number of infer requests must be greater than zero!");
desc.nireq = nireq; desc.nireq = nireq;
return *this; return *this;
} }
Params& cfgInputReshape(std::map<std::string, std::vector<std::size_t>> && reshape_table) { /** @see ie::Params::cfgInputReshape */
desc.reshape_table = std::move(reshape_table); Params& cfgInputReshape(const std::map<std::string, std::vector<std::size_t>>&reshape_table) {
desc.reshape_table = reshape_table;
return *this; return *this;
} }
Params& cfgInputReshape(const std::map<std::string, std::vector<std::size_t>>&reshape_table) { /** @overload */
desc.reshape_table = reshape_table; Params& cfgInputReshape(std::map<std::string, std::vector<std::size_t>> && reshape_table) {
desc.reshape_table = std::move(reshape_table);
return *this; return *this;
} }
/** @overload */
Params& cfgInputReshape(std::string && layer_name, std::vector<size_t> && layer_dims) { Params& cfgInputReshape(std::string && layer_name, std::vector<size_t> && layer_dims) {
desc.reshape_table.emplace(layer_name, layer_dims); desc.reshape_table.emplace(layer_name, layer_dims);
return *this; return *this;
} }
/** @overload */
Params& cfgInputReshape(const std::string & layer_name, const std::vector<size_t>&layer_dims) { Params& cfgInputReshape(const std::string & layer_name, const std::vector<size_t>&layer_dims) {
desc.reshape_table.emplace(layer_name, layer_dims); desc.reshape_table.emplace(layer_name, layer_dims);
return *this; return *this;
} }
/** @overload */
Params& cfgInputReshape(std::unordered_set<std::string> && layer_names) { Params& cfgInputReshape(std::unordered_set<std::string> && layer_names) {
desc.layer_names_to_reshape = std::move(layer_names); desc.layer_names_to_reshape = std::move(layer_names);
return *this; return *this;
} }
/** @overload */
Params& cfgInputReshape(const std::unordered_set<std::string>&layer_names) { Params& cfgInputReshape(const std::unordered_set<std::string>&layer_names) {
desc.layer_names_to_reshape = layer_names; desc.layer_names_to_reshape = layer_names;
return *this; return *this;

Loading…
Cancel
Save