[GPU] Added support dynamic sizes/scales inputs for Interpolate (#14074)
This commit is contained in:
parent
7933cc7e0b
commit
eb9946bd25
@ -57,7 +57,7 @@ struct resample : public primitive_base<resample> {
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief resample with constant inputs
|
||||
/// @brief resample with constant sizes/scales
|
||||
resample(const primitive_id& id,
|
||||
const primitive_id& input,
|
||||
const std::vector<int64_t>& sizes,
|
||||
@ -90,11 +90,11 @@ struct resample : public primitive_base<resample> {
|
||||
throw std::runtime_error("Resample's scales/axes count does not match");
|
||||
}
|
||||
|
||||
/// @brief resample with non-constant sizes
|
||||
/// @brief resample with dynamic sizes/scales
|
||||
resample(const primitive_id& id,
|
||||
const primitive_id& input,
|
||||
const primitive_id& sizes_id,
|
||||
const std::vector<float>& scales,
|
||||
const primitive_id& scales_id,
|
||||
const std::vector<int64_t>& axes,
|
||||
const std::vector<size_t>& pads_begin = {},
|
||||
const std::vector<size_t>& pads_end = {},
|
||||
@ -105,40 +105,7 @@ struct resample : public primitive_base<resample> {
|
||||
InterpolateOp::CoordinateTransformMode ctm = InterpolateOp::CoordinateTransformMode::HALF_PIXEL,
|
||||
InterpolateOp::NearestMode nm = InterpolateOp::NearestMode::ROUND_PREFER_FLOOR,
|
||||
const padding& output_padding = padding())
|
||||
: primitive_base(id, {input, sizes_id}, output_padding),
|
||||
output_size(tensor()),
|
||||
num_filter(0),
|
||||
sizes({}),
|
||||
scales(scales),
|
||||
axes(axes),
|
||||
pads_begin(pads_begin),
|
||||
pads_end(pads_end),
|
||||
operation_type(operation_type),
|
||||
shape_calc_mode(shape_calc_mode),
|
||||
antialias(antialias),
|
||||
cube_coeff(cube_coeff),
|
||||
coord_trans_mode(ctm),
|
||||
round_mode(nm) {
|
||||
if (scales.size() != axes.size())
|
||||
throw std::runtime_error("Resample's scales/axes count does not match");
|
||||
}
|
||||
|
||||
/// @brief resample with non-constant scales
|
||||
resample(const primitive_id& id,
|
||||
const primitive_id& input,
|
||||
const std::vector<int64_t>& sizes,
|
||||
const primitive_id& scales_id,
|
||||
const std::vector<int64_t>& axes,
|
||||
const std::vector<size_t>& pads_begin = {},
|
||||
const std::vector<size_t>& pads_end = {},
|
||||
int32_t antialias = 0,
|
||||
float cube_coeff = -0.75f,
|
||||
InterpolateOp::InterpolateMode operation_type = InterpolateOp::InterpolateMode::LINEAR,
|
||||
InterpolateOp::ShapeCalcMode shape_calc_mode = InterpolateOp::ShapeCalcMode::SCALES,
|
||||
InterpolateOp::CoordinateTransformMode ctm = InterpolateOp::CoordinateTransformMode::HALF_PIXEL,
|
||||
InterpolateOp::NearestMode nm = InterpolateOp::NearestMode::ROUND_PREFER_FLOOR,
|
||||
const padding& output_padding = padding())
|
||||
: primitive_base(id, {input, scales_id}, output_padding),
|
||||
: primitive_base(id, {input, sizes_id, scales_id}, output_padding),
|
||||
output_size(tensor()),
|
||||
num_filter(0),
|
||||
sizes({}),
|
||||
|
@ -28,6 +28,8 @@ public:
|
||||
explicit half_impl(T data, int /*direct_creation_tag*/) : _data(data) {}
|
||||
|
||||
operator uint16_t() const { return _data; }
|
||||
operator int32_t() const { return static_cast<int32_t>(half_to_float(_data)); }
|
||||
operator int64_t() const { return static_cast<int64_t>(half_to_float(_data)); }
|
||||
operator float() const {
|
||||
return half_to_float(_data);
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include "ngraph/runtime/host_tensor.hpp"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#ifdef ENABLE_ONEDNN_FOR_GPU
|
||||
#include <oneapi/dnnl/dnnl.hpp>
|
||||
#endif
|
||||
@ -175,19 +177,40 @@ struct surfaces_lock {
|
||||
|
||||
template<typename T>
|
||||
inline std::vector<T> read_vector(cldnn::memory::ptr mem, const cldnn::stream& stream) {
|
||||
cldnn::data_types mem_dtype = mem->get_layout().data_type;
|
||||
if (mem_dtype == data_types::f16 || mem_dtype == data_types::f32) {
|
||||
if (!std::is_floating_point<T>::value && !std::is_same<T, half_t>::value) {
|
||||
OPENVINO_ASSERT(false, "[GPU] read_vector: attempt to convert floating point memory to non-floating point memory");
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<T> out_vecs;
|
||||
if (mem->get_allocation_type() == allocation_type::usm_host || mem->get_allocation_type() == allocation_type::usm_shared) {
|
||||
switch (mem->get_layout().data_type) {
|
||||
switch (mem_dtype) {
|
||||
case data_types::i32: {
|
||||
auto p_mem = reinterpret_cast<int32_t*>(mem->buffer_ptr());
|
||||
for (size_t i = 0; i < mem->count(); i++) {
|
||||
for (size_t i = 0; i < mem->count(); ++i) {
|
||||
out_vecs.push_back(static_cast<T>(p_mem[i]));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case data_types::i64: {
|
||||
auto p_mem = reinterpret_cast<int64_t*>(mem->buffer_ptr());
|
||||
for (size_t i = 0; i < mem->count(); i++) {
|
||||
for (size_t i = 0; i < mem->count(); ++i) {
|
||||
out_vecs.push_back(static_cast<T>(p_mem[i]));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case data_types::f16: {
|
||||
auto p_mem = reinterpret_cast<uint16_t*>(mem->buffer_ptr());
|
||||
for (size_t i = 0; i < mem->count(); ++i) {
|
||||
out_vecs.push_back(static_cast<T>(half_to_float(p_mem[i])));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case data_types::f32: {
|
||||
auto p_mem = reinterpret_cast<float*>(mem->buffer_ptr());
|
||||
for (size_t i = 0; i < mem->count(); ++i) {
|
||||
out_vecs.push_back(static_cast<T>(p_mem[i]));
|
||||
}
|
||||
break;
|
||||
@ -195,7 +218,7 @@ inline std::vector<T> read_vector(cldnn::memory::ptr mem, const cldnn::stream& s
|
||||
default: OPENVINO_ASSERT(false, "[GPU] read_vector: unsupported data type");
|
||||
}
|
||||
} else {
|
||||
switch (mem->get_layout().data_type) {
|
||||
switch (mem_dtype) {
|
||||
case data_types::i32: {
|
||||
mem_lock<int32_t, mem_lock_type::read> lock{mem, stream};
|
||||
out_vecs = std::move(std::vector<T>(lock.begin(), lock.end()));
|
||||
@ -206,6 +229,16 @@ inline std::vector<T> read_vector(cldnn::memory::ptr mem, const cldnn::stream& s
|
||||
out_vecs = std::move(std::vector<T>(lock.begin(), lock.end()));
|
||||
break;
|
||||
}
|
||||
case data_types::f16: {
|
||||
mem_lock<half_t, mem_lock_type::read> lock{mem, stream};
|
||||
out_vecs = std::move(std::vector<T>(lock.begin(), lock.end()));
|
||||
break;
|
||||
}
|
||||
case data_types::f32: {
|
||||
mem_lock<float, mem_lock_type::read> lock{mem, stream};
|
||||
out_vecs = std::move(std::vector<T>(lock.begin(), lock.end()));
|
||||
break;
|
||||
}
|
||||
default: OPENVINO_ASSERT(false, "[GPU] read_vector: unsupported data type");
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "kernel_selector_helper.h"
|
||||
#include "kernel_selector/kernels/resample/resample_kernel_selector.h"
|
||||
#include "kernel_selector/kernels/resample/resample_kernel_base.h"
|
||||
#include "intel_gpu/runtime/half.hpp"
|
||||
|
||||
namespace cldnn {
|
||||
namespace ocl {
|
||||
@ -155,10 +156,9 @@ struct resample_impl : typed_primitive_impl_ocl<resample> {
|
||||
|
||||
auto scales = primitive->scales;
|
||||
bool scales_calc_mod = primitive->shape_calc_mode == resample::InterpolateOp::ShapeCalcMode::SCALES;
|
||||
if (scales_calc_mod && impl_param.input_layouts.size() == 2 && scales.empty()) {
|
||||
auto mem = impl_param.memory_deps.at(1);
|
||||
float* buffer = static_cast<float*>(mem->buffer_ptr());
|
||||
scales = std::vector<float>(buffer, buffer + mem->count());
|
||||
if (scales_calc_mod && impl_param.input_layouts.size() > 1 && scales.empty()) {
|
||||
auto mem = impl_param.memory_deps.at(2);
|
||||
scales = read_vector<float>(mem, impl_param.prog->get_stream());
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < scales.size(); ++i) {
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
program_node& input() const { return get_dependency(0); }
|
||||
program_node& input2() const { return get_dependency(1); }
|
||||
|
||||
std::vector<size_t> get_shape_infer_dependencies() const override { return {1}; }
|
||||
std::vector<size_t> get_shape_infer_dependencies() const override { return {1, 2}; }
|
||||
};
|
||||
|
||||
using resample_node = typed_program_node<resample>;
|
||||
|
@ -62,33 +62,11 @@ std::vector<layout> resample_inst::calc_output_layouts(resample_node const& /*no
|
||||
|
||||
bool sizes_calc_mod = desc->get_attrs().shape_calculation_mode == ov::op::v4::Interpolate::ShapeCalcMode::SIZES;
|
||||
|
||||
if ((sizes_data.empty() || !sizes_calc_mod) && (scales_data.empty() || sizes_calc_mod) && !memory_deps.count(1)) {
|
||||
if (((sizes_data.empty() && !memory_deps.count(1)) || !sizes_calc_mod) &&
|
||||
((scales_data.empty() && !memory_deps.count(2)) || sizes_calc_mod)) {
|
||||
return { layout{ShapeType::dynamic(input_rank), input_layout.data_type, input_layout.format} };
|
||||
}
|
||||
|
||||
if (!sizes_data.empty()) {
|
||||
auto sizes_tensor = make_host_tensor({ sizes_shape, data_types::i64, format::bfyx }, static_cast<void*>(sizes_data.data()));
|
||||
const_data.emplace(1, sizes_tensor);
|
||||
}
|
||||
|
||||
if (!scales_data.empty()) {
|
||||
auto scales_tensor = make_host_tensor({ scales_shape, data_types::f32, format::bfyx }, static_cast<void*>(scales_data.data()));
|
||||
const_data.emplace(2, scales_tensor);
|
||||
}
|
||||
|
||||
if (memory_deps.count(1)) {
|
||||
auto mem = memory_deps.at(1);
|
||||
cldnn::mem_lock<uint8_t, mem_lock_type::read> lock(mem, impl_param.prog->get_stream());
|
||||
auto ptr = lock.data();
|
||||
auto tensor = make_host_tensor(mem->get_layout(), ptr);
|
||||
|
||||
if (sizes_calc_mod) {
|
||||
const_data.emplace(1, tensor);
|
||||
} else {
|
||||
const_data.emplace(2, tensor);
|
||||
}
|
||||
}
|
||||
|
||||
auto axes_data = desc->axes;
|
||||
if (axes_data.empty()) {
|
||||
axes_data.resize(input_layout.get_rank());
|
||||
@ -102,7 +80,31 @@ std::vector<layout> resample_inst::calc_output_layouts(resample_node const& /*no
|
||||
auto pads_end = desc->pads_end;
|
||||
ov::op::v4::correct_pads_attr(&op, pads_begin, pads_end, input_shapes);
|
||||
|
||||
ov::op::v4::shape_infer(&op, pads_begin, pads_end, input_shapes, output_shapes, {const_data});
|
||||
if (sizes_calc_mod) {
|
||||
if (!sizes_data.empty()) {
|
||||
auto sizes_tensor = make_host_tensor({ sizes_shape, data_types::i64, format::bfyx }, static_cast<void*>(sizes_data.data()));
|
||||
const_data.emplace(1, sizes_tensor);
|
||||
ov::op::v4::shape_infer(&op, pads_begin, pads_end, input_shapes, output_shapes, {const_data});
|
||||
} else {
|
||||
auto sizes_mem = memory_deps.at(1);
|
||||
cldnn::mem_lock<uint8_t, mem_lock_type::read> lock(sizes_mem, impl_param.prog->get_stream());
|
||||
auto sizes_tensor = make_host_tensor(sizes_mem->get_layout(), lock.data());
|
||||
const_data.emplace(1, sizes_tensor);
|
||||
ov::op::v4::shape_infer(&op, pads_begin, pads_end, input_shapes, output_shapes, {const_data});
|
||||
}
|
||||
} else {
|
||||
if (!scales_data.empty()) {
|
||||
auto scales_tensor = make_host_tensor({ scales_shape, data_types::f32, format::bfyx }, static_cast<void*>(scales_data.data()));
|
||||
const_data.emplace(2, scales_tensor);
|
||||
ov::op::v4::shape_infer(&op, pads_begin, pads_end, input_shapes, output_shapes, {const_data});
|
||||
} else {
|
||||
auto scales_mem = memory_deps.at(2);
|
||||
cldnn::mem_lock<uint8_t, mem_lock_type::read> lock(scales_mem, impl_param.prog->get_stream());
|
||||
auto scales_tensor = make_host_tensor(scales_mem->get_layout(), lock.data());
|
||||
const_data.emplace(2, scales_tensor);
|
||||
ov::op::v4::shape_infer(&op, pads_begin, pads_end, input_shapes, output_shapes, {const_data});
|
||||
}
|
||||
}
|
||||
|
||||
return { layout{output_shapes[0], input_layout.data_type, format::adjust_to_rank(input_layout.format, output_shapes[0].size())} };
|
||||
}
|
||||
|
@ -95,24 +95,10 @@ static void CreateInterpolateOp(Program& p, const std::shared_ptr<ngraph::op::v4
|
||||
attrs.shape_calculation_mode,
|
||||
attrs.coordinate_transformation_mode,
|
||||
attrs.nearest_mode);
|
||||
} else if (scales_constant) {
|
||||
} else {
|
||||
resamplePrim = std::make_shared<cldnn::resample>(layerName,
|
||||
inputPrimitives[0],
|
||||
inputPrimitives[SIZES_INDEX],
|
||||
scales,
|
||||
axes,
|
||||
attrs.pads_begin,
|
||||
attrs.pads_end,
|
||||
attrs.antialias,
|
||||
attrs.cube_coeff,
|
||||
interpolateMode,
|
||||
attrs.shape_calculation_mode,
|
||||
attrs.coordinate_transformation_mode,
|
||||
attrs.nearest_mode);
|
||||
} else if (sizes_constant) {
|
||||
resamplePrim = std::make_shared<cldnn::resample>(layerName,
|
||||
inputPrimitives[0],
|
||||
sizes,
|
||||
inputPrimitives[SCALES_INDEX],
|
||||
axes,
|
||||
attrs.pads_begin,
|
||||
@ -123,9 +109,6 @@ static void CreateInterpolateOp(Program& p, const std::shared_ptr<ngraph::op::v4
|
||||
attrs.shape_calculation_mode,
|
||||
attrs.coordinate_transformation_mode,
|
||||
attrs.nearest_mode);
|
||||
} else {
|
||||
OPENVINO_ASSERT(false, "Scales and Sizes as parameters are not supported at the same time in ",
|
||||
op->get_friendly_name(), " (", op->get_type_name(), ")");
|
||||
}
|
||||
} else {
|
||||
auto outShape = op->get_output_shape(0);
|
||||
|
@ -35,70 +35,81 @@ struct InterpolateAttrs {
|
||||
|
||||
struct interpolate_test_params {
|
||||
layout in_layout;
|
||||
layout pattern_layout;
|
||||
std::vector<int64_t> pattern_data;
|
||||
layout sizes_layout;
|
||||
std::vector<int64_t> sizes;
|
||||
layout scales_layout;
|
||||
std::vector<float> scales;
|
||||
std::vector<int64_t> axes;
|
||||
InterpolateAttrs attrs;
|
||||
layout expected_layout;
|
||||
};
|
||||
|
||||
class interpolate_test_two_inputs : public testing::TestWithParam<interpolate_test_params> { };
|
||||
TEST_P(interpolate_test_two_inputs, shape_infer) {
|
||||
class interpolate_test_three_inputs : public testing::TestWithParam<interpolate_test_params> { };
|
||||
TEST_P(interpolate_test_three_inputs, shape_infer) {
|
||||
auto p = GetParam();
|
||||
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto input_prim = std::make_shared<input_layout>("input", p.in_layout);
|
||||
auto pattern_prim = std::make_shared<input_layout>("pattern", p.pattern_layout);
|
||||
auto resample_prim = std::make_shared<resample>("output", "input", "pattern", p.scales, p.axes,
|
||||
auto sizes_prim = std::make_shared<input_layout>("sizes", p.sizes_layout);
|
||||
auto scales_prim = std::make_shared<input_layout>("scales", p.scales_layout);
|
||||
auto resample_prim = std::make_shared<resample>("output", "input", "sizes", "scales", p.axes,
|
||||
p.attrs.pads_begin, p.attrs.pads_end,
|
||||
p.attrs.antialias, p.attrs.cube_coeff,
|
||||
p.attrs.mode, p.attrs.shape_calc_mode,
|
||||
p.attrs.coordinate_transformation_mode, p.attrs.nearest_mode);
|
||||
cldnn::program prog(engine);
|
||||
|
||||
auto pattern_mem = engine.allocate_memory(p.pattern_layout);
|
||||
set_values(pattern_mem, p.pattern_data);
|
||||
auto sizes_mem = engine.allocate_memory(p.sizes_layout);
|
||||
auto scales_mem = engine.allocate_memory(p.scales_layout);
|
||||
set_values(sizes_mem, p.sizes);
|
||||
set_values(scales_mem, p.scales);
|
||||
|
||||
auto& input_node = prog.get_or_create(input_prim);
|
||||
auto& pattern_node = prog.get_or_create(pattern_prim);
|
||||
auto& sizes_node = prog.get_or_create(sizes_prim);
|
||||
auto& scales_node = prog.get_or_create(scales_prim);
|
||||
auto& resample_node = prog.get_or_create(resample_prim);
|
||||
program_wrapper::add_connection(prog, input_node, resample_node);
|
||||
program_wrapper::add_connection(prog, pattern_node, resample_node);
|
||||
auto params = resample_node.get_kernel_impl_params();
|
||||
program_wrapper::add_connection(prog, sizes_node, resample_node);
|
||||
program_wrapper::add_connection(prog, scales_node, resample_node);
|
||||
|
||||
auto params = resample_node.get_kernel_impl_params();
|
||||
params->memory_deps = {{1, sizes_mem}, {2, scales_mem}};
|
||||
|
||||
params->memory_deps = {{1, pattern_mem}};
|
||||
auto res_w_data = resample_inst::calc_output_layouts<ov::PartialShape>(resample_node, *params);
|
||||
|
||||
ASSERT_EQ(res_w_data.size(), 1);
|
||||
ASSERT_EQ(res_w_data[0], p.expected_layout);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke, interpolate_test_two_inputs,
|
||||
INSTANTIATE_TEST_SUITE_P(smoke, interpolate_test_three_inputs,
|
||||
testing::ValuesIn(std::vector<interpolate_test_params>{
|
||||
{
|
||||
layout{ov::PartialShape{1, 2, 48, 80}, data_types::f32, format::bfyx},
|
||||
layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {-1, -1, -1, -1},
|
||||
{1.0f, 1.0f, 0.5f, 2.0f}, {0, 1, 2, 3}, InterpolateAttrs{InterpolateOp::ShapeCalcMode::SCALES},
|
||||
layout{ov::PartialShape{}, data_types::i64, format::bfyx}, {},
|
||||
layout{ov::PartialShape{4}, data_types::f32, format::bfyx}, {1.0f, 1.0f, 0.5f, 2.0f},
|
||||
{0, 1, 2, 3}, InterpolateAttrs{InterpolateOp::ShapeCalcMode::SCALES},
|
||||
layout{ov::PartialShape{1, 2, 24, 160}, data_types::f32, format::bfyx}
|
||||
},
|
||||
{
|
||||
layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx},
|
||||
layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {-1, -1, -1, -1},
|
||||
{1.0f, 1.0f, 0.5f, 2.0f}, {0, 1, 2, 3}, InterpolateAttrs{InterpolateOp::ShapeCalcMode::SCALES},
|
||||
layout{ov::PartialShape{}, data_types::i64, format::bfyx}, {},
|
||||
layout{ov::PartialShape{4}, data_types::f32, format::bfyx}, {1.0f, 1.0f, 0.5f, 2.0f},
|
||||
{0, 1, 2, 3}, InterpolateAttrs{InterpolateOp::ShapeCalcMode::SCALES},
|
||||
layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx}
|
||||
},
|
||||
{
|
||||
layout{ov::PartialShape{2, 2, 3, 2}, data_types::f32, format::bfyx},
|
||||
layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {2, 2, 2, 3},
|
||||
{}, {}, InterpolateAttrs(InterpolateOp::ShapeCalcMode::SIZES),
|
||||
layout{ov::PartialShape{4}, data_types::f32, format::bfyx}, {1.f, 1.f, 1.f, 1.f},
|
||||
{0, 1, 2, 3}, InterpolateAttrs(InterpolateOp::ShapeCalcMode::SIZES),
|
||||
layout{ov::PartialShape{2, 2, 2, 3}, data_types::f32, format::bfyx}
|
||||
},
|
||||
{
|
||||
layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx},
|
||||
layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {2, 2, 2, 3},
|
||||
{}, {}, InterpolateAttrs(InterpolateOp::ShapeCalcMode::SIZES),
|
||||
layout{ov::PartialShape{4}, data_types::f32, format::bfyx}, {1.f, 1.f, 1.f, 1.f},
|
||||
{0, 1, 2, 3}, InterpolateAttrs(InterpolateOp::ShapeCalcMode::SIZES),
|
||||
layout{ov::PartialShape{2, 2, 2, 3}, data_types::f32, format::bfyx}
|
||||
}
|
||||
}));
|
||||
@ -110,7 +121,7 @@ TEST_P(interpolate_test_single_input, shape_infer) {
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto input_prim = std::make_shared<input_layout>("input", p.in_layout);
|
||||
auto resample_prim = std::make_shared<resample>("output", "input", p.pattern_data, p.scales, p.axes,
|
||||
auto resample_prim = std::make_shared<resample>("output", "input", p.sizes, p.scales, p.axes,
|
||||
p.attrs.pads_begin, p.attrs.pads_end,
|
||||
p.attrs.antialias, p.attrs.cube_coeff,
|
||||
p.attrs.mode, p.attrs.shape_calc_mode,
|
||||
@ -132,26 +143,30 @@ INSTANTIATE_TEST_SUITE_P(smoke, interpolate_test_single_input,
|
||||
testing::ValuesIn(std::vector<interpolate_test_params>{
|
||||
{
|
||||
layout{ov::PartialShape{1, 2, 48, 80}, data_types::f32, format::bfyx},
|
||||
layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {-1, -1, -1, -1},
|
||||
{1.0f, 1.0f, 0.5f, 2.0f}, {0, 1, 2, 3}, InterpolateAttrs{InterpolateOp::ShapeCalcMode::SCALES},
|
||||
layout{ov::PartialShape{}, data_types::i64, format::bfyx}, {},
|
||||
layout{ov::PartialShape{4}, data_types::f32, format::bfyx}, {1.0f, 1.0f, 0.5f, 2.0f},
|
||||
{0, 1, 2, 3}, InterpolateAttrs{InterpolateOp::ShapeCalcMode::SCALES},
|
||||
layout{ov::PartialShape{1, 2, 24, 160}, data_types::f32, format::bfyx}
|
||||
},
|
||||
{
|
||||
layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx},
|
||||
layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {-1, -1, -1, -1},
|
||||
{1.0f, 1.0f, 0.5f, 2.0f}, {0, 1, 2, 3}, InterpolateAttrs{InterpolateOp::ShapeCalcMode::SCALES},
|
||||
layout{ov::PartialShape{}, data_types::i64, format::bfyx}, {},
|
||||
layout{ov::PartialShape{4}, data_types::f32, format::bfyx}, {1.0f, 1.0f, 0.5f, 2.0f},
|
||||
{0, 1, 2, 3}, InterpolateAttrs{InterpolateOp::ShapeCalcMode::SCALES},
|
||||
layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx}
|
||||
},
|
||||
{
|
||||
layout{ov::PartialShape{2, 2, 3, 2}, data_types::f32, format::bfyx},
|
||||
layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {2, 2, 2, 3},
|
||||
{}, {}, InterpolateAttrs(InterpolateOp::ShapeCalcMode::SIZES),
|
||||
layout{ov::PartialShape{4}, data_types::f32, format::bfyx}, {1.f, 1.f, 1.f, 1.f},
|
||||
{0, 1, 2, 3}, InterpolateAttrs(InterpolateOp::ShapeCalcMode::SIZES),
|
||||
layout{ov::PartialShape{2, 2, 2, 3}, data_types::f32, format::bfyx}
|
||||
},
|
||||
{
|
||||
layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx},
|
||||
layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {2, 2, 2, 3},
|
||||
{}, {}, InterpolateAttrs(InterpolateOp::ShapeCalcMode::SIZES),
|
||||
layout{ov::PartialShape{4}, data_types::f32, format::bfyx}, {1.f, 1.f, 1.f, 1.f},
|
||||
{0, 1, 2, 3}, InterpolateAttrs(InterpolateOp::ShapeCalcMode::SIZES),
|
||||
layout{ov::PartialShape{2, 2, 2, 3}, data_types::f32, format::bfyx}
|
||||
}
|
||||
}));
|
||||
|
@ -24,7 +24,8 @@ using InterpolateSpecificParams = std::tuple<ngraph::op::v4::Interpolate::Interp
|
||||
using ShapeParams = std::tuple<ngraph::op::v4::Interpolate::ShapeCalcMode, // ShapeCalculationMode
|
||||
InputShape, // Input shapes
|
||||
// params describing input, choice of which depends on ShapeCalcMode
|
||||
ngraph::helpers::InputLayerType, // input type
|
||||
ngraph::helpers::InputLayerType, // sizes input type
|
||||
ngraph::helpers::InputLayerType, // scales input type
|
||||
std::vector<std::vector<float>>, // scales or sizes values
|
||||
std::vector<int64_t>>; // axes
|
||||
|
||||
@ -53,10 +54,11 @@ public:
|
||||
|
||||
ngraph::op::v4::Interpolate::ShapeCalcMode shapeCalcMode;
|
||||
InputShape inputShapes;
|
||||
ngraph::helpers::InputLayerType shapeInputType;
|
||||
ngraph::helpers::InputLayerType sizesInputType;
|
||||
ngraph::helpers::InputLayerType scalesInputType;
|
||||
std::vector<std::vector<float>> shapeDataForInput;
|
||||
std::vector<int64_t> axes;
|
||||
std::tie(shapeCalcMode, inputShapes, shapeInputType, shapeDataForInput, axes) = shapeParams;
|
||||
std::tie(shapeCalcMode, inputShapes, sizesInputType, scalesInputType, shapeDataForInput, axes) = shapeParams;
|
||||
|
||||
std::ostringstream result;
|
||||
result << "ShapeCalcMode=" << shapeCalcMode << "_";
|
||||
@ -74,7 +76,8 @@ public:
|
||||
for (const auto &data : shapeDataForInput) {
|
||||
result << CommonTestUtils::vec2str(data) << "_";
|
||||
}
|
||||
result << shapeInputType << "_";
|
||||
result << "sizesInputType=" << sizesInputType << "_";
|
||||
result << "scalesInputType=" << scalesInputType << "_";
|
||||
result << "InterpolateMode=" << mode << "_";
|
||||
result << "CoordinateTransformMode=" << transfMode << "_";
|
||||
result << "NearestMode=" << nearMode << "_";
|
||||
@ -165,10 +168,11 @@ protected:
|
||||
std::tie(mode, transfMode, nearMode, antiAlias, padBegin, padEnd, cubeCoef) = specificParams;
|
||||
|
||||
InputShape dataShape;
|
||||
ngraph::helpers::InputLayerType shapeInputType;
|
||||
ngraph::helpers::InputLayerType sizesInputType;
|
||||
ngraph::helpers::InputLayerType scalesInputType;
|
||||
std::vector<std::vector<float>> shapeDataForInput;
|
||||
std::vector<int64_t> axes;
|
||||
std::tie(shapeCalcMode, dataShape, shapeInputType, shapeDataForInput, axes) = shapeParams;
|
||||
std::tie(shapeCalcMode, dataShape, sizesInputType, scalesInputType, shapeDataForInput, axes) = shapeParams;
|
||||
|
||||
if (shapeCalcMode == ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES) {
|
||||
scales = shapeDataForInput;
|
||||
@ -185,7 +189,10 @@ protected:
|
||||
|
||||
std::vector<InputShape> inputShapes;
|
||||
inputShapes.push_back(dataShape);
|
||||
if (shapeInputType == ngraph::helpers::InputLayerType::PARAMETER) {
|
||||
if (sizesInputType == ngraph::helpers::InputLayerType::PARAMETER) {
|
||||
inputShapes.push_back(InputShape({static_cast<int64_t>(axes.size())}, std::vector<ov::Shape>(dataShape.second.size(), {axes.size()})));
|
||||
}
|
||||
if (scalesInputType == ngraph::helpers::InputLayerType::PARAMETER) {
|
||||
inputShapes.push_back(InputShape({static_cast<int64_t>(axes.size())}, std::vector<ov::Shape>(dataShape.second.size(), {axes.size()})));
|
||||
}
|
||||
|
||||
@ -195,24 +202,37 @@ protected:
|
||||
|
||||
std::shared_ptr<ov::Node> sizesInput, scalesInput;
|
||||
if (shapeCalcMode == ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES) {
|
||||
if (shapeInputType == ngraph::helpers::InputLayerType::PARAMETER) {
|
||||
if (scalesInputType == ngraph::helpers::InputLayerType::PARAMETER) {
|
||||
auto paramNode = std::make_shared<ngraph::opset3::Parameter>(ngraph::element::Type_t::f32, ov::Shape{scales.front().size()});
|
||||
params.push_back(paramNode);
|
||||
scalesInput = paramNode;
|
||||
} else {
|
||||
scalesInput = std::make_shared<ngraph::opset3::Constant>(ngraph::element::Type_t::f32, ov::Shape{scales.front().size()}, scales.front());
|
||||
}
|
||||
sizesInput = std::make_shared<ngraph::opset3::Constant>(ngraph::element::Type_t::i32, ov::Shape{sizes.front().size()}, sizes.front());
|
||||
} else {
|
||||
if (shapeInputType == ngraph::helpers::InputLayerType::PARAMETER) {
|
||||
if (sizesInputType == ngraph::helpers::InputLayerType::PARAMETER) {
|
||||
auto paramNode = std::make_shared<ngraph::opset3::Parameter>(ngraph::element::Type_t::i32, ov::Shape{sizes.front().size()});
|
||||
params.push_back(paramNode);
|
||||
sizesInput = paramNode;
|
||||
} else {
|
||||
sizesInput = std::make_shared<ngraph::opset3::Constant>(ngraph::element::Type_t::i32, ov::Shape{sizes.front().size()}, sizes.front());
|
||||
}
|
||||
scalesInput = std::make_shared<ngraph::opset3::Constant>(ngraph::element::Type_t::f32, ov::Shape{scales.front().size()}, scales.front());
|
||||
} else {
|
||||
if (sizesInputType == ngraph::helpers::InputLayerType::PARAMETER) {
|
||||
auto paramNode = std::make_shared<ngraph::opset3::Parameter>(ngraph::element::Type_t::i32, ov::Shape{sizes.front().size()});
|
||||
params.push_back(paramNode);
|
||||
sizesInput = paramNode;
|
||||
} else {
|
||||
sizesInput = std::make_shared<ngraph::opset3::Constant>(ngraph::element::Type_t::i32, ov::Shape{sizes.front().size()}, sizes.front());
|
||||
}
|
||||
if (scalesInputType == ngraph::helpers::InputLayerType::PARAMETER) {
|
||||
auto paramNode = std::make_shared<ngraph::opset3::Parameter>(ngraph::element::Type_t::f32, ov::Shape{scales.front().size()});
|
||||
params.push_back(paramNode);
|
||||
scalesInput = paramNode;
|
||||
} else {
|
||||
scalesInput = std::make_shared<ngraph::opset3::Constant>(ngraph::element::Type_t::f32, ov::Shape{scales.front().size()}, scales.front());
|
||||
}
|
||||
}
|
||||
|
||||
auto axesInput = std::make_shared<ngraph::opset3::Constant>(ngraph::element::Type_t::i64, ov::Shape{axes.size()}, axes);
|
||||
|
||||
for (size_t i = 0; i < params.size(); i++) {
|
||||
@ -294,16 +314,34 @@ const std::vector<ShapeParams> shapeParams4D_Smoke = {
|
||||
ShapeParams{
|
||||
ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES,
|
||||
InputShape{{-1, {2, 20}, -1, -1}, {{1, 11, 4, 4}, {2, 7, 6, 5}, {1, 11, 4, 4}}},
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
ngraph::helpers::InputLayerType::PARAMETER,
|
||||
{{1.f, 1.f, 1.25f, 1.5f}, {1.f, 1.f, 1.25f, 1.25f}, {1.f, 1.f, 1.25f, 1.5f}},
|
||||
defaultAxes4D.front()
|
||||
},
|
||||
ShapeParams{
|
||||
ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES,
|
||||
InputShape{{-1, {1, 10}, -1, -1}, {{1, 2, 12, 20}}},
|
||||
ngraph::helpers::InputLayerType::PARAMETER,
|
||||
ngraph::helpers::InputLayerType::PARAMETER,
|
||||
{{1.f, 1.f, 0.5f, 2.0f}},
|
||||
defaultAxes4D.front()
|
||||
},
|
||||
ShapeParams{
|
||||
ngraph::op::v4::Interpolate::ShapeCalcMode::SIZES,
|
||||
InputShape{{-1, {2, 20}, -1, -1}, {{1, 11, 4, 4}, {2, 7, 6, 5}, {1, 11, 4, 4}}},
|
||||
ngraph::helpers::InputLayerType::PARAMETER,
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
{{1, 11, 5, 6}, {2, 7, 8, 7}, {1, 11, 5, 6}},
|
||||
defaultAxes4D.front()
|
||||
},
|
||||
ShapeParams{
|
||||
ngraph::op::v4::Interpolate::ShapeCalcMode::SIZES,
|
||||
InputShape{{-1, {1, 10}, -1, -1}, {{1, 2, 12, 20}}},
|
||||
ngraph::helpers::InputLayerType::PARAMETER,
|
||||
ngraph::helpers::InputLayerType::PARAMETER,
|
||||
{{1, 2, 24, 10}},
|
||||
defaultAxes4D.front()
|
||||
}
|
||||
};
|
||||
|
||||
@ -312,6 +350,7 @@ const std::vector<ShapeParams> shapeParams4D_Full = {
|
||||
ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES,
|
||||
InputShape{{-1, {2, 20}, -1, -1}, {{1, 11, 4, 4}, {2, 7, 6, 5}, {1, 11, 4, 4}}},
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
{{1.f, 1.f, 1.25f, 1.5f}},
|
||||
defaultAxes4D.front()
|
||||
},
|
||||
@ -319,6 +358,7 @@ const std::vector<ShapeParams> shapeParams4D_Full = {
|
||||
ngraph::op::v4::Interpolate::ShapeCalcMode::SIZES,
|
||||
InputShape{{-1, {2, 20}, -1, -1}, {{1, 11, 4, 4}}},
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
{{1, 11, 5, 6}},
|
||||
defaultAxes4D.front()
|
||||
}
|
||||
@ -466,17 +506,35 @@ const std::vector<ShapeParams> shapeParams5D_Smoke = {
|
||||
ShapeParams{
|
||||
ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES,
|
||||
InputShape{{-1, {2, 20}, -1, -1, -1}, {{1, 11, 4, 4, 4}, {2, 7, 6, 5, 8}, {1, 11, 4, 4, 4}}},
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
ngraph::helpers::InputLayerType::PARAMETER,
|
||||
{{1.f, 1.f, 1.25f, 1.5f, 0.5f}, {1.f, 1.f, 1.25f, 1.25f, 1.25f}, {1.f, 1.f, 1.25f, 1.5f, 0.5f}},
|
||||
defaultAxes5D.front()
|
||||
},
|
||||
ShapeParams{
|
||||
ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES,
|
||||
InputShape{{-1, {2, 10}, -1, -1, -1}, {{1, 4, 2, 3, 4}}},
|
||||
ngraph::helpers::InputLayerType::PARAMETER,
|
||||
ngraph::helpers::InputLayerType::PARAMETER,
|
||||
{{1.f, 1.f, 1.5f, 2.f, 0.5f}},
|
||||
defaultAxes5D.front()
|
||||
},
|
||||
ShapeParams{
|
||||
ngraph::op::v4::Interpolate::ShapeCalcMode::SIZES,
|
||||
InputShape{{-1, {2, 20}, -1, -1, -1}, {{1, 11, 4, 4, 4}, {2, 7, 6, 5, 8}, {1, 11, 4, 4, 4}}},
|
||||
ngraph::helpers::InputLayerType::PARAMETER,
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
{{1, 11, 5, 6, 2}, {2, 7, 8, 7, 4}, {1, 11, 5, 6, 2}},
|
||||
defaultAxes5D.front()
|
||||
},
|
||||
ShapeParams{
|
||||
ngraph::op::v4::Interpolate::ShapeCalcMode::SIZES,
|
||||
InputShape{{-1, {2, 10}, -1, -1, -1}, {{1, 4, 2, 3, 4}}},
|
||||
ngraph::helpers::InputLayerType::PARAMETER,
|
||||
ngraph::helpers::InputLayerType::PARAMETER,
|
||||
{{1, 4, 4, 1, 6}},
|
||||
defaultAxes5D.front()
|
||||
},
|
||||
};
|
||||
|
||||
const std::vector<ShapeParams> shapeParams5D_Full = {
|
||||
@ -484,6 +542,7 @@ const std::vector<ShapeParams> shapeParams5D_Full = {
|
||||
ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES,
|
||||
InputShape{{-1, {2, 20}, -1, -1, -1}, {{1, 11, 4, 4, 4}, {2, 7, 6, 5, 8}, {1, 11, 4, 4, 4}}},
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
{{1.f, 1.f, 1.25f, 1.5f, 0.5f}},
|
||||
defaultAxes5D.front()
|
||||
},
|
||||
@ -491,6 +550,7 @@ const std::vector<ShapeParams> shapeParams5D_Full = {
|
||||
ngraph::op::v4::Interpolate::ShapeCalcMode::SIZES,
|
||||
InputShape{{-1, {2, 20}, -1, -1, -1}, {{1, 11, 4, 4, 4}, {1, 11, 5, 5, 8}, {1, 11, 4, 4, 4}}},
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
{{1, 11, 5, 6, 4}},
|
||||
defaultAxes5D.front()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user