[IE CLDNN] Reduce performance drop fix (#2065)

This commit is contained in:
Mikołaj Życzyński 2020-09-05 09:11:00 +02:00 committed by GitHub
parent b3e69f1f7d
commit ad2ed5b480
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,20 +88,27 @@ InferenceEngine::ICNNNetwork::Ptr clDNNEngine::CloneAndTransformNetwork(const In
}
// Reduce node implementation with reduce along features performs better with Reshape->Pooling->Reshape pattern
// Reshape->Pooling->Reshape scenario is also more optimal in case when batch > 1 and network precission is FP16
if (auto redOp = std::dynamic_pointer_cast<const ::ngraph::opset1::ReduceMean>(node)) {
auto reduction_axes = redOp->get_reduction_axes().to_vector();
bool reduce_along_f = redOp->get_reduction_axes().size() == 1 && std::count(reduction_axes.begin(), reduction_axes.end(), 1) != 0;
return !reduce_along_f;
bool fp16_batch_not_1 = redOp->get_element_type() == ngraph::element::f16 && redOp->input(0).get_shape()[0] != 1;
bool can_use_reduce = !reduce_along_f && !fp16_batch_not_1;
return can_use_reduce;
}
if (auto redOp = std::dynamic_pointer_cast<const ::ngraph::opset1::ReduceMax>(node)) {
auto reduction_axes = redOp->get_reduction_axes().to_vector();
bool reduce_along_f = redOp->get_reduction_axes().size() == 1 && std::count(reduction_axes.begin(), reduction_axes.end(), 1) != 0;
return !reduce_along_f;
bool fp16_batch_not_1 = redOp->get_element_type() == ngraph::element::f16 && redOp->input(0).get_shape()[0] != 1;
bool can_use_reduce = !reduce_along_f && !fp16_batch_not_1;
return can_use_reduce;
}
if (auto redOp = std::dynamic_pointer_cast<const ::ngraph::opset1::ReduceSum>(node)) {
auto reduction_axes = redOp->get_reduction_axes().to_vector();
bool reduce_along_f = redOp->get_reduction_axes().size() == 1 && std::count(reduction_axes.begin(), reduction_axes.end(), 1) != 0;
return !reduce_along_f;
bool fp16_batch_not_1 = redOp->get_element_type() == ngraph::element::f16 && redOp->input(0).get_shape()[0] != 1;
bool can_use_reduce = !reduce_along_f && !fp16_batch_not_1;
return can_use_reduce;
}
return std::dynamic_pointer_cast<const ::ngraph::opset2::Gelu>(node) ||