Skip to content

Commit

Permalink
[GPU] Define to_type in jitter for reorder to support INT4
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsnam-intel committed Jan 16, 2025
1 parent 5c55539 commit 95cf8c3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/plugins/intel_gpu/src/kernel_selector/jitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,7 @@ JitConstants MakeTypeJitConstants(Datatype dataType, const std::string& macroNam
break;
case Datatype::INT4:
type = "char";
to_type = "convert_char(v)";
type_size = "0.5f";
is_fp = false;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ParamsKey ReorderKernelRef::GetSupportedKey() const {
k.EnableInputDataType(Datatype::UINT8);
k.EnableInputDataType(Datatype::UINT16);
k.EnableInputDataType(Datatype::UINT32);
k.EnableInputDataType(Datatype::INT4);
k.EnableInputDataType(Datatype::INT8);
k.EnableInputDataType(Datatype::INT16);
k.EnableInputDataType(Datatype::INT32);
Expand Down
31 changes: 31 additions & 0 deletions src/plugins/intel_gpu/tests/unit/test_cases/reorder_gpu_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,37 @@ TEST(reorder_gpu, basic_convert_f16_f32_f16) {
}
}

TEST(reorder_gpu, basic_convert_i4_to_fp16) {
tests::random_generator rg(GET_SUITE_NAME);
auto& engine = get_test_engine();

layout in_layout = layout{ ov::PartialShape{ 1, 1, 3, 3 }, data_types::i4, format::bfyx };
layout out_layout = layout{ ov::PartialShape{ 1, 1, 3, 3 }, data_types::f16, format::bfyx };

auto input = rg.generate_random_1d<int8_t>(9, -7, 7);
auto input_mem = engine.allocate_memory(in_layout);
set_values(input_mem, input);

topology topology(
input_layout("input", in_layout),
reorder("convert", input_info("input"), out_layout)
);

ExecutionConfig config = get_test_default_config(engine);
config.set_property(ov::intel_gpu::optimize_data(true));
network network(engine, topology, config);

network.set_input_data("input", input_mem);

auto outputs = network.execute();

auto output = outputs.begin()->second.get_memory();
cldnn::mem_lock<ov::float16> output_ptr(output, get_test_stream());
for (size_t i = 0; i < output_ptr.size(); ++i) {
ASSERT_EQ(output_ptr[i], input[i]);
}
}

TEST(reorder_gpu, basic_convert_int8) {

auto& engine = get_test_engine();
Expand Down

0 comments on commit 95cf8c3

Please sign in to comment.