Removed WA for CPU interpolate NHWC (#8686)

This commit is contained in:
Ilya Lavrenov
2021-11-19 11:38:06 +03:00
committed by GitHub
parent 2777820882
commit 1ca9592d75
3 changed files with 29 additions and 43 deletions

View File

@@ -27,8 +27,6 @@
#include "classification_sample_async.h" #include "classification_sample_async.h"
#include "openvino/openvino.hpp" #include "openvino/openvino.hpp"
using namespace ov::preprocess;
/** /**
* @brief Checks input args * @brief Checks input args
* @param argc number of args * @param argc number of args
@@ -104,9 +102,9 @@ int main(int argc, char* argv[]) {
// -------- Step 3. Apply preprocessing -------- // -------- Step 3. Apply preprocessing --------
const ov::Layout tensor_layout{"NHWC"}; const ov::Layout tensor_layout{"NHWC"};
PrePostProcessor proc(model); ov::preprocess::PrePostProcessor proc(model);
// 1) input() with no args assumes a model has a single input // 1) input() with no args assumes a model has a single input
InputInfo& input_info = proc.input(); ov::preprocess::InputInfo& input_info = proc.input();
// 2) Set input tensor information: // 2) Set input tensor information:
// - precision of tensor is supposed to be 'u8' // - precision of tensor is supposed to be 'u8'
// - layout of data is 'NHWC' // - layout of data is 'NHWC'

View File

@@ -17,8 +17,6 @@
#include "format_reader_ptr.h" #include "format_reader_ptr.h"
// clang-format on // clang-format on
using namespace ov::preprocess;
/** /**
* @brief Main with support Unicode paths, wide strings * @brief Main with support Unicode paths, wide strings
*/ */
@@ -71,38 +69,29 @@ int tmain(int argc, tchar* argv[]) {
// -------- Step 4. Apply preprocessing -------- // -------- Step 4. Apply preprocessing --------
// clang-format off ov::preprocess::PrePostProcessor preproc(model);
model = PrePostProcessor(model). // 1) Set input tensor information:
// 1) InputInfo() with no args assumes a model has a single input // - input() provides information about a single model input
input(InputInfo().
// 2) Set input tensor information:
// - precision of tensor is supposed to be 'u8' // - precision of tensor is supposed to be 'u8'
// - layout of data is 'NHWC' // - layout of data is 'NHWC'
// - set static spatial dimensions to input tensor to resize from // - set static spatial dimensions to input tensor to resize from
tensor(InputTensorInfo(). preproc.input()
set_element_type(ov::element::u8). .tensor()
set_spatial_static_shape( .set_element_type(ov::element::u8)
tensor_shape[ov::layout::height_idx(tensor_layout)], .set_layout(tensor_layout)
tensor_shape[ov::layout::width_idx(tensor_layout)]). .set_spatial_static_shape(tensor_shape[ov::layout::height_idx(tensor_layout)],
set_layout(tensor_layout)). tensor_shape[ov::layout::width_idx(tensor_layout)]);
// 3) Adding explicit preprocessing steps: // 2) Adding explicit preprocessing steps:
// - convert layout to 'NCHW' (from 'NHWC' specified above at tensor layout) // - convert layout to 'NCHW' (from 'NHWC' specified above at tensor layout)
// - apply linear resize from tensor spatial dims to model spatial dims // - apply linear resize from tensor spatial dims to model spatial dims
preprocess(PreProcessSteps(). preproc.input().preprocess().resize(ov::preprocess::ResizeAlgorithm::RESIZE_LINEAR);
convert_element_type(ov::element::f32). // WA for CPU plugin
convert_layout("NCHW"). // WA for CPU plugin
resize(ResizeAlgorithm::RESIZE_LINEAR)).
// 4) Here we suppose model has 'NCHW' layout for input // 4) Here we suppose model has 'NCHW' layout for input
network(InputNetworkInfo(). preproc.input().network().set_layout("NCHW");
set_layout("NCHW"))).
output(OutputInfo().
// 5) Set output tensor information: // 5) Set output tensor information:
// - precision of tensor is supposed to be 'f32' // - precision of tensor is supposed to be 'f32'
tensor(OutputTensorInfo(). preproc.output().tensor().set_element_type(ov::element::f32);
set_element_type(ov::element::f32))).
// 6) Apply preprocessing modifing the original 'model' // 6) Apply preprocessing modifing the original 'model'
build(); model = preproc.build();
// clang-format on
// -------- Step 5. Loading a model to the device -------- // -------- Step 5. Loading a model to the device --------
ov::runtime::ExecutableNetwork executable_network = core.compile_model(model, device_name); ov::runtime::ExecutableNetwork executable_network = core.compile_model(model, device_name);

View File

@@ -277,18 +277,17 @@ int main(int argc, char* argv[]) {
// apply preprocessing // apply preprocessing
// clang-format off // clang-format off
using namespace ov::preprocess; model = ov::preprocess::PrePostProcessor(model)
model = PrePostProcessor(model)
// 1) InputInfo() with no args assumes a model has a single input // 1) InputInfo() with no args assumes a model has a single input
.input(InputInfo() .input(ov::preprocess::InputInfo()
// 2) Set input tensor information: // 2) Set input tensor information:
// - precision of tensor is supposed to be 'u8' // - precision of tensor is supposed to be 'u8'
// - layout of data is 'NHWC' // - layout of data is 'NHWC'
.tensor(InputTensorInfo() .tensor(ov::preprocess::InputTensorInfo()
.set_layout(tensor_layout) .set_layout(tensor_layout)
.set_element_type(element::u8)) .set_element_type(element::u8))
// 3) Here we suppose model has 'NCHW' layout for input // 3) Here we suppose model has 'NCHW' layout for input
.network(InputNetworkInfo() .network(ov::preprocess::InputNetworkInfo()
.set_layout("NCHW"))) .set_layout("NCHW")))
// 4) Once the build() method is called, the preprocessing steps // 4) Once the build() method is called, the preprocessing steps
// for layout and precision conversions are inserted automatically // for layout and precision conversions are inserted automatically