@@ -1928,6 +1928,104 @@ TEST(reorder_gpu_i32, basic)
1928
1928
ASSERT_EQ (*(a_ptr++), val);
1929
1929
}
1930
1930
1931
+ TEST (reorder_weights_gpu_i32, reorder_weights)
1932
+ {
1933
+ auto & engine = get_test_engine ();
1934
+
1935
+ layout in_layout (data_types::f32, format::bfyx, { 2 , 2 , 2 , 2 });
1936
+ layout out_layout (data_types::i32, format::oiyx, { 2 , 2 , 2 , 2 });
1937
+ auto weights_reorder_params = std::make_shared<WeightsReorderParams>(in_layout, out_layout);
1938
+
1939
+ auto input = engine.allocate_memory (in_layout);
1940
+
1941
+ set_values (input, {
1942
+ 1 .f , 0 .f , 5 .f , 1 .5f ,
1943
+ 2 .f , 0 .f , 6 .f , 5 .2f ,
1944
+ 3 .f , 0 .5f , 7 .f , 12 .f ,
1945
+ 4 .f , -0 .5f , 8 .f , 8 .f
1946
+ });
1947
+
1948
+ topology topology {
1949
+ input_layout (" input" , in_layout),
1950
+ reorder (" reorder" , input_info (" input" ), weights_reorder_params)
1951
+ };
1952
+
1953
+ ExecutionConfig config = get_test_default_config (engine);
1954
+ ov::intel_gpu::ImplementationDesc wr_impl_desc = { format::oiyx, " reorder_weights" , impl_types::ocl };
1955
+ config.set_property (ov::intel_gpu::force_implementations (ov::intel_gpu::ImplForcingMap{ {" reorder" , wr_impl_desc} }));
1956
+
1957
+ network network (engine, topology, config);
1958
+ network.set_input_data (" input" , input);
1959
+
1960
+ auto outputs = network.execute ();
1961
+ ASSERT_EQ (outputs.size (), size_t (1 ));
1962
+ ASSERT_EQ (outputs.begin ()->first , " reorder" );
1963
+
1964
+ std::vector<int32_t > ref_output = {
1965
+ 1 , 0 , 5 , 1 ,
1966
+ 2 , 0 , 6 , 5 ,
1967
+ 3 , 0 , 7 , 12 ,
1968
+ 4 , 0 , 8 , 8
1969
+ };
1970
+
1971
+ auto output = outputs.begin ()->second .get_memory ();
1972
+ cldnn::mem_lock<int32_t > output_ptr (output, get_test_stream ());
1973
+
1974
+ ASSERT_EQ (output_ptr.size (), ref_output.size ());
1975
+ for (size_t i = 0 ; i < ref_output.size (); ++i) {
1976
+ ASSERT_EQ (output_ptr[i], ref_output[i]);
1977
+ }
1978
+ }
1979
+
1980
+ TEST (reorder_weights_gpu_i32, reorder_weights_opt)
1981
+ {
1982
+ auto & engine = get_test_engine ();
1983
+
1984
+ layout in_layout (data_types::f32, format::bfyx, { 16 , 1 , 2 , 1 });
1985
+ layout out_layout (data_types::i32, format::os_iyx_osv16, { 16 , 1 , 2 , 1 });
1986
+ auto weights_reorder_params = std::make_shared<WeightsReorderParams>(in_layout, out_layout);
1987
+
1988
+ auto input = engine.allocate_memory (in_layout);
1989
+
1990
+ set_values (input, {
1991
+ 0 .f , 1 .f , 2 .f , 3 .f , 4 .f , 5 .f , 6 .f , 7 .f ,
1992
+ 8 .f , 9 .f , 10 .f , 0 .5f , 12 .f , 13 .f , 14 .f , 15 .f ,
1993
+ 16 .f , 17 .f , 18 .f , 19 .f , 20 .f , -1 .6f , 22 .f , 23 .f ,
1994
+ -1 .0f , 25 .f , 26 .f , 27 .f , 28 .f , 29 .f , 30 .f , 31 .f
1995
+ });
1996
+
1997
+ topology topology {
1998
+ input_layout (" input" , in_layout),
1999
+ reorder (" reorder" , input_info (" input" ), weights_reorder_params)
2000
+ };
2001
+
2002
+ ExecutionConfig config = get_test_default_config (engine);
2003
+ ov::intel_gpu::ImplementationDesc wr_impl_desc = { format::os_iyx_osv16, " reorder_weights_opt" , impl_types::ocl };
2004
+ config.set_property (ov::intel_gpu::force_implementations (ov::intel_gpu::ImplForcingMap{ {" reorder" , wr_impl_desc} }));
2005
+
2006
+ network network (engine, topology, config);
2007
+ network.set_input_data (" input" , input);
2008
+
2009
+ auto outputs = network.execute ();
2010
+ ASSERT_EQ (outputs.size (), size_t (1 ));
2011
+ ASSERT_EQ (outputs.begin ()->first , " reorder" );
2012
+
2013
+ std::vector<int32_t > ref_output = {
2014
+ 0 , 2 , 4 , 6 , 8 , 10 , 12 , 14 ,
2015
+ 16 , 18 , 20 , 22 , -1 , 26 , 28 , 30 ,
2016
+ 1 , 3 , 5 , 7 , 9 , 0 , 13 , 15 ,
2017
+ 17 , 19 , -1 , 23 , 25 , 27 , 29 , 31
2018
+ };
2019
+
2020
+ auto output = outputs.begin ()->second .get_memory ();
2021
+ cldnn::mem_lock<int32_t > output_ptr (output, get_test_stream ());
2022
+
2023
+ ASSERT_EQ (output_ptr.size (), ref_output.size ());
2024
+ for (size_t i = 0 ; i < ref_output.size (); ++i) {
2025
+ ASSERT_EQ (output_ptr[i], ref_output[i]);
2026
+ }
2027
+ }
2028
+
1931
2029
TEST (reorder_gpu_i64, basic)
1932
2030
{
1933
2031
// Test for converting data types f32->i64
0 commit comments