Skip to content

Commit 489b028

Browse files
committed
more tests, enabled fusing quantize
1 parent b7fab5d commit 489b028

File tree

3 files changed

+78
-6
lines changed

3 files changed

+78
-6
lines changed

src/plugins/intel_gpu/src/kernel_selector/cl_kernels/resample_pil_ref.cl

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ KERNEL (calculate_coefficients_gpu_ref)(__global float* coefficients, __global i
5858
ww += w;
5959
}
6060
for (x = 0; x < xmax; x++) {
61-
if (ww != 0.0) {
61+
if (ww != 0.0f) {
6262
k[x] /= ww;
6363
}
6464
}
@@ -72,10 +72,16 @@ KERNEL (calculate_coefficients_gpu_ref)(__global float* coefficients, __global i
7272

7373
#elif RESAMPLE_PILLOW_STAGE == STAGE_RESAMPLE_HORIZONTAL
7474

75+
#if ENABLE_VERTICAL_PASS
76+
#define RESAMPLE_HORIZONTAL_OUTPUT_TYPE INTERMEDIATE_BUF_TYPE
77+
#else
78+
#define RESAMPLE_HORIZONTAL_OUTPUT_TYPE OUTPUT_TYPE
79+
#endif
80+
7581
KERNEL (resample_horizontal_gpu_ref)( __global INPUT0_TYPE* input
7682
, __global float* coefficients
7783
, __global int* bounds
78-
, __global OUTPUT_TYPE* output
84+
, __global RESAMPLE_HORIZONTAL_OUTPUT_TYPE* output
7985
#if HAS_FUSED_OPS_DECLS
8086
, FUSED_OPS_DECLS
8187
#endif
@@ -97,7 +103,7 @@ KERNEL (resample_horizontal_gpu_ref)( __global INPUT0_TYPE* input
97103
#endif
98104
int horizontal_min, horizontal_max;
99105
float* k;
100-
OUTPUT_TYPE ss = 0.f;
106+
ACCUMULATOR_TYPE ss = 0.f;
101107
#if BATCH_IS_HORIZONTAL_AXIS == 1
102108
horizontal_min = bounds[b * 2 + 0];
103109
horizontal_max = bounds[b * 2 + 1];
@@ -157,7 +163,13 @@ KERNEL (resample_horizontal_gpu_ref)( __global INPUT0_TYPE* input
157163

158164
#else // RESAMPLE_PILLOW_STAGE == STAGE_RESAMPLE_VERTICAL
159165

160-
KERNEL (resample_vertical_gpu_ref)( __global INPUT0_TYPE* input
166+
#if ENABLE_HORIZONTAL_PASS
167+
#define RESAMPLE_VERTICAL_INPUT_TYPE INTERMEDIATE_BUF_TYPE
168+
#else
169+
#define RESAMPLE_VERTICAL_INPUT_TYPE INPUT0_TYPE
170+
#endif
171+
172+
KERNEL (resample_vertical_gpu_ref)( __global RESAMPLE_VERTICAL_INPUT_TYPE* input
161173
, __global float* coefficients
162174
, __global int* bounds
163175
, __global OUTPUT_TYPE* output
@@ -194,7 +206,7 @@ KERNEL (resample_vertical_gpu_ref)( __global INPUT0_TYPE* input
194206
vertical_max = bounds[x * 2 + 1];
195207
#endif
196208

197-
OUTPUT_TYPE ss = 0.f;
209+
ACCUMULATOR_TYPE ss = 0.f;
198210
for (int vertical_dim = 0; vertical_dim < vertical_max; vertical_dim++) {
199211
#if ENABLE_HORIZONTAL_PASS
200212

@@ -254,3 +266,9 @@ KERNEL (resample_vertical_gpu_ref)( __global INPUT0_TYPE* input
254266
#endif
255267

256268
#undef PILLOW_SUPPORT
269+
#ifdef RESAMPLE_HORIZONTAL_OUTPUT_TYPE
270+
#undef RESAMPLE_HORIZONTAL_OUTPUT_TYPE
271+
#endif
272+
#ifdef RESAMPLE_VERTICAL_INPUT_TYPE
273+
#undef RESAMPLE_VERTICAL_INPUT_TYPE
274+
#endif

src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_pil_ref.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ DataTensor GetIntermediateBufferSize(const resample_params& params) {
122122
OPENVINO_ASSERT(channelIndex >= 0, "Invalid layout channel index");
123123

124124
dims[channelIndex] = ybox_last - ybox_first;
125-
DataTensor result{dims, output.GetDType(), layout};
125+
DataTensor result{dims, Datatype::F32, layout};
126126
return result;
127127
}
128128

@@ -134,6 +134,8 @@ ParamsKey ResampleKernelPilRef::GetSupportedKey() const {
134134
k.EnableInputDataType(Datatype::F32);
135135
k.EnableOutputDataType(Datatype::F16);
136136
k.EnableOutputDataType(Datatype::F32);
137+
k.EnableOutputDataType(Datatype::UINT8);
138+
k.EnableOutputDataType(Datatype::INT8);
137139
k.EnableDifferentTypes();
138140
k.EnableAllInputLayout();
139141
k.EnableAllOutputLayout();
@@ -281,6 +283,7 @@ JitConstants ResampleKernelPilRef::GetJitConstantsForKernel(KernelId id, const r
281283
MakeJitConstant("STAGE_CALC_VERTICAL_COEFFICIENTS", static_cast<int>(eCalcVerticalCoefficients)),
282284
MakeJitConstant("STAGE_RESAMPLE_VERTICAL", static_cast<int>(eResampleVertical)),
283285
});
286+
jit_constants.Merge(MakeTypeJitConstants(GetAccumulatorType(params), "ACCUMULATOR"));
284287
switch (id) {
285288
case eCalcHorizontalCoefficients: {
286289
auto inputHorizontalSizeWithPadding = getInputHorizontalSize(params, true);

src/plugins/intel_gpu/tests/unit/fusions/resample_fusion_test.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,3 +473,54 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, resample_bicubic_pillow_axes_scale_activat
473473
resample_axes_test_params{ CASE_RESAMPLE_BICUBIC_PILLOW_AXES_1, RESAMPLE_BICUBIC_PILLOW_AXES_SCALE_ACTIVATION_ELTWISE_CNT },
474474
resample_axes_test_params{ CASE_RESAMPLE_BICUBIC_PILLOW_AXES_2, RESAMPLE_BICUBIC_PILLOW_AXES_SCALE_ACTIVATION_ELTWISE_CNT },
475475
}));
476+
477+
class resample_bicubic_pillow_axes_activation : public ResampleAxesPrimitiveFusingTest {};
478+
TEST_P(resample_bicubic_pillow_axes_activation, basic) {
479+
auto p = GetParam();
480+
auto sizes = get_sizes_for_axes(p);
481+
create_topologies(
482+
input_layout("input", get_input_layout(p)),
483+
resample("resample_prim", input_info("input"), sizes, {}, p.axes, {}, {}, 0, -0.75f,
484+
p.type, resample::InterpolateOp::ShapeCalcMode::SIZES),
485+
activation("activation", input_info("resample_prim"), activation_func::abs),
486+
reorder("reorder_bfyx", input_info("activation"), p.default_format, data_types::f32)
487+
);
488+
489+
tolerance = 1e-2f;
490+
execute(p);
491+
}
492+
493+
#define RESAMPLE_BICUBIC_PILLOW_AXES_ACTIVATION_CNT 2, 3
494+
INSTANTIATE_TEST_SUITE_P(fusings_gpu, resample_bicubic_pillow_axes_activation,
495+
::testing::ValuesIn(std::vector<resample_axes_test_params>{
496+
resample_axes_test_params{ CASE_RESAMPLE_BICUBIC_PILLOW_AXES_1, RESAMPLE_BICUBIC_PILLOW_AXES_ACTIVATION_CNT },
497+
resample_axes_test_params{ CASE_RESAMPLE_BICUBIC_PILLOW_AXES_2, RESAMPLE_BICUBIC_PILLOW_AXES_ACTIVATION_CNT },
498+
}));
499+
500+
class resample_bicubic_pillow_axes_quantize : public ResampleAxesPrimitiveFusingTest {};
501+
TEST_P(resample_bicubic_pillow_axes_quantize, basic) {
502+
auto p = GetParam();
503+
auto sizes = get_sizes_for_axes(p);
504+
create_topologies(
505+
input_layout("input", get_input_layout(p)),
506+
data("in_lo", get_mem(get_per_channel_layout(p), min_random, 0)),
507+
data("in_hi", get_mem(get_per_channel_layout(p), 1, max_random)),
508+
data("out_lo", get_mem(get_single_element_layout(p), -127)),
509+
data("out_hi", get_mem(get_single_element_layout(p), 127)),
510+
resample("resample_prim", input_info("input"), sizes, {}, p.axes, {}, {}, 0, -0.75f,
511+
p.type, resample::InterpolateOp::ShapeCalcMode::SIZES),
512+
quantize("quantize", input_info("resample_prim"), input_info("in_lo"), input_info("in_hi"),
513+
input_info("out_lo"), input_info("out_hi"), 255, data_types::i8),
514+
reorder("reorder_bfyx", input_info("quantize"), p.default_format, data_types::f32)
515+
);
516+
517+
tolerance = 1;
518+
execute(p);
519+
}
520+
521+
#define RESAMPLE_BICUBIC_PILLOW_AXES_QUANTIZE_CNT 2, 3
522+
INSTANTIATE_TEST_SUITE_P(fusings_gpu, resample_bicubic_pillow_axes_quantize,
523+
::testing::ValuesIn(std::vector<resample_axes_test_params>{
524+
resample_axes_test_params{ CASE_RESAMPLE_BICUBIC_PILLOW_AXES_1, RESAMPLE_BICUBIC_PILLOW_AXES_QUANTIZE_CNT },
525+
resample_axes_test_params{ CASE_RESAMPLE_BICUBIC_PILLOW_AXES_2, RESAMPLE_BICUBIC_PILLOW_AXES_QUANTIZE_CNT },
526+
}));

0 commit comments

Comments
 (0)