Skip to content

Commit

Permalink
[L0] Report Unsupported vs crash given unmatched image formats
Browse files Browse the repository at this point in the history
Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
  • Loading branch information
nrspruit committed Sep 24, 2024
1 parent 45ad7c5 commit e9c3600
Show file tree
Hide file tree
Showing 3 changed files with 234 additions and 1 deletion.
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 @@ -1435,6 +1435,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
Loading

0 comments on commit e9c3600

Please sign in to comment.