1313#include < cassert>
1414#include < ur_util.hpp>
1515
16- namespace {
17-
18- size_t GetHipFormatPixelSize (hipArray_Format Format) {
19- switch (Format) {
16+ size_t imageElementByteSize (hipArray_Format ArrayFormat) {
17+ switch (ArrayFormat) {
2018 case HIP_AD_FORMAT_UNSIGNED_INT8:
2119 case HIP_AD_FORMAT_SIGNED_INT8:
2220 return 1 ;
@@ -31,10 +29,9 @@ size_t GetHipFormatPixelSize(hipArray_Format Format) {
3129 default :
3230 detail::ur::die (" Invalid HIP format specifier" );
3331 }
32+ return 0 ;
3433}
3534
36- } // namespace
37-
3835// / Decreases the reference count of the Mem object.
3936// / If this is zero, calls the relevant HIP Free function
4037// / \return UR_RESULT_SUCCESS unless deallocation error
@@ -245,7 +242,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemGetInfo(ur_mem_handle_t hMemory,
245242 UR_CHECK_ERROR (
246243 hipArray3DGetDescriptor (&ArrayDescriptor, Mem.getArray (Device)));
247244 const auto PixelSizeBytes =
248- GetHipFormatPixelSize (ArrayDescriptor.Format ) *
245+ imageElementByteSize (ArrayDescriptor.Format ) *
249246 ArrayDescriptor.NumChannels ;
250247 const auto ImageSizeBytes =
251248 PixelSizeBytes *
@@ -405,25 +402,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageGetInfo(ur_mem_handle_t hMemory,
405402 }
406403 };
407404
408- const auto hipFormatToElementSize =
409- [](hipArray_Format HipFormat) -> size_t {
410- switch (HipFormat) {
411- case HIP_AD_FORMAT_UNSIGNED_INT8:
412- case HIP_AD_FORMAT_SIGNED_INT8:
413- return 1 ;
414- case HIP_AD_FORMAT_UNSIGNED_INT16:
415- case HIP_AD_FORMAT_SIGNED_INT16:
416- case HIP_AD_FORMAT_HALF:
417- return 2 ;
418- case HIP_AD_FORMAT_UNSIGNED_INT32:
419- case HIP_AD_FORMAT_SIGNED_INT32:
420- case HIP_AD_FORMAT_FLOAT:
421- return 4 ;
422- default :
423- detail::ur::die (" Invalid Hip format specified." );
424- }
425- };
426-
427405 switch (propName) {
428406 case UR_IMAGE_INFO_FORMAT:
429407 return ReturnValue (ur_image_format_t {UR_IMAGE_CHANNEL_ORDER_RGBA,
@@ -435,7 +413,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageGetInfo(ur_mem_handle_t hMemory,
435413 case UR_IMAGE_INFO_DEPTH:
436414 return ReturnValue (ArrayInfo.Depth );
437415 case UR_IMAGE_INFO_ELEMENT_SIZE:
438- return ReturnValue (hipFormatToElementSize (ArrayInfo.Format ));
416+ return ReturnValue (imageElementByteSize (ArrayInfo.Format ));
439417 case UR_IMAGE_INFO_ROW_PITCH:
440418 case UR_IMAGE_INFO_SLICE_PITCH:
441419 return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
0 commit comments