Skip to content

Commit

Permalink
Complete to run benchmark_app f32 for resample cpu impl
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinchoi-intel committed Dec 26, 2024
1 parent 0f00606 commit 1d66c32
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 69 deletions.
22 changes: 10 additions & 12 deletions src/plugins/intel_gpu/src/graph/impls/cpu/resample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,34 +106,32 @@ struct resample_impl : public typed_primitive_impl<resample> {
auto input_mem_ptr = instance.input_memory_ptr();
cldnn::mem_lock<uint8_t, mem_lock_type::read> input_lock(input_mem_ptr, stream);

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

if (scales.size() < input_rank)
scales.insert(scales.begin(), input_rank - scales.size(), 1.f);

for(size_t i = (input_rank - axes.size()); i > 0; i--)
axes.insert(axes.begin(), 1, (i - 1));

if (input_host_tensors.size() == 1) {
auto target_shape_sizes = params->output_layouts[0].get_tensor().sizes();
std::vector<int64_t> target_shape_ps;
for (size_t i = 0; i < axes.size(); i++)
for (size_t i = 0; i < input_rank; i++)
target_shape_ps.push_back(target_shape_sizes[i]);

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

if (shape_calc_mode == ov::op::util::InterpolateBase::ShapeCalcMode::SIZES) {
auto new_scales = scales;
auto input_shape_sizes = params->input_layouts[0].get_tensor().sizes();
for (size_t i = 0; i < sizes.size(); i++)
new_scales[i] = sizes[i] / input_shape_sizes[i];

auto scales_tensor = ov::Tensor(ov::element::f32, {new_scales.size()}, new_scales.data());
input_host_tensors.push_back(scales_tensor);
shape_calc_mode = ov::op::util::InterpolateBase::ShapeCalcMode::SCALES;
} else if (shape_calc_mode == ov::op::util::InterpolateBase::ShapeCalcMode::SCALES) {
if (shape_calc_mode == ov::op::util::InterpolateBase::ShapeCalcMode::SCALES) {
auto scales_tensor = ov::Tensor(ov::element::f32, {scales.size()}, scales.data());
input_host_tensors.push_back(scales_tensor);
} else {
OPENVINO_ASSERT(false, "[GPU] Not supported Interpolate ShapeCalcMode", instance.id());
OPENVINO_ASSERT(false, "[GPU] Not supported Interpolate ShapeCalcMode of CPU impl", instance.id());
}

auto axes_tensor = ov::Tensor(ov::element::i64, {axes.size()}, axes.data());
Expand Down
36 changes: 0 additions & 36 deletions src/plugins/intel_gpu/src/graph/impls/ocl/resample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,42 +175,6 @@ struct resample_impl : typed_primitive_impl_ocl<resample> {
}
};

// namespace detail {

// attach_resample_impl::attach_resample_impl() {
// std::set<implementation_map<resample>::key_type> keys;

// const auto types = {data_types::f16, data_types::f32, data_types::i8, data_types::u8, data_types::i32};
// const auto formats = {
// format::bfyx,
// format::b_fs_yx_fsv16,
// format::b_fs_yx_fsv32,
// format::bs_fs_yx_bsv16_fsv16,
// format::bs_fs_yx_bsv32_fsv16,
// format::bs_fs_yx_bsv32_fsv32,

// format::bfzyx,
// format::b_fs_zyx_fsv16,
// format::b_fs_zyx_fsv32,
// format::bs_fs_zyx_bsv16_fsv32,
// format::bs_fs_zyx_bsv16_fsv16,
// format::bs_fs_zyx_bsv32_fsv32,
// format::bs_fs_zyx_bsv32_fsv16,
// };
// for (const auto type : types) {
// for (const auto format : formats) {
// keys.emplace(type, format);
// }
// }

// keys.emplace(data_types::f32, format::yxfb);
// keys.emplace(data_types::f16, format::yxfb);
// keys.emplace(data_types::f16, format::fs_b_yx_fsv32);

// implementation_map<resample>::add(impl_types::ocl, typed_primitive_impl_ocl<resample>::create<resample_impl>, keys);
// }

// } // namespace detail
std::unique_ptr<primitive_impl> ResampleImplementationManager::create_impl(const program_node& node, const kernel_impl_params& params) const {
assert(node.is_type<resample>());
return typed_primitive_impl_ocl<resample>::create<resample_impl>(static_cast<const resample_node&>(node), params);
Expand Down
11 changes: 1 addition & 10 deletions src/plugins/intel_gpu/src/graph/impls/ocl/resample.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "impls/registry/implementation_manager.hpp"
#include "program_node.h"
//#include "intel_gpu/primitives/resample.hpp"
#include "resample_inst.h"

#include <memory>
namespace cldnn {
Expand All @@ -15,16 +16,6 @@ struct ResampleImplementationManager : public ImplementationManager {
ResampleImplementationManager(shape_types shape_type, ValidateFunc vf = nullptr) : ImplementationManager(impl_types::ocl, shape_type, vf) {}
std::unique_ptr<primitive_impl> create_impl(const program_node& node, const kernel_impl_params& params) const override;
bool validate_impl(const program_node& node) const override {
// auto prim = node.as<resample>().get_primitive();
// const auto& in0_layout = node.get_input_layout(0);

// if (in0_layout.data_type == ov::element::f32 &&
// prim->operation_type == ov::op::util::InterpolateBase::InterpolateMode::LINEAR_ONNX &&
// prim->coord_trans_mode == ov::op::util::InterpolateBase::CoordinateTransformMode::ALIGN_CORNERS &&
// prim->shape_calc_mode == ov::op::util::InterpolateBase::ShapeCalcMode::SCALES) {
// return false;
// }

return true;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,10 @@ const std::vector<std::shared_ptr<cldnn::ImplementationManager>>& Registry<resam

return true;
})
// OV_GPU_CREATE_INSTANCE_OCL(ocl::ResampleImplementationManager, shape_types::dynamic_shape,
// [](const cldnn::program_node& node){
// return false;
// })

OV_GPU_GET_INSTANCE_CPU(resample, shape_types::static_shape,
[](const cldnn::program_node& node){
return true;
})
// OV_GPU_GET_INSTANCE_CPU(resample, shape_types::dynamic_shape,
// [](const cldnn::program_node& node){
// return false;
// })
};

return impls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,20 @@ INSTANTIATE_TEST_SUITE_P(InterpolateLinear_Layout_Test, InterpolateLayerGPUTest,
const std::vector<ShapeParams> shapeParams4D_LargeShape = {
ShapeParams{
ov::op::v4::Interpolate::ShapeCalcMode::SCALES,
//InputShape{{-1, {2, 100}, -1, -1}, {{1, 64, 148, 148}}},
InputShape{{-1, -1, -1, -1}, {{1, 3, 48, 48}}}, // min shape for failure
InputShape{{-1, {2, 100}, -1, -1}, {{1, 64, 148, 148}}},
ov::test::utils::InputLayerType::CONSTANT,
ov::test::utils::InputLayerType::CONSTANT,
{{1.f, 1.f, 2.f, 2.f}},
defaultAxes4D.front()
},
ShapeParams{
ov::op::v4::Interpolate::ShapeCalcMode::SCALES,
InputShape{{-1, -1, -1, -1}, {{1, 3, 48, 48}}},
ov::test::utils::InputLayerType::CONSTANT,
ov::test::utils::InputLayerType::CONSTANT,
{{2.f, 2.f}},
reducedAxes4D.front()
},
ShapeParams{
ov::op::v4::Interpolate::ShapeCalcMode::SIZES,
InputShape{{-1, -1, -1, -1}, {{1, 3, 48, 48}}},
Expand Down

0 comments on commit 1d66c32

Please sign in to comment.