[PP] Addded ability to preprocess inputs into plugin (#857)
desired format changed InferRequestInternal: - added _deviceInputs member to store plugin desired perprocessing targets - added default argument to preProcessingRequired to describe plugin specific desired preprocessing target - SetBlob and GetBlob to deal with plugin desired preprocessing targets (_deviceInputs) - added addInputPreProcessingFor helper method to avoid code duplication changed TEMPLATE plugin to use new functionality: - removed explicit presicion conversion (to use built-in one of InferRequestInternal) - _networkInputBlobs to use InferRequestInternal::_deviceInputs
This commit is contained in:
1 parent
544a3e148d
commit
2495eaf56f
9 files changed
+112
-81
No files matched your search
@@ -112,7 +112,7 @@ static void AllocateImpl(const BlobDataMap& blobDataMap,
|
||||
|
||||
void TemplateInferRequest::allocateBlobs() {
|
||||
auto&& parameters = _executableNetwork->_function->get_parameters();
|
||||
AllocateImpl(_networkInputs, _inputs, _networkInputBlobs, [&] (const std::string& blobName) {
|
||||
AllocateImpl(_networkInputs, _inputs, _deviceInputs, [&] (const std::string& blobName) {
|
||||
return parameters.at(_executableNetwork->_inputIndex.at(blobName))->get_element_type();
|
||||
});
|
||||
auto&& results = _executableNetwork->_function->get_results();
|
||||
@@ -176,21 +176,14 @@ void TemplateInferRequest::inferPreprocess() {
|
||||
auto start = Time::now();
|
||||
// NOTE: After InferRequestInternal::execDataPreprocessing call
|
||||
// input can points to other memory region than it was allocated in constructor.
|
||||
InferRequestInternal::execDataPreprocessing(_inputs);
|
||||
for (auto&& input : _inputs) {
|
||||
auto inputBlob = input.second;
|
||||
auto networkInput = _networkInputBlobs[input.first];
|
||||
if (inputBlob->getTensorDesc().getPrecision() == networkInput->getTensorDesc().getPrecision()) {
|
||||
networkInput = inputBlob;
|
||||
} else {
|
||||
blobCopy(inputBlob, networkInput);
|
||||
}
|
||||
auto index = _executableNetwork->_inputIndex[input.first];
|
||||
InferRequestInternal::execDataPreprocessing(_deviceInputs);
|
||||
for (auto&& networkInput : _deviceInputs) {
|
||||
auto index = _executableNetwork->_inputIndex[networkInput.first];
|
||||
const auto& parameter = _parameters[index];
|
||||
const auto& parameterShape = parameter->get_shape();
|
||||
const auto& parameterType = parameter->get_element_type();
|
||||
_inputTensors[index] = _executableNetwork->_plugin->_backend->create_tensor(parameterType, parameterShape,
|
||||
InferenceEngine::as<InferenceEngine::MemoryBlob>(networkInput)->rmap().as<void*>());
|
||||
InferenceEngine::as<InferenceEngine::MemoryBlob>(networkInput.second)->rmap().as<void*>());
|
||||
}
|
||||
for (auto&& output : _outputs) {
|
||||
auto outputBlob = output.second;
|
||||
|
||||
@@ -63,7 +63,6 @@ private:
|
||||
// for performance counters
|
||||
std::array<std::chrono::duration<float, std::micro>, numOfStages> _durations;
|
||||
|
||||
InferenceEngine::BlobMap _networkInputBlobs;
|
||||
InferenceEngine::BlobMap _networkOutputBlobs;
|
||||
ngraph::ParameterVector _parameters;
|
||||
ngraph::ResultVector _results;
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ const std::vector<std::map<std::string, std::string>> configs = {
|
||||
INSTANTIATE_TEST_CASE_P(PreprocessingPrecisionConvertTestsViaSetInput, PreprocessingPrecisionConvertTest,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(inputPrecisions),
|
||||
::testing::Values(1, 2, 3, 4, 5), // Number of input tensor channels
|
||||
::testing::Values(4), // Number of input tensor channels
|
||||
::testing::Values(true), // Use SetInput
|
||||
::testing::Values(CommonTestUtils::DEVICE_TEMPLATE),
|
||||
::testing::ValuesIn(configs)),
|
||||
@@ -31,7 +31,7 @@ INSTANTIATE_TEST_CASE_P(PreprocessingPrecisionConvertTestsViaSetInput, Preproces
|
||||
INSTANTIATE_TEST_CASE_P(PreprocessingPrecisionConvertTestsViaGetBlob, PreprocessingPrecisionConvertTest,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(inputPrecisions),
|
||||
::testing::Values(4, 5), // Number of input tensor channels (blob_copy only supports 4d and 5d tensors)
|
||||
::testing::Values(4), // Number of input tensor channels (blob_copy only supports 4d and 5d tensors)
|
||||
::testing::Values(false), // use GetBlob
|
||||
::testing::Values(CommonTestUtils::DEVICE_TEMPLATE),
|
||||
::testing::ValuesIn(configs)),
|
||||
|
||||
Reference in new issue
Block a user