Skip to content

Commit 1d66c32

Browse files
Complete to run benchmark_app f32 for resample cpu impl
1 parent 0f00606 commit 1d66c32

File tree

5 files changed

+20
-69
lines changed

5 files changed

+20
-69
lines changed

src/plugins/intel_gpu/src/graph/impls/cpu/resample.cpp

+10-12
Original file line numberDiff line numberDiff line change
@@ -106,34 +106,32 @@ struct resample_impl : public typed_primitive_impl<resample> {
106106
auto input_mem_ptr = instance.input_memory_ptr();
107107
cldnn::mem_lock<uint8_t, mem_lock_type::read> input_lock(input_mem_ptr, stream);
108108

109+
auto input_rank = params->input_layouts[0].get_rank();
109110
for (size_t i = 0; i < params->input_layouts.size(); i++) {
110111
auto input_tensor = make_tensor(params->input_layouts[0], input_lock.data());
111112
input_host_tensors.push_back(input_tensor);
112113
}
113114

115+
if (scales.size() < input_rank)
116+
scales.insert(scales.begin(), input_rank - scales.size(), 1.f);
117+
118+
for(size_t i = (input_rank - axes.size()); i > 0; i--)
119+
axes.insert(axes.begin(), 1, (i - 1));
120+
114121
if (input_host_tensors.size() == 1) {
115122
auto target_shape_sizes = params->output_layouts[0].get_tensor().sizes();
116123
std::vector<int64_t> target_shape_ps;
117-
for (size_t i = 0; i < axes.size(); i++)
124+
for (size_t i = 0; i < input_rank; i++)
118125
target_shape_ps.push_back(target_shape_sizes[i]);
119126

120127
auto target_shape_tensor = ov::Tensor(ov::element::i32, {target_shape_ps.size()}, target_shape_ps.data());
121128
input_host_tensors.push_back(target_shape_tensor);
122129

123-
if (shape_calc_mode == ov::op::util::InterpolateBase::ShapeCalcMode::SIZES) {
124-
auto new_scales = scales;
125-
auto input_shape_sizes = params->input_layouts[0].get_tensor().sizes();
126-
for (size_t i = 0; i < sizes.size(); i++)
127-
new_scales[i] = sizes[i] / input_shape_sizes[i];
128-
129-
auto scales_tensor = ov::Tensor(ov::element::f32, {new_scales.size()}, new_scales.data());
130-
input_host_tensors.push_back(scales_tensor);
131-
shape_calc_mode = ov::op::util::InterpolateBase::ShapeCalcMode::SCALES;
132-
} else if (shape_calc_mode == ov::op::util::InterpolateBase::ShapeCalcMode::SCALES) {
130+
if (shape_calc_mode == ov::op::util::InterpolateBase::ShapeCalcMode::SCALES) {
133131
auto scales_tensor = ov::Tensor(ov::element::f32, {scales.size()}, scales.data());
134132
input_host_tensors.push_back(scales_tensor);
135133
} else {
136-
OPENVINO_ASSERT(false, "[GPU] Not supported Interpolate ShapeCalcMode", instance.id());
134+
OPENVINO_ASSERT(false, "[GPU] Not supported Interpolate ShapeCalcMode of CPU impl", instance.id());
137135
}
138136

139137
auto axes_tensor = ov::Tensor(ov::element::i64, {axes.size()}, axes.data());

src/plugins/intel_gpu/src/graph/impls/ocl/resample.cpp

-36
Original file line numberDiff line numberDiff line change
@@ -175,42 +175,6 @@ struct resample_impl : typed_primitive_impl_ocl<resample> {
175175
}
176176
};
177177

178-
// namespace detail {
179-
180-
// attach_resample_impl::attach_resample_impl() {
181-
// std::set<implementation_map<resample>::key_type> keys;
182-
183-
// const auto types = {data_types::f16, data_types::f32, data_types::i8, data_types::u8, data_types::i32};
184-
// const auto formats = {
185-
// format::bfyx,
186-
// format::b_fs_yx_fsv16,
187-
// format::b_fs_yx_fsv32,
188-
// format::bs_fs_yx_bsv16_fsv16,
189-
// format::bs_fs_yx_bsv32_fsv16,
190-
// format::bs_fs_yx_bsv32_fsv32,
191-
192-
// format::bfzyx,
193-
// format::b_fs_zyx_fsv16,
194-
// format::b_fs_zyx_fsv32,
195-
// format::bs_fs_zyx_bsv16_fsv32,
196-
// format::bs_fs_zyx_bsv16_fsv16,
197-
// format::bs_fs_zyx_bsv32_fsv32,
198-
// format::bs_fs_zyx_bsv32_fsv16,
199-
// };
200-
// for (const auto type : types) {
201-
// for (const auto format : formats) {
202-
// keys.emplace(type, format);
203-
// }
204-
// }
205-
206-
// keys.emplace(data_types::f32, format::yxfb);
207-
// keys.emplace(data_types::f16, format::yxfb);
208-
// keys.emplace(data_types::f16, format::fs_b_yx_fsv32);
209-
210-
// implementation_map<resample>::add(impl_types::ocl, typed_primitive_impl_ocl<resample>::create<resample_impl>, keys);
211-
// }
212-
213-
// } // namespace detail
214178
std::unique_ptr<primitive_impl> ResampleImplementationManager::create_impl(const program_node& node, const kernel_impl_params& params) const {
215179
assert(node.is_type<resample>());
216180
return typed_primitive_impl_ocl<resample>::create<resample_impl>(static_cast<const resample_node&>(node), params);

src/plugins/intel_gpu/src/graph/impls/ocl/resample.hpp

+1-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "impls/registry/implementation_manager.hpp"
66
#include "program_node.h"
77
//#include "intel_gpu/primitives/resample.hpp"
8+
#include "resample_inst.h"
89

910
#include <memory>
1011
namespace cldnn {
@@ -15,16 +16,6 @@ struct ResampleImplementationManager : public ImplementationManager {
1516
ResampleImplementationManager(shape_types shape_type, ValidateFunc vf = nullptr) : ImplementationManager(impl_types::ocl, shape_type, vf) {}
1617
std::unique_ptr<primitive_impl> create_impl(const program_node& node, const kernel_impl_params& params) const override;
1718
bool validate_impl(const program_node& node) const override {
18-
// auto prim = node.as<resample>().get_primitive();
19-
// const auto& in0_layout = node.get_input_layout(0);
20-
21-
// if (in0_layout.data_type == ov::element::f32 &&
22-
// prim->operation_type == ov::op::util::InterpolateBase::InterpolateMode::LINEAR_ONNX &&
23-
// prim->coord_trans_mode == ov::op::util::InterpolateBase::CoordinateTransformMode::ALIGN_CORNERS &&
24-
// prim->shape_calc_mode == ov::op::util::InterpolateBase::ShapeCalcMode::SCALES) {
25-
// return false;
26-
// }
27-
2819
return true;
2920
}
3021
};

src/plugins/intel_gpu/src/graph/impls/registry/resample_impls.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,10 @@ const std::vector<std::shared_ptr<cldnn::ImplementationManager>>& Registry<resam
3333

3434
return true;
3535
})
36-
// OV_GPU_CREATE_INSTANCE_OCL(ocl::ResampleImplementationManager, shape_types::dynamic_shape,
37-
// [](const cldnn::program_node& node){
38-
// return false;
39-
// })
40-
4136
OV_GPU_GET_INSTANCE_CPU(resample, shape_types::static_shape,
4237
[](const cldnn::program_node& node){
4338
return true;
4439
})
45-
// OV_GPU_GET_INSTANCE_CPU(resample, shape_types::dynamic_shape,
46-
// [](const cldnn::program_node& node){
47-
// return false;
48-
// })
4940
};
5041

5142
return impls;

src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/interpolate.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,20 @@ INSTANTIATE_TEST_SUITE_P(InterpolateLinear_Layout_Test, InterpolateLayerGPUTest,
549549
const std::vector<ShapeParams> shapeParams4D_LargeShape = {
550550
ShapeParams{
551551
ov::op::v4::Interpolate::ShapeCalcMode::SCALES,
552-
//InputShape{{-1, {2, 100}, -1, -1}, {{1, 64, 148, 148}}},
553-
InputShape{{-1, -1, -1, -1}, {{1, 3, 48, 48}}}, // min shape for failure
552+
InputShape{{-1, {2, 100}, -1, -1}, {{1, 64, 148, 148}}},
554553
ov::test::utils::InputLayerType::CONSTANT,
555554
ov::test::utils::InputLayerType::CONSTANT,
556555
{{1.f, 1.f, 2.f, 2.f}},
557556
defaultAxes4D.front()
558557
},
558+
ShapeParams{
559+
ov::op::v4::Interpolate::ShapeCalcMode::SCALES,
560+
InputShape{{-1, -1, -1, -1}, {{1, 3, 48, 48}}},
561+
ov::test::utils::InputLayerType::CONSTANT,
562+
ov::test::utils::InputLayerType::CONSTANT,
563+
{{2.f, 2.f}},
564+
reducedAxes4D.front()
565+
},
559566
ShapeParams{
560567
ov::op::v4::Interpolate::ShapeCalcMode::SIZES,
561568
InputShape{{-1, -1, -1, -1}, {{1, 3, 48, 48}}},

0 commit comments

Comments
 (0)