[IE CLDNN] Disabled vectorized ocl path for modes with bool output (#5521)
This commit is contained in:
parent
fa4a67ab25
commit
30b9d2ba13
@ -246,6 +246,9 @@ bool EltwiseKernel_b_fs_yx_fsv16::Validate(const Params& p, const optional_param
|
||||
if (count % 8 != 0)
|
||||
return false;
|
||||
|
||||
if (IsUnsupportedModeForVecCode(params))
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < params.inputs.size(); i++) {
|
||||
if ((params.inputs[i].GetLayout() != DataLayout::b_fs_yx_fsv16) &&
|
||||
(params.inputs[i].GetLayout() != DataLayout::b_fs_zyx_fsv16) &&
|
||||
|
@ -108,6 +108,34 @@ bool EltwiseKernelBase::Validate(const Params& p, const optional_params& o) cons
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EltwiseKernelBase::IsUnsupportedModeForVecCode(const eltwise_params& params) const {
|
||||
// These modes are supposed to produce BOOL output type
|
||||
// but this kernel uses vector data types, and these operation will produce 0xFFFF / 0x0000 instead of 0 / 1 values
|
||||
// The value might be then converted to fp16/fp32 and used for some arithmetic, which will lead to invalid results, thus reject these modes
|
||||
// to fallback on ref kernel with scalar types.
|
||||
// TODO: Consider updating optimized kernels to produce 0/1 output for vector code if such operation is a bottleneck in some model
|
||||
const std::vector<EltwiseMode> unsupported_modes = {
|
||||
EltwiseMode::EQ,
|
||||
EltwiseMode::NE,
|
||||
EltwiseMode::LT,
|
||||
EltwiseMode::LE,
|
||||
EltwiseMode::GT,
|
||||
EltwiseMode::GE,
|
||||
EltwiseMode::LOGIC_AND,
|
||||
EltwiseMode::LOGIC_OR,
|
||||
EltwiseMode::LOGIC_XOR,
|
||||
EltwiseMode::FLOOR_MOD,
|
||||
};
|
||||
|
||||
for (size_t op_num = 0; op_num < params.operations.size(); op_num++) {
|
||||
const auto& ew = params.operations[op_num];
|
||||
if (std::find(unsupported_modes.begin(), unsupported_modes.end(), ew.mode) != unsupported_modes.end())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
JitConstants EltwiseKernelBase::GetOperationsJitConstants(const eltwise_params& params, bool useVload8, size_t blockSize) const {
|
||||
JitConstants jit = {};
|
||||
for (size_t op_num = 0; op_num < params.operations.size(); op_num++) {
|
||||
|
@ -119,5 +119,7 @@ protected:
|
||||
virtual DispatchData SetDefault(const eltwise_params& params) const;
|
||||
KernelsData GetCommonKernelsData(const Params& params, const optional_params& options) const;
|
||||
Datatype GetAccumulatorType(const eltwise_params ¶ms) const;
|
||||
|
||||
bool IsUnsupportedModeForVecCode(const eltwise_params& params) const;
|
||||
};
|
||||
} // namespace kernel_selector
|
||||
|
@ -58,6 +58,9 @@ bool EltwiseKernel_fs_b_yx_fsv32::Validate(const Params& params, const optional_
|
||||
}
|
||||
}
|
||||
|
||||
if (IsUnsupportedModeForVecCode(ewParams))
|
||||
return false;
|
||||
|
||||
if (!bCheckSizes || !bSupportedCount || !bCheckUpdateInput || !bCheckUseOutput) {
|
||||
return false;
|
||||
}
|
||||
|
@ -73,6 +73,9 @@ bool EltwiseKernel_vload8::Validate(const Params& params, const optional_params&
|
||||
}
|
||||
}
|
||||
|
||||
if (IsUnsupportedModeForVecCode(ewParams))
|
||||
return false;
|
||||
|
||||
if (!bCheckSizes || !bSupportedCount || !bCheckUpdateInput || !bCheckUseOutput) {
|
||||
return false;
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ T eltwise_execute(cldnn::eltwise_mode mode, T x, T y) {
|
||||
return std::pow((float)x, (float)y);
|
||||
case eltwise_mode::mod:
|
||||
return std::fmod((float)x, (float)y);
|
||||
case eltwise_mode::eq:
|
||||
return (float)((float)x == (float)y);
|
||||
default:
|
||||
return (T)0;
|
||||
}
|
||||
@ -3540,6 +3542,7 @@ struct eltwise_layout_test_params {
|
||||
#define CASE_ELTWISE_TEST6 eltwise_mode::sum, {4, 1, 4, 4}, {1, 5, 1, 1}, format::bfyx, format::b_fs_yx_fsv16, "generic_eltwise_ref"
|
||||
#define CASE_ELTWISE_TEST7 eltwise_mode::sum, {4, 5, 4, 1}, {4, 1, 4, 1}, format::bfyx, format::b_fs_yx_fsv16, "generic_eltwise_ref"
|
||||
#define CASE_ELTWISE_TEST8 eltwise_mode::sum, {4, 2, 4, 4}, {1, 1, 1, 1}, format::bfyx, format::b_fs_yx_fsv16, "generic_eltwise_ref"
|
||||
#define CASE_ELTWISE_TEST9 eltwise_mode::eq, {4, 2, 4, 4}, {1, 1, 1, 1}, format::b_fs_yx_fsv16, format::bfyx, "generic_eltwise_ref"
|
||||
|
||||
class eltwise_layout_test : public BaseEltwiseTest<eltwise_layout_test_params> {
|
||||
};
|
||||
@ -3619,4 +3622,5 @@ INSTANTIATE_TEST_CASE_P(eltwise, eltwise_test_mixed_layout,
|
||||
eltwise_layout_test_params{CASE_ELTWISE_TEST6},
|
||||
eltwise_layout_test_params{CASE_ELTWISE_TEST7},
|
||||
eltwise_layout_test_params{CASE_ELTWISE_TEST8},
|
||||
eltwise_layout_test_params{CASE_ELTWISE_TEST9},
|
||||
}), );
|
||||
|
Loading…
Reference in New Issue
Block a user