Skip to content

Commit

Permalink
Address reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
riverlijunjie committed Sep 12, 2023
1 parent 94ecdf3 commit 330989d
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 82 deletions.
3 changes: 0 additions & 3 deletions src/plugins/intel_cpu/src/compiled_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ class CompiledModel : public ov::ICompiledModel {
*/
GraphGuard::Lock GetGraph() const;

bool CanProcessDynBatch(const std::shared_ptr<ov::Model> &model) const;

ov::Any GetConfigLegacy(const std::string& name) const;
ov::Any get_metric(const std::string& name) const;
ov::Any get_metric_legacy(const std::string& name, const GraphGuard& graph) const;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class jit_uni_vcvtneps2bf16 : public jit_emitter {
h->vpermq(Ymm(aux.getIdx()), Ymm(aux.getIdx()), 0xD8); //11 01 10 00
h->vextracti128(out, Ymm(aux.getIdx()), 0);
} else {
h->pshufd(Xmm(aux.getIdx()), Xmm(aux.getIdx()), 0xD8); // 11 01 10 00
h->uni_vmovups(out, aux);
}
}
Expand Down
134 changes: 71 additions & 63 deletions src/plugins/intel_cpu/src/infer_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,76 +592,84 @@ void SyncInferRequest::init_tensor(const std::string& name) {
if (output != outMap.end()) {
if (m_outputs.find(name) == m_outputs.end()) {
auto output_port = m_output_ports_map.find(name);
OPENVINO_ASSERT(m_output_ports_map.find(name) != m_output_ports_map.end(),
"Tensor with name: ",
name,
" exists in CPU plugin graph, but absents in network outputs");
auto port = output_port->second;
const auto port_shape = port.get_partial_shape();
if (output_port != m_output_ports_map.end()) {
const auto& graph_shape = output->second->getInputShapeAtPort(0);
const auto& graph_shape = output->second->getInputShapeAtPort(0);

// WA, due to the transformations and constant folding, shape inference of the resulting model may
// have static shapes, while they are dynamic in the initial representation
const auto& shape = graph_shape.isDynamic() ? port_shape :
(port_shape.is_dynamic() ? graph_shape.toPartialShape() : port_shape);
// WA, due to the transformations and constant folding, shape inference of the resulting model may
// have static shapes, while they are dynamic in the initial representation
const auto& shape = graph_shape.isDynamic()
? port_shape
: (port_shape.is_dynamic() ? graph_shape.toPartialShape() : port_shape);

const bool isDynamic = shape.is_dynamic();
tensor = ov::ISyncInferRequest::get_tensor(port);

if (!tensor) {
ov::Shape tensor_shape;
if (isDynamic) {
const auto model_prec = InferenceEngine::details::convertPrecision(port.get_element_type());
const auto graph_prec = output->second->getParentEdgesAtPort(0)[0]->getMemory().getDesc().getPrecision();
OutputControlBlock control_block{model_prec, Shape{shape}};

DEBUG_LOG(name,
", tensor ", control_block.tensor(),
", memmngr ", control_block.tensor()->get_memory()->getMemoryMngr(),
"memory object ", control_block.tensor()->get_memory().get());

tensor = control_block.tensor();
if (model_prec == graph_prec) outputControlBlocks.emplace(std::make_pair(name, std::move(control_block)));
} else {
tensor_shape = shape.to_shape();

InferenceEngine::TensorDesc desc(InferenceEngine::details::convertPrecision(port.get_element_type()),
tensor_shape, InferenceEngine::TensorDesc::getLayoutByRank(tensor_shape.size()));
tensor = ov::make_tensor(port.get_element_type(), tensor_shape);
}
ov::ISyncInferRequest::set_tensor(port, tensor);
const bool isDynamic = shape.is_dynamic();
tensor = ov::ISyncInferRequest::get_tensor(port);

if (!tensor) {
ov::Shape tensor_shape;
if (isDynamic) {
const auto model_prec = InferenceEngine::details::convertPrecision(port.get_element_type());
const auto graph_prec =
output->second->getParentEdgesAtPort(0)[0]->getMemory().getDesc().getPrecision();
OutputControlBlock control_block{model_prec, Shape{shape}};

DEBUG_LOG(name,
", tensor ",
control_block.tensor(),
", memmngr ",
control_block.tensor()->get_memory()->getMemoryMngr(),
"memory object ",
control_block.tensor()->get_memory().get());

tensor = control_block.tensor();
if (model_prec == graph_prec)
outputControlBlocks.emplace(std::make_pair(name, std::move(control_block)));
} else {
const auto& blobDims = tensor->get_shape();
const bool isDynamic = port_shape.is_dynamic();
// Static shape case is enough information that shapes are incompatible to throw exception
// but in dynamic shape case we also need to handle following corner case:
// on tensor initialization stage we create empty tensor with dimensions equal 0
// so if we have tensor with all zero dimension we mustn't throw exception
if (!port_shape.compatible(ov::PartialShape(blobDims)) &&
(!isDynamic || static_cast<int64_t>(blobDims.size()) != port_shape.rank().get_length() ||
std::any_of(blobDims.begin(), blobDims.end(), [](const size_t& dims) {
return dims != 0;
}))) {
IE_THROW(ParameterMismatch)
<< "Network input and output use the same name: " << name
<< ", but expect tensors with different shapes. Input shape: " << ov::PartialShape(blobDims)
<< ", output shape: " << port_shape;
}

const auto netOutPrc = port.get_element_type();
if (netOutPrc != tensor->get_element_type()) {
IE_THROW(ParameterMismatch)
<< "Network input and output use the same name: " << name
<< " but expect blobs with different precision: " << tensor->get_element_type()
<< " for input and " << netOutPrc << " for output.";
}
}
m_outputs[name] = tensor;
auto desc = create_tensor_desc(tensor);
if (!port_shape.is_dynamic() && !external_ptr.count(name) &&
desc == MemoryDescUtils::convertToTensorDesc(
output->second->getParentEdgesAtPort(0)[0]->getMemory().getDesc())) {
external_ptr[name] = tensor;
tensor_shape = shape.to_shape();

InferenceEngine::TensorDesc desc(
InferenceEngine::details::convertPrecision(port.get_element_type()),
tensor_shape,
InferenceEngine::TensorDesc::getLayoutByRank(tensor_shape.size()));
tensor = ov::make_tensor(port.get_element_type(), tensor_shape);
}
ov::ISyncInferRequest::set_tensor(port, tensor);
} else {
OPENVINO_THROW("Tensor with name: ", name, " exists in CPU plugin graph, but absents in network outputs");
const auto& blobDims = tensor->get_shape();
const bool isDynamic = port_shape.is_dynamic();
// Static shape case is enough information that shapes are incompatible to throw exception
// but in dynamic shape case we also need to handle following corner case:
// on tensor initialization stage we create empty tensor with dimensions equal 0
// so if we have tensor with all zero dimension we mustn't throw exception
if (!port_shape.compatible(ov::PartialShape(blobDims)) &&
(!isDynamic || static_cast<int64_t>(blobDims.size()) != port_shape.rank().get_length() ||
std::any_of(blobDims.begin(), blobDims.end(), [](const size_t& dims) {
return dims != 0;
}))) {
IE_THROW(ParameterMismatch)
<< "Network input and output use the same name: " << name
<< ", but expect tensors with different shapes. Input shape: " << ov::PartialShape(blobDims)
<< ", output shape: " << port_shape;
}

const auto netOutPrc = port.get_element_type();
if (netOutPrc != tensor->get_element_type()) {
IE_THROW(ParameterMismatch)
<< "Network input and output use the same name: " << name
<< " but expect blobs with different precision: " << tensor->get_element_type()
<< " for input and " << netOutPrc << " for output.";
}
}
m_outputs[name] = tensor;
auto desc = create_tensor_desc(tensor);
if (!port_shape.is_dynamic() && !external_ptr.count(name) &&
desc == MemoryDescUtils::convertToTensorDesc(
output->second->getParentEdgesAtPort(0)[0]->getMemory().getDesc())) {
external_ptr[name] = tensor;
}
// update tensors in case of multiple output ports with the same name
for (const auto& out : get_outputs()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,6 @@ precisions_map Transformations::get_convert_precisions() {
return map;
}

void Transformations::RunPrecisionConvert() {
static const auto precisions = get_convert_precisions();
type_to_fuse_map type_to_fuse = {{ov::opset10::Convert::get_type_info_static(), fuse_type_to_convert}};

ov::pass::Manager manager;
CPU_REGISTER_PASS_COMMON(manager, ov::pass::InsertConvertAfterExtension);
CPU_REGISTER_PASS_COMMON(manager, ov::pass::ConvertPrecision, precisions, type_to_fuse, false, true);
manager.run_passes(model);
}

void Transformations::PreLpt(const std::vector<ov::element::Type>& defaultPrecisions, const bool isLegacyApi) {
CPU_DEBUG_CAP_TRANSFORMATION_SCOPE(this, PreLpt);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class Transformations {

void UpToLpt();
void CpuSpecificOpSet();
void RunPrecisionConvert();
void PostLpt();
void Snippets(void);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,19 @@ std::vector<std::string> disabledTestPatterns() {
R"(.*InferRequestIOBBlobTest.*canProcessDeallocatedOutputBlobAfterGetAndSetBlob.*)",
// Plugin version was changed to ov::Version
R"(.*VersionTest.*pluginCurrentVersionIsCorrect.*)",
// New plugin api + legacy ov api will put preprocess into transformation, which will add additional Convert
// node to graph, it cause below tests failure
// Issue: 120286
R"(.*smoke_Basic/FuseTransposeAndReorderTest.CompareWithRefs.*)",
// Issue: 113703 - input/output port's name maybe changed after transformation in plugin api 2.0
// Issue: 113703, 114763
R"(.*smoke_If/SimpleIfTest.*Cond=0.*)",
// Issue: JIT choose error issue, don't know why not choose jit_avx512_BF16
// Issue: 114765
R"(.*smoke_PSROIPoolingAverageLayoutTest/PSROIPoolingLayerCPUTest.*)",
R"(.*smoke_PSROIPoolingBilinearLayoutTest/PSROIPoolingLayerCPUTest.*)",
// TODO: for 22.2 (CVS-68949)
R"(.*smoke_AutoBatching_CPU/AutoBatching_Test_DetectionOutput.*)",
// Issue: 117837
R"(.*smoke_4D_out_of_range/GatherInPlaceLayerTestCPU.*_indices=\(\-15\).*)",
// Issue: 120279
R"(.*OVCompiledGraphImportExportTest.*elementType=(i16|u16|u32|u64).*)",
};

#if defined(OPENVINO_ARCH_X86)
Expand Down

0 comments on commit 330989d

Please sign in to comment.