[GPU] Pad shape infer support (#12654)
* [GPU] Align Pad parameters with ngraph * [GPU] Pad shape infer support
This commit is contained in:
parent
0053ed1a65
commit
5128f20cfa
@ -17,7 +17,6 @@ void shape_infer(const Pad* op,
|
||||
const std::vector<T>& input_shapes,
|
||||
std::vector<T>& output_shapes,
|
||||
const std::map<size_t, std::shared_ptr<ngraph::runtime::HostTensor>>& constant_data = {}) {
|
||||
using DimType = typename std::iterator_traits<typename T::iterator>::value_type;
|
||||
constexpr bool is_dynamic_shape = std::is_base_of<ov::PartialShape, T>::value;
|
||||
|
||||
NODE_VALIDATION_CHECK(op, (input_shapes.size() == 3 || input_shapes.size() == 4) && output_shapes.size() == 1);
|
||||
|
@ -5,6 +5,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#include "primitive.hpp"
|
||||
#include "openvino/core/coordinate_diff.hpp"
|
||||
|
||||
namespace cldnn {
|
||||
/// @addtogroup cpp_api C++ API
|
||||
@ -14,93 +15,71 @@ namespace cldnn {
|
||||
/// @addtogroup cpp_primitives Primitives
|
||||
/// @{
|
||||
|
||||
/// @brief Type of border that will be added to the input by border layer / primitive.
|
||||
enum class border_type : std::int32_t {
|
||||
/// @brief All points in the border are set to constant value.
|
||||
constant,
|
||||
zero,
|
||||
/// @brief Border is constructed as an mirror of image (edge is also mirrored).
|
||||
/// @details Size of border in any dimension cannot be larger than size of
|
||||
/// input in the same dimension.
|
||||
mirror,
|
||||
/// @brief Border is constructed as an mirror of image (edge is NOT mirrored).
|
||||
/// @details Size of border in any dimension cannot be larger than size of
|
||||
/// input in the same dimension decreased by @c 1.
|
||||
mirror_101,
|
||||
/// @brief Border is constructed as an replication of edge.
|
||||
/// @details Size of border in any dimension cannot be larger than size of
|
||||
/// input in the same dimension.
|
||||
edge
|
||||
};
|
||||
|
||||
/// @brief Adds border around input.
|
||||
///
|
||||
/// @details Applies border of specified type around input data. The size of output data is increased
|
||||
/// by @c left_top_sizes and by @right_bottom_sizes.
|
||||
/// by @c pads_begin and by @c pads_end.
|
||||
/// @n
|
||||
/// @n@b Requirements:
|
||||
/// @n - @c left_top_sizes and @c right_bottom_sizes must be non-negative on all dimensions and compatible
|
||||
/// @n - @c pads_begin and @c pads_end must be non-negative on all dimensions and compatible
|
||||
/// with size of input (describe the same dimensions).
|
||||
/// @n - For @c border_type equal to @c cldnn_border_mirror, @c left_top_sizes and @c right_bottom_sizes
|
||||
/// @n - For @c PadMode equal to @c SYMMETRIC, @c pads_begin and @c pads_end
|
||||
/// must be lower than or equal to size of input on corresponding dimension (for all dimensions)
|
||||
/// @n - For @c border_type equal to @c cldnn_border_mirror_101, @c left_top_sizes and @c right_bottom_sizes
|
||||
/// @n - For @c PadMode equal to @c REFLECT, @c pads_begin and @c pads_end
|
||||
/// must be lower than size of input on corresponding dimension (for all dimensions)
|
||||
/// @n Breaking any of this conditions will cause exeption throw.
|
||||
struct border : public primitive_base<border> {
|
||||
CLDNN_DECLARE_PRIMITIVE(border)
|
||||
|
||||
/// @brief Constructs border primitive / layer.
|
||||
/// @brief Constructs border primitive / layer with static pads.
|
||||
///
|
||||
/// @param id An identifier of new primitive.
|
||||
/// @param input An identifier of primitive which is an input for newly created
|
||||
/// border primitive.
|
||||
/// @param left_top_sizes Sizes of border that needs to be added from left
|
||||
/// @param pads_begin Sizes of border that needs to be added from left
|
||||
/// (in X dimension) and from top (in Y dimension).
|
||||
/// @param right_bottom_sizes Sizes of border that needs to be added from right
|
||||
/// @param pads_end Sizes of border that needs to be added from right
|
||||
/// (in X dimension) and from bottom (in Y dimension).
|
||||
/// @param type Type of added border.
|
||||
/// @param border_value Value of elements which is used for paddings
|
||||
/// @param pad_mode Value of elements which is used for paddings
|
||||
/// @param output_padding Optional padding for output from primitive.
|
||||
border(const primitive_id& id,
|
||||
const primitive_id& input,
|
||||
const tensor& left_top_sizes = {0, 0, 0, 0},
|
||||
const tensor& right_bottom_sizes = {0, 0, 0, 0},
|
||||
const border_type type = border_type::constant,
|
||||
const float border_value = 0.0f,
|
||||
const ov::CoordinateDiff& pads_begin = {0, 0, 0, 0},
|
||||
const ov::CoordinateDiff& pads_end = {0, 0, 0, 0},
|
||||
const ov::op::PadMode pad_mode = ov::op::PadMode::CONSTANT,
|
||||
const float pad_value = 0.0f,
|
||||
const primitive_id& ext_prim_id = "",
|
||||
const padding& output_padding = padding())
|
||||
: primitive_base(id, {input}, ext_prim_id, output_padding),
|
||||
left_top_sizes(left_top_sizes),
|
||||
right_bottom_sizes(right_bottom_sizes),
|
||||
type(type),
|
||||
border_value(border_value) {}
|
||||
pads_begin(pads_begin),
|
||||
pads_end(pads_end),
|
||||
pad_mode(pad_mode),
|
||||
pad_value(pad_value) {}
|
||||
|
||||
/// @brief Constructs border primitive / layer.
|
||||
///
|
||||
/// @param id An identifier of new primitive.
|
||||
/// @param input An identifier of primitive which is an input for newly created
|
||||
/// border primitive.
|
||||
/// @param x_y_sizes Sizes of border that needs to be added from left and right
|
||||
/// (in X dimension) and from top and bottom (in Y dimension).
|
||||
/// Created border is simmetric (the same size of border applied
|
||||
/// from both sides of input).
|
||||
/// @param type Type of added border.
|
||||
/// @param output_padding Optional padding for output from primitive.
|
||||
/// @brief Constructs border primitive / layer with dynamic pads.
|
||||
border(const primitive_id& id,
|
||||
const primitive_id& input,
|
||||
const tensor& x_y_sizes,
|
||||
const border_type type = border_type::constant,
|
||||
const primitive_id& pads_begin_id,
|
||||
const primitive_id& pads_end_id,
|
||||
const ov::op::PadMode pad_mode = ov::op::PadMode::CONSTANT,
|
||||
const float pad_value = 0.0f,
|
||||
const primitive_id& ext_prim_id = "",
|
||||
const padding& output_padding = padding())
|
||||
: border(id, input, x_y_sizes, x_y_sizes, type, 0.0f, ext_prim_id, output_padding) {}
|
||||
: primitive_base(id, {input, pads_begin_id, pads_end_id}, ext_prim_id, output_padding),
|
||||
pads_begin({}),
|
||||
pads_end({}),
|
||||
pad_mode(pad_mode),
|
||||
pad_value(pad_value) {}
|
||||
|
||||
/// @brief Sizes of border that needs to be added from left (in X dimension) and from top (in Y dimension).
|
||||
tensor left_top_sizes;
|
||||
ov::CoordinateDiff pads_begin;
|
||||
/// @brief Sizes of border that needs to be added from right (in X dimension) and from bottom (in Y dimension).
|
||||
tensor right_bottom_sizes;
|
||||
ov::CoordinateDiff pads_end;
|
||||
/// @brief Type of border that needs to be added to the input.
|
||||
border_type type;
|
||||
ov::op::PadMode pad_mode;
|
||||
/// @brief Border value that is used in constant mode.
|
||||
float border_value;
|
||||
float pad_value;
|
||||
};
|
||||
/// @}
|
||||
/// @}
|
||||
|
@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "border_inst.h"
|
||||
#include "pad_shape_inference.hpp"
|
||||
|
||||
#include "intel_gpu/runtime/error_handler.hpp"
|
||||
#include "json_object.h"
|
||||
@ -20,51 +21,79 @@ layout border_inst::calc_output_layout(border_node const& node, kernel_impl_para
|
||||
assert(static_cast<bool>(impl_param.desc->output_data_type) == false &&
|
||||
"Output data type forcing is not supported for border_node!");
|
||||
auto input_layout = impl_param.get_input_layout();
|
||||
auto input_format = input_layout.format;
|
||||
auto desc = impl_param.typed_desc<border>();
|
||||
|
||||
auto new_size = input_layout.get_tensor();
|
||||
new_size += desc->left_top_sizes.sub(tensor(0));
|
||||
new_size += desc->right_bottom_sizes.sub(tensor(0));
|
||||
auto dims_format = format::adjust_to_rank(format::bfyx, input_layout.get_rank());
|
||||
auto new_dims = input_layout.get_dims();
|
||||
|
||||
return layout{ input_layout.data_type, input_layout.format, new_size };
|
||||
for (size_t i = 0; i < new_dims.size(); ++i) {
|
||||
new_dims[i] += desc->pads_begin[i];
|
||||
new_dims[i] += desc->pads_end[i];
|
||||
}
|
||||
return layout{ input_layout.data_type, input_format, tensor(dims_format, new_dims) };
|
||||
}
|
||||
|
||||
template<typename ShapeType>
|
||||
std::vector<layout> border_inst::calc_output_layouts(border_node const& /*node*/, const kernel_impl_params& impl_param) {
|
||||
auto desc = impl_param.typed_desc<border>();
|
||||
auto input0_layout = impl_param.get_input_layout(0);
|
||||
|
||||
auto output_type = input0_layout.data_type;
|
||||
if (impl_param.has_fused_primitives()) {
|
||||
output_type = impl_param.get_fused_output_layout().data_type;
|
||||
}
|
||||
|
||||
ov::op::v1::Pad op;
|
||||
op.set_pad_mode(desc->pad_mode);
|
||||
|
||||
ShapeType pads_shape = impl_param.input_layouts.size() > 1 ? impl_param.get_input_layout(1).get<ShapeType>()
|
||||
: ov::Shape{ desc->pads_begin.size() };
|
||||
std::vector<ShapeType> output_shapes = {ShapeType{}};
|
||||
std::vector<ShapeType> input_shapes = {
|
||||
input0_layout.get<ShapeType>(),
|
||||
pads_shape,
|
||||
pads_shape,
|
||||
};
|
||||
|
||||
auto& memory_deps = impl_param.memory_deps;
|
||||
std::map<size_t, ngraph::HostTensorPtr> const_data;
|
||||
|
||||
if (!memory_deps.empty()) {
|
||||
auto pads_begin_mem = memory_deps.at(1);
|
||||
cldnn::mem_lock<uint8_t, mem_lock_type::read> pads_begin_lock(pads_begin_mem, impl_param.prog.get_stream());
|
||||
const_data.emplace(1, make_host_tensor(pads_begin_mem->get_layout(), pads_begin_lock.data()));
|
||||
|
||||
auto pads_end_mem = memory_deps.at(2);
|
||||
cldnn::mem_lock<uint8_t, mem_lock_type::read> pads_end_lock(pads_end_mem, impl_param.prog.get_stream());
|
||||
const_data.emplace(2, make_host_tensor(pads_end_mem->get_layout(), pads_end_lock.data()));
|
||||
|
||||
ov::op::v1::shape_infer(&op, input_shapes, output_shapes, const_data);
|
||||
} else {
|
||||
auto pads_begin_data = desc->pads_begin;
|
||||
auto pads_begin_tensor = make_host_tensor({pads_shape, data_types::i64, format::bfyx}, static_cast<void*>(pads_begin_data.data()));
|
||||
const_data.emplace(1, pads_begin_tensor);
|
||||
|
||||
auto pads_end_data = desc->pads_end;
|
||||
auto pads_end_tensor = make_host_tensor({pads_shape, data_types::i64, format::bfyx}, static_cast<void*>(pads_end_data.data()));
|
||||
const_data.emplace(2, pads_end_tensor);
|
||||
|
||||
ov::op::v1::shape_infer(&op, input_shapes, output_shapes, const_data);
|
||||
}
|
||||
format output_format = format::adjust_to_rank(input0_layout.format, output_shapes[0].size());
|
||||
|
||||
return { layout{output_shapes[0], output_type, output_format} };
|
||||
}
|
||||
|
||||
std::string border_inst::to_string(border_node const& node) {
|
||||
auto desc = node.get_primitive();
|
||||
|
||||
const auto& left_top_sizes = desc->left_top_sizes.sub({0, 0, 0, 0});
|
||||
const auto& right_bottom_sizes = desc->right_bottom_sizes.sub({0, 0, 0, 0});
|
||||
const auto& border_value = std::to_string(desc->border_value);
|
||||
|
||||
const char* border_type_str = "unknown";
|
||||
switch (desc->type) {
|
||||
case border_type::zero:
|
||||
border_type_str = "zero";
|
||||
break;
|
||||
case border_type::constant:
|
||||
border_type_str = "constant";
|
||||
break;
|
||||
case border_type::edge:
|
||||
border_type_str = "edge";
|
||||
break;
|
||||
case border_type::mirror:
|
||||
border_type_str = "mirror";
|
||||
break;
|
||||
case border_type::mirror_101:
|
||||
border_type_str = "mirror-101";
|
||||
break;
|
||||
default:
|
||||
border_type_str = "unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
auto node_info = node.desc_to_json();
|
||||
|
||||
json_composite border_info;
|
||||
border_info.add("left/top sizes", left_top_sizes.to_string());
|
||||
border_info.add("right/bottom sizes", right_bottom_sizes.to_string());
|
||||
border_info.add("border type", border_type_str);
|
||||
border_info.add("border value", border_value);
|
||||
border_info.add("pads_begin", desc->pads_begin);
|
||||
border_info.add("pads_end", desc->pads_end);
|
||||
border_info.add("pad mode", desc->pad_mode);
|
||||
border_info.add("pad value", std::to_string(desc->pad_value));
|
||||
|
||||
node_info->add("border info", border_info);
|
||||
|
||||
@ -76,58 +105,47 @@ std::string border_inst::to_string(border_node const& node) {
|
||||
border_inst::typed_primitive_inst(network& network, border_node const& node) : parent(network, node) {
|
||||
auto input_layout = node.input().get_output_layout();
|
||||
|
||||
const auto& input_sizes = input_layout.get_tensor();
|
||||
|
||||
auto lt_sizes = argument.left_top_sizes.sub(tensor(0));
|
||||
auto rb_sizes = argument.right_bottom_sizes.sub(tensor(0));
|
||||
auto b_type = argument.type;
|
||||
|
||||
tensor null_tensor = tensor(0);
|
||||
const auto& input_sizes = input_layout.get_dims();
|
||||
auto pad_mode = argument.pad_mode;
|
||||
|
||||
// Check if sizes of border are in proper range.
|
||||
CLDNN_ERROR_TENSOR_SIZES_LESS_THAN(node.id(),
|
||||
"Left/Top border sizes",
|
||||
lt_sizes,
|
||||
"0 value",
|
||||
null_tensor,
|
||||
"Invalid border size: negative value");
|
||||
CLDNN_ERROR_TENSOR_SIZES_LESS_THAN(node.id(),
|
||||
"Right/Bottom border sizes",
|
||||
rb_sizes,
|
||||
"0 value",
|
||||
null_tensor,
|
||||
"Invalid border size: negative value");
|
||||
CLDNN_ERROR_BOOL(node.id(),
|
||||
"pads_begin border sizes",
|
||||
std::any_of(argument.pads_begin.begin(), argument.pads_begin.end(),
|
||||
[](std::ptrdiff_t pad) {
|
||||
return pad < 0;
|
||||
}),
|
||||
"Invalid border size: negative value");
|
||||
CLDNN_ERROR_BOOL(node.id(),
|
||||
"pads_end border sizes",
|
||||
std::any_of(argument.pads_end.begin(), argument.pads_end.end(),
|
||||
[](std::ptrdiff_t pad) {
|
||||
return pad < 0;
|
||||
}),
|
||||
"Invalid border size: negative value");
|
||||
|
||||
if (b_type == border_type::mirror) {
|
||||
CLDNN_ERROR_TENSOR_SIZES_GREATER_THAN(node.id(),
|
||||
"Left/Top border sizes",
|
||||
lt_sizes,
|
||||
"input_sizes",
|
||||
input_sizes,
|
||||
"Not enough data in input to create mirror border of specified size");
|
||||
CLDNN_ERROR_TENSOR_SIZES_GREATER_THAN(node.id(),
|
||||
"Right/Bottom border sizes",
|
||||
rb_sizes,
|
||||
"input_sizes",
|
||||
input_sizes,
|
||||
"Not enough data in input to create mirror border of specified size");
|
||||
} else if (b_type == border_type::mirror_101) {
|
||||
auto reduced_input_sizes = input_sizes;
|
||||
reduced_input_sizes -= tensor(1);
|
||||
reduced_input_sizes = tensor::max(reduced_input_sizes, tensor());
|
||||
if (pad_mode == ov::op::PadMode::SYMMETRIC) {
|
||||
bool valid_pads = true;
|
||||
|
||||
CLDNN_ERROR_TENSOR_SIZES_GREATER_THAN(node.id(),
|
||||
"Left/Top border sizes",
|
||||
lt_sizes,
|
||||
"input_sizes - 1",
|
||||
reduced_input_sizes,
|
||||
"Not enough data in input to create mirror-101 border of specified size");
|
||||
CLDNN_ERROR_TENSOR_SIZES_GREATER_THAN(node.id(),
|
||||
"Right/Bottom border sizes",
|
||||
rb_sizes,
|
||||
"input_sizes - 1",
|
||||
reduced_input_sizes,
|
||||
"Not enough data in input to create mirror-101 border of specified size");
|
||||
for (size_t i = 0; i < input_sizes.size(); ++i) {
|
||||
valid_pads &= argument.pads_begin[i] <= input_sizes[i];
|
||||
valid_pads &= argument.pads_end[i] <= input_sizes[i];
|
||||
}
|
||||
CLDNN_ERROR_BOOL(node.id(),
|
||||
"pads_begin/pads_end border sizes",
|
||||
!valid_pads,
|
||||
"Not enough data in input to create SYMMETRIC border of specified size");
|
||||
} else if (pad_mode == ov::op::PadMode::REFLECT) {
|
||||
bool valid_pads = true;
|
||||
|
||||
for (size_t i = 0; i < input_sizes.size(); ++i) {
|
||||
valid_pads &= argument.pads_begin[i] < input_sizes[i];
|
||||
valid_pads &= argument.pads_end[i] < input_sizes[i];
|
||||
}
|
||||
CLDNN_ERROR_BOOL(node.id(),
|
||||
"pads_begin/pads_end border sizes",
|
||||
!valid_pads,
|
||||
"Not enough data in input to create REFLECT border of specified size");
|
||||
}
|
||||
}
|
||||
} // namespace cldnn
|
||||
|
@ -88,22 +88,18 @@ void handle_input_padding::run(program& p) {
|
||||
primitive_id input_id = convolution_prim->input[0];
|
||||
primitive_id border_id = input_id + "_border_" + convolution_prim->id;
|
||||
|
||||
tensor padding_above = tensor(0);
|
||||
tensor padding_below = tensor(0);
|
||||
|
||||
padding_above.spatial[0] = pa_x;
|
||||
padding_above.spatial[1] = pa_y;
|
||||
padding_above.spatial[2] = pa_z;
|
||||
|
||||
padding_below.spatial[0] = pb_x;
|
||||
padding_below.spatial[1] = pb_y;
|
||||
padding_below.spatial[2] = pb_z;
|
||||
size_t rank = node->get_input_layouts().front().get_rank();
|
||||
if (pad_above.size() < rank) {
|
||||
size_t zeros_to_add = rank - pad_above.size();
|
||||
pad_above.insert(pad_above.begin(), zeros_to_add, 0);
|
||||
pad_below.insert(pad_below.begin(), zeros_to_add, 0);
|
||||
}
|
||||
|
||||
auto b_prim = std::make_shared<border>(border_id,
|
||||
input_id,
|
||||
padding_above,
|
||||
padding_below,
|
||||
border_type::constant,
|
||||
pad_above,
|
||||
pad_below,
|
||||
ov::op::PadMode::CONSTANT,
|
||||
0.0f);
|
||||
|
||||
auto& b_prim_node = p.get_or_create(b_prim);
|
||||
|
@ -29,27 +29,31 @@ struct border_impl : typed_primitive_impl_ocl<border> {
|
||||
auto b_optional_params =
|
||||
get_default_optional_params<kernel_selector::border_optional_params>(arg.get_program());
|
||||
|
||||
b_params.lt_sizes = convert_dim_vector(desc->left_top_sizes);
|
||||
b_params.rb_sizes = convert_dim_vector(desc->right_bottom_sizes);
|
||||
b_params.border_value = desc->border_value;
|
||||
format pads_format = format::adjust_to_rank(format::bfyx, arg.get_input_layouts().front().get_rank());
|
||||
std::vector<tensor::value_type> pads_begin(desc->pads_begin.begin(), desc->pads_begin.end());
|
||||
std::vector<tensor::value_type> pads_end(desc->pads_end.begin(), desc->pads_end.end());
|
||||
|
||||
switch (desc->type) {
|
||||
case border_type::constant:
|
||||
b_params.lt_sizes = convert_dim_vector(tensor(pads_format, pads_begin, 0));
|
||||
b_params.rb_sizes = convert_dim_vector(tensor(pads_format, pads_end, 0));
|
||||
b_params.border_value = desc->pad_value;
|
||||
|
||||
switch (desc->pad_mode) {
|
||||
case ov::op::PadMode::CONSTANT:
|
||||
b_params.b_type = kernel_selector::border_type::CONSTANT;
|
||||
break;
|
||||
case border_type::edge:
|
||||
case ov::op::PadMode::EDGE:
|
||||
b_params.b_type = kernel_selector::border_type::EDGE;
|
||||
break;
|
||||
case border_type::mirror:
|
||||
case ov::op::PadMode::SYMMETRIC:
|
||||
b_params.b_type = kernel_selector::border_type::MIRROR;
|
||||
break;
|
||||
case border_type::mirror_101:
|
||||
case ov::op::PadMode::REFLECT:
|
||||
b_params.b_type = kernel_selector::border_type::MIRROR_101;
|
||||
break;
|
||||
default:
|
||||
assert(
|
||||
false &&
|
||||
"Encountered unhandled enum case: border_type during translation to kernel selector enumeration.");
|
||||
"Encountered unhandled enum case: PadMode during translation to kernel selector enumeration.");
|
||||
}
|
||||
|
||||
auto& kernel_selector = kernel_selector::border_kernel_selector::Instance();
|
||||
|
@ -33,6 +33,8 @@ class typed_primitive_inst<border> : public typed_primitive_inst_base<border> {
|
||||
|
||||
public:
|
||||
static layout calc_output_layout(border_node const& node, kernel_impl_params const& impl_param);
|
||||
template<typename ShapeType>
|
||||
static std::vector<layout> calc_output_layouts(border_node const& /*node*/, const kernel_impl_params& impl_param);
|
||||
static std::string to_string(border_node const& node);
|
||||
typed_primitive_inst(network& network, border_node const& node);
|
||||
};
|
||||
|
@ -22,7 +22,7 @@ struct gather_tree_optional_params : optional_params {
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BorderKernelBase
|
||||
// GatherTreeKernelBase
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
class GatherTreeKernelBase : public KernelBaseOpenCL {
|
||||
public:
|
||||
|
@ -36,7 +36,7 @@ struct gemm_optional_params : optional_params {
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BorderKernelBase
|
||||
// GemmKernelBase
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
class GemmKernelBase : public KernelBaseOpenCL {
|
||||
public:
|
||||
|
@ -13,43 +13,13 @@
|
||||
namespace ov {
|
||||
namespace intel_gpu {
|
||||
|
||||
static cldnn::border_type GetBorderType(ngraph::op::PadMode mode) {
|
||||
switch (mode) {
|
||||
case ngraph::op::PadMode::CONSTANT: return cldnn::border_type::constant;
|
||||
case ngraph::op::PadMode::EDGE: return cldnn::border_type::edge;
|
||||
case ngraph::op::PadMode::REFLECT: return cldnn::border_type::mirror_101;
|
||||
case ngraph::op::PadMode::SYMMETRIC: return cldnn::border_type::mirror;
|
||||
default: IE_THROW() << "Invalid border mode " << mode << " in layer ";
|
||||
}
|
||||
return cldnn::border_type::constant;
|
||||
}
|
||||
|
||||
static std::vector<int32_t> GetPermuteOrder(const ngraph::CoordinateDiff& ie_order) {
|
||||
std::vector<int32_t> cldnn_order(ie_order.begin(), ie_order.end());
|
||||
|
||||
// 1. Align to min. 4 sizes
|
||||
if (cldnn_order.size() < 4) {
|
||||
const auto zeros_to_add = 4 - ie_order.size();
|
||||
cldnn_order.insert(cldnn_order.end(), zeros_to_add, 0);
|
||||
}
|
||||
|
||||
// 2. Swap spatial positions
|
||||
for (int i = 0; i < (static_cast<int32_t>(cldnn_order.size()) - 2) / 2; i++) {
|
||||
std::swap(cldnn_order[2 + i], cldnn_order[1 + cldnn_order.size() - (2 + i)]);
|
||||
}
|
||||
|
||||
return cldnn_order;
|
||||
}
|
||||
|
||||
static void CreatePadOp(Program& p, const std::shared_ptr<ngraph::op::v1::Pad>& op) {
|
||||
p.ValidateInputs(op, {3, 4});
|
||||
auto inputPrimitives = p.GetInputPrimitiveIDs(op);
|
||||
std::string layerName = layer_type_name_ID(op);
|
||||
size_t rank = std::max(op->get_input_shape(0).size(), static_cast<size_t>(4));
|
||||
|
||||
auto pads_begin = cldnn::tensor(GetPermuteOrder(op->get_pads_begin()), 0);
|
||||
auto pads_end = cldnn::tensor(GetPermuteOrder(op->get_pads_end()), 0);
|
||||
float pad_value = 0.f;
|
||||
|
||||
if (op->get_input_size() == 4) {
|
||||
auto const_node = std::dynamic_pointer_cast<ngraph::op::v0::Constant>(op->get_input_node_shared_ptr(3));
|
||||
if (!const_node) {
|
||||
@ -58,13 +28,20 @@ static void CreatePadOp(Program& p, const std::shared_ptr<ngraph::op::v1::Pad>&
|
||||
ngraph::op::util::get_single_value(const_node, pad_value);
|
||||
}
|
||||
|
||||
cldnn::border_type border_mode = GetBorderType(op->get_pad_mode());
|
||||
auto pads_begin = op->get_pads_begin();
|
||||
auto pads_end = op->get_pads_end();
|
||||
|
||||
if (pads_begin.size() < rank) {
|
||||
size_t zeros_to_add = rank - pads_begin.size();
|
||||
pads_begin.insert(pads_begin.end(), zeros_to_add, 0);
|
||||
pads_end.insert(pads_end.end(), zeros_to_add, 0);
|
||||
}
|
||||
|
||||
auto tilePrim = cldnn::border(layerName,
|
||||
inputPrimitives[0],
|
||||
pads_begin,
|
||||
pads_end,
|
||||
border_mode,
|
||||
op->get_pad_mode(),
|
||||
pad_value,
|
||||
op->get_friendly_name());
|
||||
|
||||
|
117
src/plugins/intel_gpu/tests/shape_infer/pad_si_test.cpp
Normal file
117
src/plugins/intel_gpu/tests/shape_infer/pad_si_test.cpp
Normal file
@ -0,0 +1,117 @@
|
||||
// Copyright (C) 2018-2022 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/border.hpp>
|
||||
#include <intel_gpu/primitives/data.hpp>
|
||||
|
||||
#include "border_inst.h"
|
||||
|
||||
#include "program_wrapper.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace cldnn;
|
||||
using namespace ::tests;
|
||||
|
||||
namespace shape_infer_tests {
|
||||
|
||||
struct pad_test_params {
|
||||
layout in_layout;
|
||||
layout pads_begin_layout;
|
||||
ov::CoordinateDiff pads_begin_data;
|
||||
layout pads_end_layout;
|
||||
ov::CoordinateDiff pads_end_data;
|
||||
ov::op::PadMode pad_mode;
|
||||
float pad_value;
|
||||
layout expected_layout;
|
||||
};
|
||||
|
||||
class pad_test_three_input : public testing::TestWithParam<pad_test_params> { };
|
||||
|
||||
TEST_P(pad_test_three_input, shape_infer) {
|
||||
auto p = GetParam();
|
||||
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto input_prim = std::make_shared<input_layout>("input", p.in_layout);
|
||||
auto pads_begin_prim = std::make_shared<input_layout>("pads_begin", p.pads_begin_layout);
|
||||
auto pads_end_prim = std::make_shared<input_layout>("pads_end", p.pads_end_layout);
|
||||
|
||||
auto border_prim = std::make_shared<border>("output", "input",
|
||||
"pads_begin", "pads_end",
|
||||
p.pad_mode, p.pad_value);
|
||||
cldnn::program prog(engine);
|
||||
|
||||
auto pads_begin_mem = engine.allocate_memory(p.pads_begin_layout);
|
||||
auto pads_end_mem = engine.allocate_memory(p.pads_end_layout);
|
||||
set_values(pads_begin_mem, p.pads_begin_data);
|
||||
set_values(pads_end_mem, p.pads_end_data);
|
||||
|
||||
auto& input_node = prog.get_or_create(input_prim);
|
||||
auto& pads_begin_node = prog.get_or_create(pads_begin_prim);
|
||||
auto& pads_end_node = prog.get_or_create(pads_end_prim);
|
||||
auto& border_node = prog.get_or_create(border_prim);
|
||||
program_wrapper::add_connection(prog, input_node, border_node);
|
||||
program_wrapper::add_connection(prog, pads_begin_node, border_node);
|
||||
program_wrapper::add_connection(prog, pads_end_node, border_node);
|
||||
|
||||
auto params = border_node.get_kernel_impl_params();
|
||||
params->memory_deps = {{1, pads_begin_mem}, {2, pads_end_mem}}; //mb add pad_value
|
||||
auto res = border_inst::calc_output_layouts<ov::PartialShape>(border_node, *params);
|
||||
|
||||
ASSERT_EQ(res.size(), 1);
|
||||
ASSERT_EQ(res[0], p.expected_layout);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke, pad_test_three_input,
|
||||
testing::ValuesIn(std::vector<pad_test_params>{
|
||||
{
|
||||
layout{ov::PartialShape{1, 3, 32, 40}, data_types::f32, format::bfyx},
|
||||
layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {0, 5, 2, 1},
|
||||
layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {1, 0, 3, 7},
|
||||
ov::op::PadMode::CONSTANT, 1.f,
|
||||
layout{ov::PartialShape{2, 8, 37, 48}, data_types::f32, format::bfyx}
|
||||
},
|
||||
}));
|
||||
|
||||
class pad_test_single_input : public testing::TestWithParam<pad_test_params> { };
|
||||
|
||||
TEST_P(pad_test_single_input, shape_infer) {
|
||||
auto p = GetParam();
|
||||
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto input_prim = std::make_shared<input_layout>("input", p.in_layout);
|
||||
|
||||
auto border_prim = std::make_shared<border>("output", "input",
|
||||
p.pads_begin_data, p.pads_end_data,
|
||||
p.pad_mode, p.pad_value);
|
||||
cldnn::program prog(engine);
|
||||
|
||||
auto& input_node = prog.get_or_create(input_prim);
|
||||
auto& border_node = prog.get_or_create(border_prim);
|
||||
program_wrapper::add_connection(prog, input_node, border_node);
|
||||
|
||||
auto res = border_inst::calc_output_layouts<ov::PartialShape>(border_node, *border_node.get_kernel_impl_params());
|
||||
|
||||
ASSERT_EQ(res.size(), 1);
|
||||
ASSERT_EQ(res[0], p.expected_layout);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke, pad_test_single_input,
|
||||
testing::ValuesIn(std::vector<pad_test_params>{
|
||||
{
|
||||
layout{ov::PartialShape{1, 3, 32, 40}, data_types::f32, format::bfyx},
|
||||
layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {0, 5, 2, 1},
|
||||
layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {1, 0, 3, 7},
|
||||
ov::op::PadMode::CONSTANT, 1.f,
|
||||
layout{ov::PartialShape{2, 8, 37, 48}, data_types::f32, format::bfyx}
|
||||
},
|
||||
}));
|
||||
|
||||
} // shape_infer_tests
|
@ -39,7 +39,7 @@ static int mult(T arr) {
|
||||
}
|
||||
|
||||
#define PAD_MODES \
|
||||
border_type::constant, border_type::edge, border_type::mirror, border_type::mirror_101 //,border_type::zero
|
||||
ov::op::PadMode::CONSTANT, ov::op::PadMode::EDGE, ov::op::PadMode::SYMMETRIC, ov::op::PadMode::REFLECT
|
||||
#define FORMATS \
|
||||
format::type::bfyx, format::type::yxfb, format::type::b_fs_yx_fsv4, format::type::b_fs_yx_fsv16, \
|
||||
format::type::b_fs_yx_fsv32, format::type::bs_fs_yx_bsv4_fsv2, format::type::bs_fs_yx_bsv16_fsv16, \
|
||||
@ -47,7 +47,7 @@ static int mult(T arr) {
|
||||
format::type::bs_fs_yx_bsv8_fsv2, format::type::bs_fs_yx_bsv8_fsv4
|
||||
|
||||
template <class T>
|
||||
using border_test_param = std::tuple<border_type, // pad mode
|
||||
using border_test_param = std::tuple<ov::op::PadMode, // pad mode
|
||||
T, // pad value
|
||||
format::type, // format
|
||||
std::array<int, 4>, // shape in
|
||||
@ -57,7 +57,7 @@ using border_test_param = std::tuple<border_type, // pad mode
|
||||
template <class T, data_types T_dt>
|
||||
class border_test : public ::testing::TestWithParam<border_test_param<T>> {
|
||||
public:
|
||||
border_type pad_mode;
|
||||
ov::op::PadMode pad_mode;
|
||||
T pad_value;
|
||||
format::type fmt;
|
||||
std::array<int, 4> sh_in, cd_lt, cd_rb, sh_out;
|
||||
@ -78,8 +78,8 @@ public:
|
||||
target_topology.add(reorder("border_input", "input", fmt, T_dt),
|
||||
border("border",
|
||||
"border_input",
|
||||
tensor(format::bfyx,std::vector<tensor::value_type>(cd_lt.begin(),cd_lt.end()),0),
|
||||
tensor(format::bfyx,std::vector<tensor::value_type>(cd_rb.begin(),cd_rb.end()),0),
|
||||
ov::CoordinateDiff(cd_lt.begin(),cd_lt.end()),
|
||||
ov::CoordinateDiff(cd_rb.begin(),cd_rb.end()),
|
||||
pad_mode,
|
||||
pad_value),
|
||||
reorder("output", "border", cldnn::format::bfyx, T_dt));
|
||||
@ -92,8 +92,8 @@ public:
|
||||
base_topology.add(input_layout("input", input->get_layout()));
|
||||
base_topology.add(border("border",
|
||||
"input",
|
||||
tensor(format::bfyx, std::vector<tensor::value_type>(cd_lt.begin(), cd_lt.end()), 0),
|
||||
tensor(format::bfyx, std::vector<tensor::value_type>(cd_rb.begin(), cd_rb.end()), 0),
|
||||
ov::CoordinateDiff(cd_lt.begin(),cd_lt.end()),
|
||||
ov::CoordinateDiff(cd_rb.begin(),cd_rb.end()),
|
||||
pad_mode,
|
||||
pad_value));
|
||||
|
||||
@ -119,7 +119,7 @@ using border_test_u8 = border_test<char, data_types::u8>;
|
||||
TEST_P(border_test_u8, border_test_u8) {}
|
||||
INSTANTIATE_TEST_SUITE_P(border_test_u8,
|
||||
border_test_u8,
|
||||
testing::Combine(testing::Values(border_type::edge),
|
||||
testing::Combine(testing::Values(ov::op::PadMode::EDGE),
|
||||
testing::Values(99),
|
||||
testing::Values(format::type::bs_fs_yx_bsv16_fsv16),
|
||||
testing::Values(std::array<int, 4>{2, 3, 4, 5}),
|
||||
@ -129,7 +129,7 @@ using border_test_i32 = border_test<int, data_types::i32>;
|
||||
TEST_P(border_test_i32, border_test_i32) {}
|
||||
INSTANTIATE_TEST_SUITE_P(border_test_i32,
|
||||
border_test_i32,
|
||||
testing::Combine(testing::Values(border_type::mirror),
|
||||
testing::Combine(testing::Values(ov::op::PadMode::SYMMETRIC),
|
||||
testing::Values(11),
|
||||
testing::Values(format::type::b_fs_yx_fsv16),
|
||||
testing::Values(std::array<int, 4>{2, 3, 4, 5}),
|
||||
@ -139,7 +139,7 @@ using border_test_f16 = border_test<FLOAT16, data_types::f16>;
|
||||
TEST_P(border_test_f16, border_test_f16) {}
|
||||
INSTANTIATE_TEST_SUITE_P(border_test_f16,
|
||||
border_test_f16,
|
||||
testing::Combine(testing::Values(border_type::mirror_101),
|
||||
testing::Combine(testing::Values(ov::op::PadMode::REFLECT),
|
||||
testing::Values(FLOAT16(123)),
|
||||
testing::Values(format::type::bs_fs_yx_bsv32_fsv16),
|
||||
testing::Values(std::array<int, 4>{2, 3, 4, 5}),
|
||||
@ -149,7 +149,7 @@ using border_test_f32 = border_test<float, data_types::f32>;
|
||||
TEST_P(border_test_f32, border_test_f32) {}
|
||||
INSTANTIATE_TEST_SUITE_P(border_test_f32,
|
||||
border_test_f32,
|
||||
testing::Combine(testing::Values(border_type::edge),
|
||||
testing::Combine(testing::Values(ov::op::PadMode::EDGE),
|
||||
testing::Values(12.34),
|
||||
testing::Values(format::type::bs_fs_yx_bsv4_fsv2),
|
||||
testing::Values(std::array<int, 4>{2, 3, 4, 5}),
|
||||
@ -158,7 +158,7 @@ INSTANTIATE_TEST_SUITE_P(border_test_f32,
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(bsv16fsv16_reorder,
|
||||
border_test_i32,
|
||||
testing::Combine(testing::Values(border_type::mirror),
|
||||
testing::Combine(testing::Values(ov::op::PadMode::SYMMETRIC),
|
||||
testing::Values(99),
|
||||
testing::Values(format::type::bs_fs_yx_bsv16_fsv16),
|
||||
testing::Values(std::array<int, 4>{2, 3, 4, 5}),
|
||||
@ -168,7 +168,7 @@ INSTANTIATE_TEST_SUITE_P(bsv16fsv16_reorder,
|
||||
TEST(border_gpu, bsv16fsv16_without_reorder) {
|
||||
using T = int;
|
||||
data_types T_dt = data_types::i32;
|
||||
border_type pad_mode = border_type::constant;
|
||||
ov::op::PadMode pad_mode = ov::op::PadMode::CONSTANT;
|
||||
T pad_value = 0;
|
||||
std::array<int, 4> sh_in = {16, 16, 2, 3}, cd_lt = {0, 0, 1, 1}, cd_rb = {0, 0, 1, 1}, sh_out;
|
||||
sh_out = {sh_in[0] + cd_lt[0] + cd_rb[0],
|
||||
@ -208,8 +208,8 @@ TEST(border_gpu, bsv16fsv16_without_reorder) {
|
||||
target_topology.add(input_layout("input", input_b16f16->get_layout()));
|
||||
target_topology.add(border("border",
|
||||
"input",
|
||||
tensor(format::bfyx, std::vector<tensor::value_type>(cd_lt.begin(), cd_lt.end()), 0),
|
||||
tensor(format::bfyx, std::vector<tensor::value_type>(cd_rb.begin(), cd_rb.end()), 0),
|
||||
ov::CoordinateDiff(cd_lt.begin(),cd_lt.end()),
|
||||
ov::CoordinateDiff(cd_rb.begin(),cd_rb.end()),
|
||||
pad_mode,
|
||||
pad_value));
|
||||
cldnn::network target_network(engine, target_topology);
|
||||
@ -221,8 +221,8 @@ TEST(border_gpu, bsv16fsv16_without_reorder) {
|
||||
base_topology.add(input_layout("input", input->get_layout()));
|
||||
base_topology.add(border("border",
|
||||
"input",
|
||||
tensor(format::bfyx, std::vector<tensor::value_type>(cd_lt.begin(), cd_lt.end()), 0),
|
||||
tensor(format::bfyx, std::vector<tensor::value_type>(cd_rb.begin(), cd_rb.end()), 0),
|
||||
ov::CoordinateDiff(cd_lt.begin(),cd_lt.end()),
|
||||
ov::CoordinateDiff(cd_rb.begin(),cd_rb.end()),
|
||||
pad_mode,
|
||||
pad_value));
|
||||
cldnn::network base_network(engine, base_topology);
|
||||
@ -244,7 +244,7 @@ TEST(border_gpu, bsv16fsv16_without_reorder) {
|
||||
TEST(border_gpu, zyx_bsv16fsv16) {
|
||||
using T = int;
|
||||
data_types T_dt = data_types::i32;
|
||||
border_type pad_mode = border_type::mirror_101;
|
||||
ov::op::PadMode pad_mode = ov::op::PadMode::REFLECT;
|
||||
T pad_value = 0;
|
||||
std::array<int, 5> sh_in = {16, 16, 4, 5, 6}, cd_lt = {0, 0, 1, 1, 1}, cd_rb = {0, 0, 2, 3, 4}, sh_out;
|
||||
sh_out = {sh_in[0] + cd_lt[0] + cd_rb[0],
|
||||
@ -262,8 +262,8 @@ TEST(border_gpu, zyx_bsv16fsv16) {
|
||||
target_topology.add(reorder("border_input", "input", format::bs_fs_zyx_bsv16_fsv16, T_dt),
|
||||
border("border",
|
||||
"border_input",
|
||||
tensor(format::bfzyx, std::vector<tensor::value_type>(cd_lt.begin(), cd_lt.end()), 0),
|
||||
tensor(format::bfzyx, std::vector<tensor::value_type>(cd_rb.begin(), cd_rb.end()), 0),
|
||||
ov::CoordinateDiff(cd_lt.begin(),cd_lt.end()),
|
||||
ov::CoordinateDiff(cd_rb.begin(),cd_rb.end()),
|
||||
pad_mode,
|
||||
pad_value),
|
||||
reorder("output", "border", cldnn::format::bfzyx, T_dt));
|
||||
@ -276,8 +276,8 @@ TEST(border_gpu, zyx_bsv16fsv16) {
|
||||
base_topology.add(input_layout("input", input->get_layout()));
|
||||
base_topology.add(border("border",
|
||||
"input",
|
||||
tensor(format::bfzyx, std::vector<tensor::value_type>(cd_lt.begin(), cd_lt.end()), 0),
|
||||
tensor(format::bfzyx, std::vector<tensor::value_type>(cd_rb.begin(), cd_rb.end()), 0),
|
||||
ov::CoordinateDiff(cd_lt.begin(),cd_lt.end()),
|
||||
ov::CoordinateDiff(cd_rb.begin(),cd_rb.end()),
|
||||
pad_mode,
|
||||
pad_value));
|
||||
cldnn::network base_network(engine, base_topology);
|
||||
@ -319,9 +319,9 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_constant) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(border("output",
|
||||
"input",
|
||||
tensor(format::bfyx, {blt_size_b, blt_size_f, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfyx, {brb_size_b, brb_size_f, brb_size_y, brb_size_x}, 0),
|
||||
border_type::constant,
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::CONSTANT,
|
||||
0.0f));
|
||||
|
||||
std::vector<float> input_data = {
|
||||
@ -394,9 +394,9 @@ TEST(border_gpu, basic_fsv16_0x0x1x2_0x0x3x4_border_constant) {
|
||||
topology.add(reorder("border_input", "input", cldnn::format::b_fs_yx_fsv16, cldnn::data_types::f32),
|
||||
border("border",
|
||||
"border_input",
|
||||
tensor(format::bfyx, {blt_size_b, blt_size_f, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfyx, {brb_size_b, brb_size_f, brb_size_y, brb_size_x}, 0),
|
||||
border_type::constant,
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::CONSTANT,
|
||||
0.0f),
|
||||
reorder("output", "border", cldnn::format::yxfb, cldnn::data_types::f32));
|
||||
|
||||
@ -471,9 +471,9 @@ TEST(border_gpu, basic_bfzyx_0x0x1x01_0x0x0x0x3_border_constant) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(border("output",
|
||||
"input",
|
||||
tensor(format::bfzyx, {blt_size_b, blt_size_f, blt_size_z, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfzyx, {brb_size_b, brb_size_f, brb_size_z, brb_size_y, brb_size_x}, 0),
|
||||
border_type::constant,
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_z, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_z, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::CONSTANT,
|
||||
0.0f));
|
||||
|
||||
std::vector<float> input_data = {
|
||||
@ -578,9 +578,9 @@ TEST(border_gpu, basic_bfwzyx_0x0x0x1x0x1_0x0x0x1x0x1_border_constant) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(border("output",
|
||||
"input",
|
||||
tensor(format::bfwzyx, {blt_size_b, blt_size_f, blt_size_w, blt_size_z, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfwzyx, {brb_size_b, brb_size_f, brb_size_w, brb_size_z, brb_size_y, brb_size_x}, 0),
|
||||
border_type::constant,
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_w, blt_size_z, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_w, brb_size_z, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::CONSTANT,
|
||||
0.0f));
|
||||
|
||||
std::vector<float> input_data = {
|
||||
@ -680,9 +680,9 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_constant_non_constant) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(border("output",
|
||||
"input",
|
||||
tensor(format::bfyx, {blt_size_b, blt_size_f, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfyx, {brb_size_b, brb_size_f, brb_size_y, brb_size_x}, 0),
|
||||
border_type::constant,
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::CONSTANT,
|
||||
1.0f));
|
||||
|
||||
std::vector<float> input_data = {
|
||||
@ -754,9 +754,9 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_mirror) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(border("output",
|
||||
"input",
|
||||
tensor(format::bfyx, {blt_size_b, blt_size_f, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfyx, {brb_size_b, brb_size_f, brb_size_y, brb_size_x}, 0),
|
||||
border_type::mirror));
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::SYMMETRIC));
|
||||
|
||||
std::vector<float> input_data = {
|
||||
1, -2, 3, -4,
|
||||
@ -829,9 +829,9 @@ TEST(border_gpu, basic_bfzyx_0x0x0x0x1_0x0x0x0x1_border_mirror) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(border("output",
|
||||
"input",
|
||||
tensor(format::bfzyx, {blt_size_b, blt_size_f, blt_size_z, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfzyx, {brb_size_b, brb_size_f, brb_size_z, brb_size_y, brb_size_x}, 0),
|
||||
border_type::mirror));
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_z, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_z, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::SYMMETRIC));
|
||||
|
||||
const std::vector<size_t> sizes{ static_cast<std::size_t>(in_size_b), static_cast<std::size_t>(in_size_f),
|
||||
static_cast<std::size_t>(in_size_y), static_cast<std::size_t>(in_size_x),
|
||||
@ -907,9 +907,9 @@ TEST(border_gpu, basic_bfzyxw_0x0x0x0x1_0x0x0x0x1_border_mirror) {
|
||||
topology.add(
|
||||
border("output",
|
||||
"input",
|
||||
tensor(format::bfwzyx, {blt_size_b, blt_size_f, blt_size_w, blt_size_z, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfwzyx, {brb_size_b, brb_size_f, brb_size_w, brb_size_z, brb_size_y, brb_size_x}, 0),
|
||||
border_type::mirror));
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_w, blt_size_z, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_w, brb_size_z, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::SYMMETRIC));
|
||||
|
||||
const std::vector<size_t> sizes{ static_cast<std::size_t>(in_size_b), static_cast<std::size_t>(in_size_f),
|
||||
static_cast<std::size_t>(in_size_y), static_cast<std::size_t>(in_size_x),
|
||||
@ -981,9 +981,9 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_mirror_101) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(border("output",
|
||||
"input",
|
||||
tensor(format::bfyx, {blt_size_b, blt_size_f, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfyx, {brb_size_b, brb_size_f, brb_size_y, brb_size_x}, 0),
|
||||
border_type::mirror_101));
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::REFLECT));
|
||||
|
||||
std::vector<float> input_data = {
|
||||
1, -2, 3, -4, 4,
|
||||
@ -1057,9 +1057,9 @@ TEST(border_gpu, basic_bfzyx_0x0x0x0x1_0x0x0x0x1_border_mirror_101) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(border("output",
|
||||
"input",
|
||||
tensor(format::bfzyx, {blt_size_b, blt_size_f, blt_size_z, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfzyx, {brb_size_b, brb_size_f, brb_size_z, brb_size_y, brb_size_x}, 0),
|
||||
border_type::mirror_101));
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_z, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_z, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::REFLECT));
|
||||
|
||||
std::vector<float> input_data = {
|
||||
1, -2, 3, -4, 4,
|
||||
@ -1141,9 +1141,9 @@ TEST(border_gpu, basic_bfwzyx_0x0x0x0x1x1_0x0x0x0x1x1_border_mirror_101) {
|
||||
topology.add(
|
||||
border("output",
|
||||
"input",
|
||||
tensor(format::bfwzyx, {blt_size_b, blt_size_f, blt_size_w, blt_size_z, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfwzyx, {brb_size_b, brb_size_f, brb_size_w, brb_size_z, brb_size_y, brb_size_x}, 0),
|
||||
border_type::mirror_101));
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_w, blt_size_z, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_w, brb_size_z, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::REFLECT));
|
||||
|
||||
std::vector<float> input_data = {
|
||||
1, -2, 3, -4,
|
||||
@ -1230,9 +1230,9 @@ TEST(border_gpu, basic_yxfb_0x0x1x2_0x0x3x4_border_edge) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(border("output",
|
||||
"input",
|
||||
tensor(format::bfyx, {blt_size_b, blt_size_f, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfyx, {brb_size_b, brb_size_f, brb_size_y, brb_size_x}, 0),
|
||||
border_type::edge));
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::EDGE));
|
||||
|
||||
std::vector<float> input_data = {
|
||||
1, -2, 3, -4, 4,
|
||||
@ -1302,9 +1302,9 @@ TEST(border_gpu, basic_bfyx_2x1x2x3_1x2x3x4_border_constant) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(border("output",
|
||||
"input",
|
||||
tensor(format::bfyx, {blt_size_b, blt_size_f, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfyx, {brb_size_b, brb_size_f, brb_size_y, brb_size_x}, 0),
|
||||
border_type::constant,
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::CONSTANT,
|
||||
0.0f));
|
||||
|
||||
const std::vector<size_t> sizes{ static_cast<std::size_t>(in_size_b), static_cast<std::size_t>(in_size_f),
|
||||
@ -1371,9 +1371,9 @@ TEST(border_gpu, basic_bfyx_2x1x2x3_1x2x3x4_border_mirror) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(border("output",
|
||||
"input",
|
||||
tensor(format::bfyx, {blt_size_b, blt_size_f, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfyx, {brb_size_b, brb_size_f, brb_size_y, brb_size_x}, 0),
|
||||
border_type::mirror));
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::SYMMETRIC));
|
||||
|
||||
const std::vector<size_t> sizes{ static_cast<std::size_t>(in_size_b), static_cast<std::size_t>(in_size_f),
|
||||
static_cast<std::size_t>(in_size_y), static_cast<std::size_t>(in_size_x) };
|
||||
@ -1435,9 +1435,9 @@ TEST(border_gpu, basic_bfyx_2x1x2x3_1x2x3x4_border_mirror_101) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(border("output",
|
||||
"input",
|
||||
tensor(format::bfyx, {blt_size_b, blt_size_f, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfyx, {brb_size_b, brb_size_f, brb_size_y, brb_size_x}, 0),
|
||||
border_type::mirror_101));
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::REFLECT));
|
||||
const std::vector<size_t> sizes{ static_cast<std::size_t>(in_size_b), static_cast<std::size_t>(in_size_f),
|
||||
static_cast<std::size_t>(in_size_y), static_cast<std::size_t>(in_size_x) };
|
||||
std::vector<float> input_data = generate_rnd_real_input<float>(sizes, -8.0f, 8.0f);
|
||||
@ -1498,9 +1498,9 @@ TEST(border_gpu, basic_bfyx_2x1x2x3_1x2x3x4_border_edge) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(border("output",
|
||||
"input",
|
||||
tensor(format::bfyx, {blt_size_b, blt_size_f, blt_size_y, blt_size_x}, 0),
|
||||
tensor(format::bfyx, {brb_size_b, brb_size_f, brb_size_y, brb_size_x}, 0),
|
||||
border_type::edge));
|
||||
ov::CoordinateDiff{blt_size_b, blt_size_f, blt_size_y, blt_size_x},
|
||||
ov::CoordinateDiff{brb_size_b, brb_size_f, brb_size_y, brb_size_x},
|
||||
ov::op::PadMode::EDGE));
|
||||
const std::vector<size_t> sizes{ static_cast<std::size_t>(in_size_b), static_cast<std::size_t>(in_size_f),
|
||||
static_cast<std::size_t>(in_size_y), static_cast<std::size_t>(in_size_x) };
|
||||
std::vector<float> input_data = generate_rnd_real_input<float>(sizes, -8.0f, 8.0f);
|
||||
|
Loading…
Reference in New Issue
Block a user