Skip to content

Commit 0ab7dfa

Browse files
hyunbackrnugmanx
authored and
rnugmanx
committed
[IE CLDNN] Use single primitive reduce when axis=1(feature) (openvinotoolkit#4548)
1 parent 6142850 commit 0ab7dfa

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

inference-engine/src/cldnn_engine/cldnn_engine.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,8 @@ cldnn::device_info clDNNEngine::GetDeviceInfo(const std::map<std::string, std::s
134134
template<typename T>
135135
static bool disableReduceDecomposition(const std::shared_ptr<const ngraph::Node> node) {
136136
if (auto op = std::dynamic_pointer_cast<const T>(node)) {
137-
auto reduction_axes = op->get_reduction_axes().to_vector();
138-
bool reduce_along_f = op->get_reduction_axes().size() == 1 && std::count(reduction_axes.begin(), reduction_axes.end(), 1) != 0;
139137
bool fp16_batch_not_1 = op->get_element_type() == ngraph::element::f16 && op->input(0).get_shape()[0] != 1;
140-
bool can_use_reduce = !reduce_along_f && !fp16_batch_not_1;
141-
return can_use_reduce;
138+
return !fp16_batch_not_1;
142139
}
143140
return false;
144141
}

inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/resample/resample_kernel_opt.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ ParamsKey ResampleKernelOpt::GetSupportedKey() const {
2222
ParamsKey k;
2323
k.EnableInputDataType(Datatype::F16);
2424
k.EnableInputDataType(Datatype::F32);
25+
k.EnableInputDataType(Datatype::UINT8);
26+
k.EnableInputDataType(Datatype::INT8);
2527
k.EnableOutputDataType(Datatype::F16);
2628
k.EnableOutputDataType(Datatype::F32);
2729
k.EnableOutputDataType(Datatype::UINT8);
@@ -84,6 +86,11 @@ bool ResampleKernelOpt::Validate(const Params& p, const optional_params& o) cons
8486

8587
const auto& input = params.inputs[0];
8688

89+
if ((input.GetDType() == Datatype::UINT8 || input.GetDType() == Datatype::INT8) &&
90+
params.resampleType != ResampleType::NEAREST_NEIGHBOR &&
91+
params.resampleType != ResampleType::BILINEAR_INTERP)
92+
return false;
93+
8794
if (input.GetLayout() != DataLayout::fs_b_yx_fsv32 && input.GetLayout() != DataLayout::b_fs_yx_fsv16)
8895
return false;
8996

inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/reduce_gpu_b_fs_yx_fsv16.cl

+3-3
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ uint offset = batch_out * input_batch_pitch + ((feature_out + FSV - 1) / FSV) *
256256
for (uint yi = y_out; yi < y_max_val; ++yi) {
257257
for (uint xi = x_out; xi < x_max_val; ++xi) {
258258
INPUT_VEC input = (INPUT_VEC)(INPUT_INIT_VAL);
259-
#if (REDUCE_MAX_MODE || REDUCE_MIN_MODE || REDUCE_PROD_MODE || REDUCE_AND_MODE || REDUCE_LOG_SUM_EXP_MODE) && REDUCE_FEATURE && (INPUT0_FEATURE_NUM % FSV != 0)
259+
#if REDUCE_FEATURE && (INPUT0_FEATURE_NUM % FSV != 0)
260260
if (fi + FSV <= INPUT0_FEATURE_NUM)
261261
input = BLOCK_READ(data, offset);
262262
else
@@ -273,7 +273,7 @@ uint offset = batch_out * input_batch_pitch + ((feature_out + FSV - 1) / FSV) *
273273
#if INPUT0_SIZE_X % READ_OFFSET != 0
274274
for (uint xi = x_leftover_start; xi < x_leftover_end; ++xi) {
275275
INPUT0_TYPE leftovers = INIT_VAL;
276-
#if (REDUCE_MAX_MODE || REDUCE_MIN_MODE || REDUCE_PROD_MODE || REDUCE_AND_MODE || REDUCE_LOG_SUM_EXP_MODE) && REDUCE_FEATURE && (INPUT0_FEATURE_NUM % FSV != 0)
276+
#if REDUCE_FEATURE && (INPUT0_FEATURE_NUM % FSV != 0)
277277
if (fi + FSV <= INPUT0_FEATURE_NUM)
278278
leftovers = DT_INPUT_BLOCK_READ(data, offset);
279279
else
@@ -341,7 +341,7 @@ uint offset = batch_out * input_batch_pitch + ((feature_out + FSV - 1) / FSV) *
341341
for (uint yi = y_out; yi < y_max_val; ++yi) {
342342
for (uint xi = x_out; xi < x_max_val; ++xi) {
343343
INPUT_VEC input = (INPUT_VEC)(INPUT_INIT_VAL);
344-
#if (REDUCE_MAX_MODE || REDUCE_MIN_MODE || REDUCE_PROD_MODE || REDUCE_AND_MODE || REDUCE_LOG_SUM_EXP_MODE) && REDUCE_FEATURE && (INPUT0_FEATURE_NUM % FSV != 0)
344+
#if REDUCE_FEATURE && (INPUT0_FEATURE_NUM % FSV != 0)
345345
if (fi + FSV <= INPUT0_FEATURE_NUM)
346346
input = BLOCK_READ(data, offset);
347347
else

0 commit comments

Comments
 (0)