diff --git a/source/adapters/level_zero/image.cpp b/source/adapters/level_zero/image.cpp index 61ce9ae257..4810b3d88e 100644 --- a/source/adapters/level_zero/image.cpp +++ b/source/adapters/level_zero/image.cpp @@ -271,6 +271,9 @@ ur_result_t ur2zeImageDesc(const ur_image_format_t *ImageFormat, ZeStruct &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) { @@ -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}; } diff --git a/source/adapters/level_zero/memory.cpp b/source/adapters/level_zero/memory.cpp index 69edf83a78..74d1e02f70 100644 --- a/source/adapters/level_zero/memory.cpp +++ b/source/adapters/level_zero/memory.cpp @@ -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) {