[CPU] Enable brgconv primitives with binary post-ops by default on AVX512+ ISA (#16286)
This commit is contained in:
parent
613b66ba35
commit
16933efc06
@ -955,17 +955,6 @@ void Convolution::addLegacyZeroPoints(dnnl::primitive_attr& attr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool attrContainsAnyOfPostOps(const dnnl::primitive_attr& attr, std::initializer_list<dnnl::impl::primitive_kind_t> kinds) {
|
|
||||||
const auto ops = attr.get_post_ops();
|
|
||||||
|
|
||||||
for (const auto& kind : kinds) {
|
|
||||||
if (ops.get()->find(kind) != -1)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool attrContainsPostOp(const dnnl::primitive_attr& attr, const dnnl::impl::primitive_kind_t kind) {
|
static bool attrContainsPostOp(const dnnl::primitive_attr& attr, const dnnl::impl::primitive_kind_t kind) {
|
||||||
const auto ops = attr.get_post_ops();
|
const auto ops = attr.get_post_ops();
|
||||||
return ops.get()->find(kind) != -1;
|
return ops.get()->find(kind) != -1;
|
||||||
@ -1640,28 +1629,15 @@ void Convolution::appendZeroPointsArgs() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Due to performance issue, brgconv will only be enabled by default:
|
// brgconv will be enabled by default:
|
||||||
// 1, static shape(dynamic shape may change weights layout if the input shape changes and cause performance issue: 86948)
|
// 1, static shape(dynamic shape may change weights layout if the input shape changes and cause performance issue: 86948)
|
||||||
// 2, support amx except having input zero point.
|
// 2, hw supports avx512+
|
||||||
// 3, support avx512 without legacy postops/per channel zero point when avx512
|
|
||||||
void Convolution::initTryBrgconvFlag() {
|
void Convolution::initTryBrgconvFlag() {
|
||||||
if (isDynamicNode())
|
if (isDynamicNode())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core_amx)) {
|
if (dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core)) {
|
||||||
shouldTryBrgconv = true;
|
shouldTryBrgconv = true;
|
||||||
} else if (dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core)) {
|
|
||||||
shouldTryBrgconv = true;
|
|
||||||
// should remove after binary postops performance issue resolved
|
|
||||||
// heuristics: if it's avx512 ISA model && it doesn't have binary post ops or per channel zero point.
|
|
||||||
dnnl::primitive_attr attr;
|
|
||||||
DEBUG_LOG("setPostOps, useLegacyPostOps=false");
|
|
||||||
setPostOps(attr, outputStaticShape(), false);
|
|
||||||
|
|
||||||
if (attrContainsPostOp(attr, dnnl::impl::primitive_kind::binary) &&
|
|
||||||
attrContainsAnyOfPostOps(attr, {dnnl::impl::primitive_kind::eltwise})) {
|
|
||||||
shouldTryBrgconv = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary debug functionality to be able to force brgconv for any model
|
// Temporary debug functionality to be able to force brgconv for any model
|
||||||
|
Loading…
Reference in New Issue
Block a user