Commit 8d70e2a3 authored by shssf's avatar shssf Committed by Robert Kimball

IntelGPU backend: Avoid scalar to matrix operation in clDNN (#1715)

parent 43b91a57
......@@ -626,8 +626,9 @@ bool runtime::intelgpu::IntelGPUBackend::compile(shared_ptr<Function> func)
{
do_equal_propagation(topology, get_input_name(op), get_output_name(op));
}
else if (get_input_shape(op).empty() ||
(get_input_shape(op).size() == 1 && get_input_shape(op).at(0) == 1))
else if (get_input_type(op) != element::i32 && get_input_type(op) != element::i64 &&
((get_input_shape(op).size() == 1 && get_input_shape(op).at(0) == 1) ||
get_input_shape(op).empty()))
{
const cldnn::tensor output_tensor_size =
intelgpu_space::create_cldnn_tensor(get_output_shape(op));
......
......@@ -2091,6 +2091,44 @@ NGRAPH_TEST(${BACKEND_NAME}, broadcast_vector_rowwise_int64)
EXPECT_EQ((vector<int64_t>{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}), read_vector<int64_t>(result));
}
NGRAPH_TEST(${BACKEND_NAME}, broadcast_scalar_to_matrix_int64)
{
Shape shape_a{1};
auto A = make_shared<op::Parameter>(element::i64, shape_a);
Shape shape_r{3, 1};
auto f = make_shared<Function>(make_shared<op::Broadcast>(A, shape_r, AxisSet{0}),
op::ParameterVector{A});
auto backend = runtime::Backend::create("${BACKEND_NAME}");
// Create some tensors for input/output
auto a = backend->create_tensor(element::i64, shape_a);
copy_data(a, vector<int64_t>{4});
auto result = backend->create_tensor(element::i64, shape_r);
backend->call_with_validate(f, {result}, {a});
EXPECT_EQ((vector<int64_t>{4, 4, 4}), read_vector<int64_t>(result));
}
NGRAPH_TEST(${BACKEND_NAME}, broadcast_scalar_to_matrix_int32)
{
Shape shape_a{1};
auto A = make_shared<op::Parameter>(element::i32, shape_a);
Shape shape_r{3, 1};
auto f = make_shared<Function>(make_shared<op::Broadcast>(A, shape_r, AxisSet{0}),
op::ParameterVector{A});
auto backend = runtime::Backend::create("${BACKEND_NAME}");
// Create some tensors for input/output
auto a = backend->create_tensor(element::i32, shape_a);
copy_data(a, vector<int32_t>{4});
auto result = backend->create_tensor(element::i32, shape_r);
backend->call_with_validate(f, {result}, {a});
EXPECT_EQ((vector<int32_t>{4, 4, 4}), read_vector<int32_t>(result));
}
static void broadcast_test_helper(const Shape& shape_a, const Shape& shape_r, const AxisSet& axis)
{
auto A = make_shared<op::Parameter>(element::f32, shape_a);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment