Skip to content

Commit 38171c1

Browse files
authored
Merge pull request #2126 from nrspruit/return_unsupported_image_formats
[L0] Report Unsupported vs crash given unmatched image formats
2 parents d5b9b20 + caf8e5f commit 38171c1

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

source/adapters/level_zero/image.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat,
271271
ZeStruct<ze_image_desc_t> &ZeImageDesc) {
272272
auto [ZeImageFormatType, ZeImageFormatTypeSize] =
273273
getImageFormatTypeAndSize(ImageFormat);
274+
if (ZeImageFormatTypeSize == 0) {
275+
return UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT;
276+
}
274277
// TODO: populate the layout mapping
275278
ze_image_format_layout_t ZeImageFormatLayout;
276279
switch (ImageFormat->channelOrder) {
@@ -673,7 +676,8 @@ getImageFormatTypeAndSize(const ur_image_format_t *ImageFormat) {
673676
logger::error(
674677
"urMemImageCreate: unsupported image data type: data type = {}",
675678
ImageFormat->channelType);
676-
ur::unreachable();
679+
ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_FORCE_UINT32;
680+
ZeImageFormatTypeSize = 0;
677681
}
678682
return {ZeImageFormatType, ZeImageFormatTypeSize};
679683
}

source/adapters/level_zero/memory.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,10 @@ static ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat,
14251425
auto [ZeImageFormatType, ZeImageFormatTypeSize] =
14261426
getImageFormatTypeAndSize(ImageFormat);
14271427

1428+
if (ZeImageFormatTypeSize == 0) {
1429+
return UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT;
1430+
}
1431+
14281432
// TODO: populate the layout mapping
14291433
ze_image_format_layout_t ZeImageFormatLayout;
14301434
switch (ImageFormat->channelOrder) {

test/conformance/memory/memory_adapter_level_zero.match

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,16 @@
22
urMemBufferPartitionTest.InvalidValueCreateType/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
33
urMemBufferPartitionTest.InvalidValueBufferCreateInfoOutOfBounds/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
44
{{OPT}}urMemGetInfoImageTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_MEM_INFO_SIZE
5-
{{Segmentation fault|Aborted}}
5+
{{OPT}}{{Segmentation fault|Aborted}}
6+
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_SNORM_INT8
7+
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_SNORM_INT16
8+
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_UNORM_INT8
9+
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_UNORM_INT16
10+
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8
11+
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16
12+
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32
13+
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8
14+
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16
15+
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32
16+
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT
17+
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_FLOAT

0 commit comments

Comments
 (0)