Skip to content

Commit

Permalink
Merge pull request #2126 from nrspruit/return_unsupported_image_formats
Browse files Browse the repository at this point in the history
[L0] Report Unsupported vs crash given unmatched image formats
  • Loading branch information
aarongreig authored Oct 17, 2024
2 parents 7c19b36 + c021f8c commit 7739fc9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 5 additions & 1 deletion source/adapters/level_zero/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat,
ZeStruct<ze_image_desc_t> &ZeImageDesc) {
auto [ZeImageFormatType, ZeImageFormatTypeSize] =
getImageFormatTypeAndSize(ImageFormat);
if (ZeImageFormatTypeSize == 0) {
return UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT;
}
// TODO: populate the layout mapping
ze_image_format_layout_t ZeImageFormatLayout;
switch (ImageFormat->channelOrder) {
Expand Down Expand Up @@ -673,7 +676,8 @@ getImageFormatTypeAndSize(const ur_image_format_t *ImageFormat) {
logger::error(
"urMemImageCreate: unsupported image data type: data type = {}",
ImageFormat->channelType);
ur::unreachable();
ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_FORCE_UINT32;
ZeImageFormatTypeSize = 0;
}
return {ZeImageFormatType, ZeImageFormatTypeSize};
}
Expand Down
4 changes: 4 additions & 0 deletions source/adapters/level_zero/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,10 @@ static ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat,
auto [ZeImageFormatType, ZeImageFormatTypeSize] =
getImageFormatTypeAndSize(ImageFormat);

if (ZeImageFormatTypeSize == 0) {
return UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT;
}

// TODO: populate the layout mapping
ze_image_format_layout_t ZeImageFormatLayout;
switch (ImageFormat->channelOrder) {
Expand Down
14 changes: 13 additions & 1 deletion test/conformance/memory/memory_adapter_level_zero.match
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@
urMemBufferPartitionTest.InvalidValueCreateType/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
urMemBufferPartitionTest.InvalidValueBufferCreateInfoOutOfBounds/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
{{OPT}}urMemGetInfoImageTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_MEM_INFO_SIZE
{{Segmentation fault|Aborted}}
{{OPT}}{{Segmentation fault|Aborted}}
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_SNORM_INT8
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_SNORM_INT16
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_UNORM_INT8
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_UNORM_INT16
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_SIGNED_INT8
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_SIGNED_INT16
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_SIGNED_INT32
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_HALF_FLOAT
{{OPT}}urMemImageCreateTestWithImageFormatParam.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_IMAGE_CHANNEL_ORDER_RGBA__UR_IMAGE_CHANNEL_TYPE_FLOAT

0 comments on commit 7739fc9

Please sign in to comment.