}
void ngraph::op::GenericIE::validate_and_infer_types() {
- // Try to find extension with shape inference inplementation and apply it
+ // This function returns precision based on existing precision and
+ // precision that was set in outputs vector
+ auto get_precision = [this](const size_t index) -> element::Type {
+ if (index >= get_output_size() ||
+ get_output_element_type(index) == element::dynamic ||
+ get_output_element_type(index) == element::undefined) {
+ return InferenceEngine::details::convertPrecision(outputs[index].precision);
+ }
+ return get_output_element_type(index);
+ };
+ // Try to find extension with shape inference implementation and apply it
for (const auto& ext : extensions) {
IE_SUPPRESS_DEPRECATED_START
InferenceEngine::IShapeInferImpl::Ptr impl;
if (!this_input_shape.is_static()) {
// Set dynamic output shapes if input shapes are not defined
- for (size_t i = 0; i < outputs.size(); i++) {
- const auto& port = outputs[i];
- auto type = InferenceEngine::details::convertPrecision(port.precision);
- set_output_type(i, type, PartialShape::dynamic());
+ for (size_t output_index = 0; output_index < outputs.size(); output_index++) {
+ set_output_type(output_index, get_precision(output_index), PartialShape::dynamic());
}
return;
}
if (ret != InferenceEngine::StatusCode::OK || outShapes.size() != outputs.size()) continue;
- for (size_t i = 0; i < outputs.size(); i++) {
- const auto& port = outputs[i];
- ngraph::Shape outShape(outShapes[i]);
- auto type = InferenceEngine::details::convertPrecision(port.precision);
- set_output_type(i, type, PartialShape(outShape));
+ for (size_t output_index = 0; output_index < outputs.size(); output_index++) {
+ set_output_type(output_index, get_precision(output_index), Shape(outShapes[output_index]));
}
-
return;
}
if (initialized < 1) {
if (outputs.size())
set_output_size(outputs.size());
- for (size_t i = 0; i < outputs.size(); i++) {
- const auto& port = outputs[i];
- ngraph::Shape outShape(port.dims);
- auto type = InferenceEngine::details::convertPrecision(port.precision);
- set_output_type(i, type, PartialShape(outShape));
+ for (size_t output_index = 0; output_index < outputs.size(); output_index++) {
+ set_output_type(output_index, get_precision(output_index), Shape(outputs[output_index].dims));
}
initialized++;
} else if (reshape) {
break;
}
- // If node type in map and convert can be fused into node we skip Convert creation
+ // Check that node type exists in map and we can fuse type into node
if (type_to_fuse.count(node->get_type_info()) &&
type_to_fuse.at(node->get_type_info())(node, m_to, output.get_index())) {
+ // We need to break if original node was replaced
break;
}
}
bool fuse_type_to_generic_ie(std::shared_ptr<ngraph::Node> & node, ngraph::element::Type to, size_t idx) {
node->set_output_type(idx, to, node->output(idx).get_partial_shape());
- return true;
+ // return false as we do not replace original node
+ return false;
}
bool fuse_type_to_shapeof_v0(std::shared_ptr<ngraph::Node> & node, ngraph::element::Type to, size_t idx) {