Skip to content

Commit

Permalink
Remove custom binary PReLU post op
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnick committed Apr 10, 2024
1 parent e0e3ec4 commit aa8e214
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 50 deletions.
44 changes: 0 additions & 44 deletions src/plugins/intel_cpu/src/dnnl_extension_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,50 +222,6 @@ const char* DnnlExtensionUtils::query_pd_info(const_dnnl_primitive_desc_t pd) {
return pd->info();
}

dnnl::algorithm DnnlExtensionUtils::convertToDnnlAlgorithm(Algorithm alg) {
switch (alg) {
case Algorithm::EltwiseRelu: return dnnl::algorithm::eltwise_relu;
case Algorithm::EltwiseTanh: return dnnl::algorithm::eltwise_tanh;
case Algorithm::EltwiseElu: return dnnl::algorithm::eltwise_elu;
case Algorithm::EltwiseAbs: return dnnl::algorithm::eltwise_abs;
case Algorithm::EltwiseSqrt: return dnnl::algorithm::eltwise_sqrt;
case Algorithm::EltwiseSwish: return dnnl::algorithm::eltwise_swish;
case Algorithm::EltwiseHswish: return dnnl::algorithm::eltwise_hardswish;
case Algorithm::EltwiseSoftRelu: return dnnl::algorithm::eltwise_soft_relu;
case Algorithm::EltwiseMish: return dnnl::algorithm::eltwise_mish;
case Algorithm::EltwiseExp: return dnnl::algorithm::eltwise_exp;
case Algorithm::EltwiseGeluErf: return dnnl::algorithm::eltwise_gelu_erf;
case Algorithm::EltwiseGeluTanh: return dnnl::algorithm::eltwise_gelu_tanh;
case Algorithm::EltwiseSigmoid: return dnnl::algorithm::eltwise_logistic;
case Algorithm::EltwiseClamp: return dnnl::algorithm::eltwise_clip;
case Algorithm::EltwisePowerStatic: return dnnl::algorithm::eltwise_pow;
case Algorithm::EltwiseHsigmoid: return dnnl::algorithm::eltwise_hsigmoid;
case Algorithm::EltwiseRoundHalfToEven: return dnnl::algorithm::eltwise_round_half_to_even;
case Algorithm::EltwiseRoundHalfAwayFromZero: return dnnl::algorithm::eltwise_round_half_away_from_zero;
case Algorithm::EltwiseAdd: return dnnl::algorithm::binary_add;
case Algorithm::EltwiseMultiply: return dnnl::algorithm::binary_mul;
case Algorithm::EltwiseSubtract: return dnnl::algorithm::binary_sub;
case Algorithm::EltwiseDivide: return dnnl::algorithm::binary_div;
case Algorithm::EltwiseMaximum: return dnnl::algorithm::binary_max;
case Algorithm::EltwiseMinimum: return dnnl::algorithm::binary_min;
case Algorithm::EltwiseEqual: return dnnl::algorithm::binary_eq;
case Algorithm::EltwiseNotEqual: return dnnl::algorithm::binary_ne;
case Algorithm::EltwiseGreater: return dnnl::algorithm::binary_gt;
case Algorithm::EltwiseGreaterEqual: return dnnl::algorithm::binary_ge;
case Algorithm::EltwiseLess: return dnnl::algorithm::binary_lt;
case Algorithm::EltwiseLessEqual: return dnnl::algorithm::binary_le;
case Algorithm::EltwisePrelu: return dnnl::algorithm::binary_prelu;
case Algorithm::ReduceMax: return dnnl::algorithm::reduction_max;
case Algorithm::ReduceMin: return dnnl::algorithm::reduction_min;
case Algorithm::ReduceSum: return dnnl::algorithm::reduction_sum;
case Algorithm::ReduceMean: return dnnl::algorithm::reduction_mean;
case Algorithm::FQCommon: return dnnl::algorithm::quantization_quantize_dequantize;
case Algorithm::FQQuantization: return dnnl::algorithm::quantization_quantize;
case Algorithm::FQBinarization: return dnnl::algorithm::binarization_depthwise;
default: return dnnl::algorithm::undef;
}
}

bool DnnlExtensionUtils::isUnarySupportedAsPostOp(Algorithm alg) {
#if defined(OV_CPU_WITH_ACL)
return one_of(alg, Algorithm::EltwiseRelu,
Expand Down
1 change: 0 additions & 1 deletion src/plugins/intel_cpu/src/dnnl_extension_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class DnnlExtensionUtils {
static dnnl_primitive_desc_t clone_primitive_desc(const_dnnl_primitive_desc_t cprim_desc);
static dnnl_memory_desc_t clone_desc(const_dnnl_memory_desc_t cdesc);
static const char* query_pd_info(const_dnnl_primitive_desc_t pd);
static dnnl::algorithm convertToDnnlAlgorithm(Algorithm alg);
static bool isUnarySupportedAsPostOp(Algorithm alg);
};

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/intel_cpu/src/dnnl_postops_composer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,7 @@ bool DnnlPostOpsComposer::appendScale(const std::vector<float>& scale, bool isLa
// prelu(x)*s = prelu(x*s)
if (ops.len() == 1) {
auto& cur_op = ops.get()->entry_[0];
if ((cur_op.kind == dnnl::impl::primitive_kind::eltwise && cur_op.eltwise.alg == dnnl_eltwise_relu) ||
(cur_op.kind == dnnl::impl::primitive_kind::binary && cur_op.binary.alg == dnnl_binary_prelu)) {
if (cur_op.is_relu(false, false) || cur_op.is_prelu()) {
fuseIntoWeiScale = true;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/intel_cpu/src/dnnl_postops_composer_legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ bool DnnlPostOpsComposerLegacy::appendScale(const std::vector<float>& scale, boo
// prelu(x)*s = prelu(x*s)
if (ops.len() == 1) {
auto& cur_op = ops.get()->entry_[0];
if ((cur_op.kind == dnnl::impl::primitive_kind::eltwise && cur_op.eltwise.alg == dnnl_eltwise_relu) ||
(cur_op.kind == dnnl::impl::primitive_kind::binary && cur_op.binary.alg == dnnl_binary_prelu)) {
if (cur_op.is_relu(false, false) || cur_op.is_prelu()) {
fuseIntoWeiScale = true;
}
}
Expand Down

0 comments on commit aa8e214

Please sign in to comment.