From e6af0f88a65448b043d5d7d8876a8d13c54bdd75 Mon Sep 17 00:00:00 2001 From: Yury Gaydaychuk Date: Fri, 30 Jul 2021 15:09:00 +0300 Subject: [PATCH] ... --- .../nodes/mkldnn_def_conv_node.cpp | 49 +++++++++++-------- .../nodes/mkldnn_def_conv_node.h | 1 + 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_def_conv_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_def_conv_node.cpp index 81c64c0a0cd23e..18cf7f42811c33 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_def_conv_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_def_conv_node.cpp @@ -966,6 +966,12 @@ void MKLDNNDeformableConvolutionNode::initSupportedPrimitiveDescriptors() { if (!supportedPrimitiveDescriptors.empty()) return; + const int simd_w = mayiuse(cpu::x64::avx512_common) ? 16 : 8; + if (group != 1 && (((getParentEdgeAt(0)->getDims()[1] / group) % simd_w != 0) + || ((getChildEdgeAt(0)->getDims()[1] / group) % simd_w != 0))) { + enforceRef = true; + } + size_t inputsNumber = getOriginalInputsNumber(); InferenceEngine::LayerConfig config; config.dynBatchSupport = false; @@ -986,19 +992,20 @@ void MKLDNNDeformableConvolutionNode::initSupportedPrimitiveDescriptors() { config.outConfs[0].inPlace = -1; impl_desc_type impl_type; -// if (mayiuse(cpu::x64::avx512_common)) { -// impl_type = impl_desc_type::jit_avx512; -// } else if (mayiuse(cpu::x64::avx2)) { -// impl_type = impl_desc_type::jit_avx2; -// } else if (mayiuse(cpu::x64::sse41)) { -// impl_type = impl_desc_type::jit_sse42; -// } else { -// impl_type = impl_desc_type::ref; -// } - impl_type = impl_desc_type::ref; - - if (false && mayiuse(cpu::x64::sse41)) { - // optimzed implementation + if (enforceRef) { + impl_type = impl_desc_type::ref; + } else if (mayiuse(cpu::x64::avx512_common)) { + impl_type = impl_desc_type::jit_avx512; + } else if (mayiuse(cpu::x64::avx2)) { + impl_type = impl_desc_type::jit_avx2; + } else if (mayiuse(cpu::x64::sse41)) { + impl_type = impl_desc_type::jit_sse42; + } else { + impl_type = impl_desc_type::ref; + } + + if (!enforceRef && mayiuse(cpu::x64::sse41)) { + // optimized implementation auto dataFormat = memory::format_tag::nhwc; auto offFormat = memory::format_tag::nchw; auto weiFormat = group > 1 ? mayiuse(avx512_common) ? memory::format_tag::gOIhw16i16o : memory::format_tag::gOIhw8i8o @@ -1097,13 +1104,15 @@ void MKLDNNDeformableConvolutionNode::createPrimitive() { jcp.nthr = dnnl_get_max_threads(); -// if (mayiuse(cpu::x64::avx512_common)) { -// def_conv_kernel.reset(new jit_uni_def_conv_kernel_f32(jcp)); -// } else if (mayiuse(cpu::x64::avx2)) { -// def_conv_kernel.reset(new jit_uni_def_conv_kernel_f32(jcp)); -// } else if (mayiuse(cpu::x64::sse41)) { -// def_conv_kernel.reset(new jit_uni_def_conv_kernel_f32(jcp)); -// } + if (enforceRef) { + return; + } else if (mayiuse(cpu::x64::avx512_common)) { + def_conv_kernel.reset(new jit_uni_def_conv_kernel_f32(jcp)); + } else if (mayiuse(cpu::x64::avx2)) { + def_conv_kernel.reset(new jit_uni_def_conv_kernel_f32(jcp)); + } else if (mayiuse(cpu::x64::sse41)) { + def_conv_kernel.reset(new jit_uni_def_conv_kernel_f32(jcp)); + } if (def_conv_kernel) def_conv_kernel->create_ker(); diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_def_conv_node.h b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_def_conv_node.h index 5ffaff1fb3a316..d71946f77a3b51 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_def_conv_node.h +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_def_conv_node.h @@ -79,6 +79,7 @@ class MKLDNNDeformableConvolutionNode : public MKLDNNNode { bool canBeInPlace() const override { return false; } + bool enforceRef = false; InferenceEngine::Precision getRuntimePrecision() const override;