16 #include "cpp_interfaces/interface/ie_iinfer_request_internal.hpp"
21 #include "ie_preprocess_data.hpp"
23 namespace InferenceEngine {
25 class ExecutableNetworkInternal;
37 typedef std::shared_ptr<InferRequestInternal>
Ptr;
73 OV_ITT_SCOPED_TASK(itt::domains::Plugin,
"SetBlob");
74 if (name ==
nullptr) {
78 const bool compoundBlobPassed = data->is<
CompoundBlob>();
79 if (!compoundBlobPassed && data->buffer() ==
nullptr)
81 if (data->size() == 0) {
87 size_t dataSize = data->size();
89 if (foundInput->getPrecision() != data->getTensorDesc().getPrecision()) {
91 <<
"Failed to set Blob with precision not corresponding to user input precision";
95 if (compoundBlobPassed && !preProcRequired) {
97 <<
"cannot set compound blob: supported only for input pre-processing";
100 if (preProcRequired) {
110 if (dataSize != inputSize) {
112 <<
"!=" << inputSize <<
").";
117 if (compoundBlobPassed) {
119 <<
"cannot set compound blob: supported only for input pre-processing";
122 if (dataSize != outputSize) {
123 THROW_IE_EXCEPTION <<
"Output blob size is not equal network output size (" << dataSize
124 <<
"!=" << outputSize <<
").";
126 if (foundOutput->getPrecision() != data->getTensorDesc().getPrecision()) {
128 <<
"Failed to set Blob with precision not corresponding to user output precision";
142 OV_ITT_SCOPED_TASK(itt::domains::Plugin,
"GetBlob");
150 data = it->second->getRoiBlob();
154 foundInput->getTensorDesc().getLayout() !=
SCALAR
155 ? foundInput->getTensorDesc().getDims()
161 foundOutput->getTensorDesc().getLayout() !=
SCALAR
162 ? foundOutput->getTensorDesc().getDims()
177 copyPreProcess(info, foundInput->getPreProcess());
194 *info = &foundInput->getPreProcess();
218 for (
auto const& input :
_inputs) {
219 checkBlob(input.second, input.first,
true);
221 for (
auto const& output :
_outputs) {
222 checkBlob(output.second, output.first,
false);
226 std::vector<IVariableStateInternal::Ptr>
QueryState()
override {
252 for (
auto& input : inputs) {
274 foundInput =
nullptr;
275 foundOutput =
nullptr;
280 [&](
const std::pair<std::string, InputInfo::Ptr>& pair) {
281 return pair.first == name;
284 [&](
const std::pair<std::string, DataPtr>& pair) {
285 return pair.first == name;
291 foundInput = foundInputPair->second;
294 foundOutput = foundOutputPair->second;
308 std::string bType = isInput ?
"Input" :
"Output";
309 std::string sType = isInput ?
"input" :
"output";
310 std::string strNotAllocated(bType +
" data was not allocated.");
311 std::string strNotMatched(
"The " + sType +
" blob size is not equal to the network " + sType +
" size");
317 if (refDims.empty()) {
321 [&](
const std::pair<std::string, InputInfo::Ptr>& pair) {
322 return pair.first == name;
327 dims = foundInputPair->second->getTensorDesc().getDims();
328 refSize = foundInputPair->second->getTensorDesc().getLayout() !=
SCALAR
333 [&](
const std::pair<std::string, DataPtr>& pair) {
334 return pair.first == name;
339 dims = foundOutputPair->second->getTensorDesc().getDims();
340 refSize = foundOutputPair->second->getTensorDesc().getLayout() !=
SCALAR
348 if (refSize != blob->size()) {
349 THROW_IE_EXCEPTION << strNotMatched +
": got " << blob->size() <<
" expecting " << refSize;
366 const auto& preProcessInfo = info->getPreProcess();
367 const auto inputColorFormat = preProcessInfo.getColorFormat();
370 const auto networkColorFormat = ColorFormat::BGR;
372 const bool colorFormatSpecified = inputColorFormat != ColorFormat::RAW;
373 return preProcessInfo.getResizeAlgorithm() != ResizeAlgorithm::NO_RESIZE ||
374 (colorFormatSpecified && inputColorFormat != networkColorFormat) ||
375 (colorFormatSpecified && info->getLayout() != blob->getTensorDesc().getLayout());
std::shared_ptr< Blob > Ptr
An internal API of synchronous inference request to be implemented by plugin, which is used in InferR...
Definition: ie_iinfer_request_internal.hpp:24
An optimal implementation of IInferRequestInternal interface to avoid duplication in all plugins This...
Definition: ie_infer_request_internal.hpp:32
InferenceEngine::BlobMap _outputs
A map of network output blobs.
Definition: ie_infer_request_internal.hpp:236
void SetBlob(const char *name, const Blob::Ptr &data) override
Given optional implementation of setting blob to avoid need for it to be implemented by plugin.
Definition: ie_infer_request_internal.hpp:72
bool findInputAndOutputBlobByName(const char *name, InputInfo::Ptr &foundInput, DataPtr &foundOutput) const
Helper function to find input or output blob by name.
Definition: ie_infer_request_internal.hpp:273
std::shared_ptr< InferRequestInternal > Ptr
A shared pointer to a InferRequestInternal implementation.
Definition: ie_infer_request_internal.hpp:37
virtual void checkBlobs()
Checks that both inputs and outputs blob are valid. Throws an exception if they are not.
Definition: ie_infer_request_internal.hpp:217
void SetBatch(int batch) override
Sets new batch size when dynamic batching is enabled in executable network that created this request.
Definition: ie_infer_request_internal.hpp:200
std::map< std::string, PreProcessDataPtr > _preProcData
A map of pre-process data per input.
Definition: ie_infer_request_internal.hpp:237
InferenceEngine::InputsDataMap _networkInputs
Holds information about network inputs info.
Definition: ie_infer_request_internal.hpp:233
std::shared_ptr< ExecutableNetworkInternal > _exeNetwork
A shared pointer to ExecutableNetworkInternal interface.
Definition: ie_infer_request_internal.hpp:244
void GetBlob(const char *name, Blob::Ptr &data) override
Given optional implementation of getting blob to avoid need for it to be implemented by plugin.
Definition: ie_infer_request_internal.hpp:141
virtual void InferImpl()=0
The minimal infer function to be implemented by plugins. It infers specified input(s) in synchronous ...
void GetPreProcess(const char *name, const PreProcessInfo **info) const override
Gets pre-process for input data.
Definition: ie_infer_request_internal.hpp:190
void Infer() override
Default common implementation for all plugins with checking input and output blobs before inference.
Definition: ie_infer_request_internal.hpp:61
bool preProcessingRequired(const InputInfo::Ptr &info, const Blob::Ptr &blob)
Checks whether pre-processing step is required for a given input.
Definition: ie_infer_request_internal.hpp:360
void setPointerToExecutableNetworkInternal(std::shared_ptr< ExecutableNetworkInternal > exeNetwork)
Sets the pointer to executable network internal.
Definition: ie_infer_request_internal.hpp:210
int m_curBatch
Current batch value used in dynamic batching.
Definition: ie_infer_request_internal.hpp:238
void SetBlob(const char *name, const Blob::Ptr &data, const PreProcessInfo &info) override
Sets pre-process for input data.
Definition: ie_infer_request_internal.hpp:173
void execDataPreprocessing(InferenceEngine::BlobMap &inputs, bool serial=false)
Checks and executes input data pre-processing if needed.
Definition: ie_infer_request_internal.hpp:251
InferenceEngine::OutputsDataMap _networkOutputs
Holds information about network outputs data.
Definition: ie_infer_request_internal.hpp:234
InferenceEngine::BlobMap _inputs
A map of network input blobs.
Definition: ie_infer_request_internal.hpp:235
void checkBlob(const Blob::Ptr &blob, const std::string &name, bool isInput, const SizeVector &refDims={}) const
Check that blob is valid. Throws an exception if it's not.
Definition: ie_infer_request_internal.hpp:307
InferRequestInternal(const InputsDataMap &networkInputs, const OutputsDataMap &networkOutputs)
Constructs a new instance.
Definition: ie_infer_request_internal.hpp:44
std::vector< IVariableStateInternal::Ptr > QueryState() override
Queries memory states.
Definition: ie_infer_request_internal.hpp:226
Wrappers from c++ function to c-style one.
#define NOT_IMPLEMENTED_str
Defines the not implemented message.
Definition: exception2status.hpp:111
#define NOT_ALLOCATED_str
Defines the not allocated message.
Definition: exception2status.hpp:117
T product(std::vector< T, A > const &vec)
multiply vector's values
Definition: debug.h:144
#define NOT_FOUND_str
Defines the not found message.
Definition: exception2status.hpp:87
#define PARAMETER_MISMATCH_str
Defines the parameter mismatch message.
Definition: exception2status.hpp:75
std::shared_ptr< Data > DataPtr
std::vector< size_t > SizeVector
#define THROW_IE_EXCEPTION
std::map< std::string, DataPtr > OutputsDataMap
Inference Engine plugin API wrapper, to be used by particular implementors.
Defines a ie_memcpy to safely (SDL-friendly) copy arrays.
Defines openvino domains for tracing.