Skip to content

Commit

Permalink
Merge pull request #1791 from aakanksha555/paakan/hipTensor_part8
Browse files Browse the repository at this point in the history
[HIPIFY][Tensor][feature] hipTensor support - Functions - Part 8
  • Loading branch information
emankov authored Dec 13, 2024
2 parents 1156258 + a9da49a commit 57c535a
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 6 deletions.
43 changes: 43 additions & 0 deletions bin/hipify-perl
Original file line number Diff line number Diff line change
Expand Up @@ -6139,6 +6139,7 @@ sub simpleSubstitutions {
subst("cusparseZsctr", "hipsparseZsctr", "library");
subst("cutensorCreate", "hiptensorCreate", "library");
subst("cutensorDestroy", "hiptensorDestroy", "library");
subst("cutensorInitTensorDescriptor", "hiptensorInitTensorDescriptor", "library");
subst("nvrtcAddNameExpression", "hiprtcAddNameExpression", "library");
subst("nvrtcCompileProgram", "hiprtcCompileProgram", "library");
subst("nvrtcCreateProgram", "hiprtcCreateProgram", "library");
Expand Down Expand Up @@ -7374,6 +7375,7 @@ sub simpleSubstitutions {
subst("cutensorHandle_t", "hiptensorHandle_t", "type");
subst("cutensorOperator_t", "hiptensorOperator_t", "type");
subst("cutensorStatus_t", "hiptensorStatus_t", "type");
subst("cutensorTensorDescriptor", "hiptensorTensorDescriptor_t", "type");
subst("cutensorWorksizePreference_t", "hiptensorWorksizePreference_t", "type");
subst("gesvdjInfo_t", "hipsolverGesvdjInfo_t", "type");
subst("nvrtcProgram", "hiprtcProgram", "type");
Expand Down Expand Up @@ -7874,6 +7876,14 @@ sub simpleSubstitutions {
subst("CUSPARSE_STATUS_ZERO_PIVOT", "HIPSPARSE_STATUS_ZERO_PIVOT", "numeric_literal");
subst("CUTENSOR_ALGO_DEFAULT", "HIPTENSOR_ALGO_DEFAULT", "numeric_literal");
subst("CUTENSOR_ALGO_DEFAULT_PATIENT", "HIPTENSOR_ALGO_DEFAULT_PATIENT", "numeric_literal");
subst("CUTENSOR_COMPUTE_16BF", "HIPTENSOR_COMPUTE_16BF", "numeric_literal");
subst("CUTENSOR_COMPUTE_16F", "HIPTENSOR_COMPUTE_16F", "numeric_literal");
subst("CUTENSOR_COMPUTE_32F", "HIPTENSOR_COMPUTE_32F", "numeric_literal");
subst("CUTENSOR_COMPUTE_32I", "HIPTENSOR_COMPUTE_32I", "numeric_literal");
subst("CUTENSOR_COMPUTE_32U", "HIPTENSOR_COMPUTE_32U", "numeric_literal");
subst("CUTENSOR_COMPUTE_64F", "HIPTENSOR_COMPUTE_64F", "numeric_literal");
subst("CUTENSOR_COMPUTE_8I", "HIPTENSOR_COMPUTE_8I", "numeric_literal");
subst("CUTENSOR_COMPUTE_8U", "HIPTENSOR_COMPUTE_8U", "numeric_literal");
subst("CUTENSOR_C_32F", "HIPTENSOR_COMPUTE_C32F", "numeric_literal");
subst("CUTENSOR_C_64F", "HIPTENSOR_COMPUTE_C64F", "numeric_literal");
subst("CUTENSOR_OP_ADD", "HIPTENSOR_OP_ADD", "numeric_literal");
Expand Down Expand Up @@ -8668,6 +8678,7 @@ sub simpleSubstitutions {
subst("cudaSuccess", "hipSuccess", "numeric_literal");
subst("cudaUserObjectNoDestructorSync", "hipUserObjectNoDestructorSync", "numeric_literal");
subst("cusolver_int_t", "int", "numeric_literal");
subst("cutensorComputeType_t", "hiptensorComputeType_t", "numeric_literal");
subst("CUB_MAX", "CUB_MAX", "define");
subst("CUB_MIN", "CUB_MIN", "define");
subst("CUB_NAMESPACE_BEGIN", "BEGIN_HIPCUB_NAMESPACE", "define");
Expand Down Expand Up @@ -9867,13 +9878,17 @@ sub warnHipOnlyUnsupportedFunctions {
my $line_num = shift;
my $k = 0;
foreach $func (
"cutensorWriteKernelCacheToFile",
"cutensorReadKernelCacheFromFile",
"cutensorPlanPreferenceAttribute_t",
"cutensorPlanAttribute_t",
"cutensorOperationDescriptorAttribute_t",
"cutensorJitMode_t",
"cutensorHandleWritePlanCacheToFile",
"cutensorHandleResizePlanCache",
"cutensorHandleReadPlanCacheFromFile",
"cutensorDestroyTensorDescriptor",
"cutensorCreateTensorDescriptor",
"cutensorCacheMode_t",
"cutensorAutotuneMode_t",
"cusparseZhybsv_solve",
Expand Down Expand Up @@ -10190,6 +10205,13 @@ sub warnHipOnlyUnsupportedFunctions {
"CUTENSOR_STATUS_LICENSE_ERROR",
"CUTENSOR_STATUS_CUDA_ERROR",
"CUTENSOR_STATUS_CUBLAS_ERROR",
"CUTENSOR_R_MIN_TF32",
"CUTENSOR_R_MIN_8U",
"CUTENSOR_R_MIN_64F",
"CUTENSOR_R_MIN_32U",
"CUTENSOR_R_MIN_32F",
"CUTENSOR_R_MIN_16F",
"CUTENSOR_R_MIN_16BF",
"CUTENSOR_R_64U",
"CUTENSOR_R_64I",
"CUTENSOR_R_4U",
Expand Down Expand Up @@ -10238,6 +10260,10 @@ sub warnHipOnlyUnsupportedFunctions {
"CUTENSOR_OPERATION_DESCRIPTOR_FLOPS",
"CUTENSOR_JIT_MODE_NONE",
"CUTENSOR_JIT_MODE_DEFAULT",
"CUTENSOR_C_MIN_TF32",
"CUTENSOR_C_MIN_64F",
"CUTENSOR_C_MIN_32F",
"CUTENSOR_C_MIN_16F",
"CUTENSOR_C_8U",
"CUTENSOR_C_8I",
"CUTENSOR_C_64U",
Expand All @@ -10250,6 +10276,7 @@ sub warnHipOnlyUnsupportedFunctions {
"CUTENSOR_C_16I",
"CUTENSOR_C_16F",
"CUTENSOR_C_16BF",
"CUTENSOR_COMPUTE_TF32",
"CUTENSOR_CACHE_MODE_PEDANTIC",
"CUTENSOR_CACHE_MODE_NONE",
"CUTENSOR_AUTOTUNE_MODE_NONE",
Expand Down Expand Up @@ -11190,13 +11217,17 @@ sub warnRocOnlyUnsupportedFunctions {
my $line_num = shift;
my $k = 0;
foreach $func (
"cutensorWriteKernelCacheToFile",
"cutensorReadKernelCacheFromFile",
"cutensorPlanPreferenceAttribute_t",
"cutensorPlanAttribute_t",
"cutensorOperationDescriptorAttribute_t",
"cutensorJitMode_t",
"cutensorHandleWritePlanCacheToFile",
"cutensorHandleResizePlanCache",
"cutensorHandleReadPlanCacheFromFile",
"cutensorDestroyTensorDescriptor",
"cutensorCreateTensorDescriptor",
"cutensorCacheMode_t",
"cutensorAutotuneMode_t",
"cusparseZhybsv_solve",
Expand Down Expand Up @@ -11603,6 +11634,13 @@ sub warnRocOnlyUnsupportedFunctions {
"CUTENSOR_STATUS_LICENSE_ERROR",
"CUTENSOR_STATUS_CUDA_ERROR",
"CUTENSOR_STATUS_CUBLAS_ERROR",
"CUTENSOR_R_MIN_TF32",
"CUTENSOR_R_MIN_8U",
"CUTENSOR_R_MIN_64F",
"CUTENSOR_R_MIN_32U",
"CUTENSOR_R_MIN_32F",
"CUTENSOR_R_MIN_16F",
"CUTENSOR_R_MIN_16BF",
"CUTENSOR_R_64U",
"CUTENSOR_R_64I",
"CUTENSOR_R_4U",
Expand Down Expand Up @@ -11651,6 +11689,10 @@ sub warnRocOnlyUnsupportedFunctions {
"CUTENSOR_OPERATION_DESCRIPTOR_FLOPS",
"CUTENSOR_JIT_MODE_NONE",
"CUTENSOR_JIT_MODE_DEFAULT",
"CUTENSOR_C_MIN_TF32",
"CUTENSOR_C_MIN_64F",
"CUTENSOR_C_MIN_32F",
"CUTENSOR_C_MIN_16F",
"CUTENSOR_C_8U",
"CUTENSOR_C_8I",
"CUTENSOR_C_64U",
Expand All @@ -11663,6 +11705,7 @@ sub warnRocOnlyUnsupportedFunctions {
"CUTENSOR_C_16I",
"CUTENSOR_C_16F",
"CUTENSOR_C_16BF",
"CUTENSOR_COMPUTE_TF32",
"CUTENSOR_CACHE_MODE_PEDANTIC",
"CUTENSOR_CACHE_MODE_NONE",
"CUTENSOR_AUTOTUNE_MODE_NONE",
Expand Down
29 changes: 28 additions & 1 deletion docs/tables/CUTENSOR_API_supported_by_HIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
|`CUTENSOR_AUTOTUNE_MODE_NONE`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_CACHE_MODE_NONE`|1.2.0.0| | | | | | | | | |
|`CUTENSOR_CACHE_MODE_PEDANTIC`|1.2.0.0| | | | | | | | | |
|`CUTENSOR_COMPUTE_16BF`|1.0.1.0| | |2.0.0.0|`HIPTENSOR_COMPUTE_16BF`|5.7.0| | | | |
|`CUTENSOR_COMPUTE_16F`|1.0.1.0| | |2.0.0.0|`HIPTENSOR_COMPUTE_16F`|5.7.0| | | | |
|`CUTENSOR_COMPUTE_32F`|1.0.1.0| | |2.0.0.0|`HIPTENSOR_COMPUTE_32F`|5.7.0| | | | |
|`CUTENSOR_COMPUTE_32I`|1.0.1.0| | |2.0.0.0|`HIPTENSOR_COMPUTE_32I`|5.7.0| | | | |
|`CUTENSOR_COMPUTE_32U`|1.0.1.0| | |2.0.0.0|`HIPTENSOR_COMPUTE_32U`|5.7.0| | | | |
|`CUTENSOR_COMPUTE_64F`|1.0.1.0| | |2.0.0.0|`HIPTENSOR_COMPUTE_64F`|5.7.0| | | | |
|`CUTENSOR_COMPUTE_8I`|1.0.1.0| | |2.0.0.0|`HIPTENSOR_COMPUTE_8I`|5.7.0| | | | |
|`CUTENSOR_COMPUTE_8U`|1.0.1.0| | |2.0.0.0|`HIPTENSOR_COMPUTE_8U`|5.7.0| | | | |
|`CUTENSOR_COMPUTE_TF32`|1.0.1.0| | |2.0.0.0| | | | | | |
|`CUTENSOR_C_16BF`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_C_16F`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_C_16I`|2.0.0.0| | | | | | | | | |
Expand All @@ -27,6 +36,10 @@
|`CUTENSOR_C_64U`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_C_8I`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_C_8U`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_C_MIN_16F`|1.0.1.0|1.2.0.0| |2.0.0.0| | | | | | |
|`CUTENSOR_C_MIN_32F`|1.0.1.0|1.2.0.0| |2.0.0.0| | | | | | |
|`CUTENSOR_C_MIN_64F`|1.0.1.0|1.2.0.0| |2.0.0.0| | | | | | |
|`CUTENSOR_C_MIN_TF32`|1.0.1.0|1.2.0.0| |2.0.0.0| | | | | | |
|`CUTENSOR_JIT_MODE_DEFAULT`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_JIT_MODE_NONE`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_OPERATION_DESCRIPTOR_FLOPS`|2.0.0.0| | | | | | | | | |
Expand Down Expand Up @@ -90,6 +103,13 @@
|`CUTENSOR_R_64U`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_R_8I`|2.0.0.0| | | |`HIPTENSOR_COMPUTE_8I`|5.7.0| | | | |
|`CUTENSOR_R_8U`|2.0.0.0| | | |`HIPTENSOR_COMPUTE_8U`|5.7.0| | | | |
|`CUTENSOR_R_MIN_16BF`|1.0.1.0|1.2.0.0| |2.0.0.0| | | | | | |
|`CUTENSOR_R_MIN_16F`|1.0.1.0|1.2.0.0| |2.0.0.0| | | | | | |
|`CUTENSOR_R_MIN_32F`|1.0.1.0|1.2.0.0| |2.0.0.0| | | | | | |
|`CUTENSOR_R_MIN_32U`|1.0.1.0|1.2.0.0| |2.0.0.0| | | | | | |
|`CUTENSOR_R_MIN_64F`|1.0.1.0|1.2.0.0| |2.0.0.0| | | | | | |
|`CUTENSOR_R_MIN_8U`|1.0.1.0|1.2.0.0| |2.0.0.0| | | | | | |
|`CUTENSOR_R_MIN_TF32`|1.0.1.0|1.2.0.0| |2.0.0.0| | | | | | |
|`CUTENSOR_STATUS_ALLOC_FAILED`|1.0.1.0| | | |`HIPTENSOR_STATUS_ALLOC_FAILED`|5.7.0| | | | |
|`CUTENSOR_STATUS_ARCH_MISMATCH`|1.0.1.0| | | |`HIPTENSOR_STATUS_ARCH_MISMATCH`|5.7.0| | | | |
|`CUTENSOR_STATUS_CUBLAS_ERROR`|1.0.1.0| | | | | | | | | |
Expand All @@ -112,25 +132,32 @@
|`cutensorAlgo_t`|1.0.1.0| | | |`hiptensorAlgo_t`|5.7.0| | | | |
|`cutensorAutotuneMode_t`|1.2.0.0| | | | | | | | | |
|`cutensorCacheMode_t`|1.2.0.0| | | | | | | | | |
|`cutensorComputeType_t`| | | | |`hiptensorComputeType_t`|5.7.0| | | | |
|`cutensorDataType_t`|2.0.0.0| | | |`hiptensorComputeType_t`|5.7.0| | | | |
|`cutensorHandle_t`| | | | |`hiptensorHandle_t`| | | | | |
|`cutensorHandle_t`|1.0.1.0| | | |`hiptensorHandle_t`|5.7.0| | | | |
|`cutensorJitMode_t`|2.0.0.0| | | | | | | | | |
|`cutensorOperationDescriptorAttribute_t`|2.0.0.0| | | | | | | | | |
|`cutensorOperator_t`|1.0.1.0| | | |`hiptensorOperator_t`|5.7.0| | | | |
|`cutensorPlanAttribute_t`|2.0.0.0| | | | | | | | | |
|`cutensorPlanPreferenceAttribute_t`|2.0.0.0| | | | | | | | | |
|`cutensorStatus_t`|1.0.1.0| | | |`hiptensorStatus_t`|5.7.0| | | | |
|`cutensorTensorDescriptor`| | | | |`hiptensorTensorDescriptor_t`|5.7.0| | | | |
|`cutensorWorksizePreference_t`|1.0.1.0| | | |`hiptensorWorksizePreference_t`|5.7.0| | | | |

## **2. CUTENSOR Function Reference**

|**CUDA**|**A**|**D**|**C**|**R**|**HIP**|**A**|**D**|**C**|**R**|**E**|
|:--|:-:|:-:|:-:|:-:|:--|:-:|:-:|:-:|:-:|:-:|
|`cutensorCreate`|1.7.0.0| | | |`hiptensorCreate`|5.7.0| | | | |
|`cutensorCreateTensorDescriptor`|2.0.0.0| | | | | | | | | |
|`cutensorDestroy`|1.7.0.0| | | |`hiptensorDestroy`|5.7.0| | | | |
|`cutensorDestroyTensorDescriptor`|2.0.0.0| | | | | | | | | |
|`cutensorHandleReadPlanCacheFromFile`|2.0.0.0| | | | | | | | | |
|`cutensorHandleResizePlanCache`|2.0.0.0| | | | | | | | | |
|`cutensorHandleWritePlanCacheToFile`|2.0.0.0| | | | | | | | | |
|`cutensorInitTensorDescriptor`|1.0.1.0| | |2.0.0.0|`hiptensorInitTensorDescriptor`|5.7.0| | | | |
|`cutensorReadKernelCacheFromFile`|2.0.0.0| | | | | | | | | |
|`cutensorWriteKernelCacheToFile`|2.0.0.0| | | | | | | | | |


\*A - Added; D - Deprecated; C - Changed; R - Removed; E - Experimental
11 changes: 11 additions & 0 deletions src/CUDA2HIP_TENSOR_API_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ const std::map<llvm::StringRef, hipCounter> CUDA_TENSOR_FUNCTION_MAP {
{"cutensorHandleResizePlanCache", {"", "", CONV_LIB_FUNC, API_TENSOR, 2, UNSUPPORTED}},
{"cutensorHandleWritePlanCacheToFile", {"", "", CONV_LIB_FUNC, API_TENSOR, 2, UNSUPPORTED}},
{"cutensorHandleReadPlanCacheFromFile", {"", "", CONV_LIB_FUNC, API_TENSOR, 2, UNSUPPORTED}},
{"cutensorWriteKernelCacheToFile", {"", "", CONV_LIB_FUNC, API_TENSOR, 2, UNSUPPORTED}},
{"cutensorReadKernelCacheFromFile", {"", "", CONV_LIB_FUNC, API_TENSOR, 2, UNSUPPORTED}},
{"cutensorCreateTensorDescriptor", {"", "", CONV_LIB_FUNC, API_TENSOR, 2, UNSUPPORTED}},
{"cutensorInitTensorDescriptor", {"hiptensorInitTensorDescriptor", "", CONV_LIB_FUNC, API_TENSOR, 2}},
{"cutensorDestroyTensorDescriptor", {"", "", CONV_LIB_FUNC, API_TENSOR, 2, UNSUPPORTED}},
};


Expand All @@ -37,11 +42,17 @@ const std::map<llvm::StringRef, cudaAPIversions> CUDA_TENSOR_FUNCTION_VER_MAP {
{"cutensorHandleResizePlanCache", {CUTENSOR_2000, CUDA_0, CUDA_0 }},
{"cutensorHandleWritePlanCacheToFile", {CUTENSOR_2000, CUDA_0, CUDA_0 }},
{"cutensorHandleReadPlanCacheFromFile", {CUTENSOR_2000, CUDA_0, CUDA_0 }},
{"cutensorWriteKernelCacheToFile", {CUTENSOR_2000, CUDA_0, CUDA_0 }},
{"cutensorReadKernelCacheFromFile", {CUTENSOR_2000, CUDA_0, CUDA_0 }},
{"cutensorCreateTensorDescriptor", {CUTENSOR_2000, CUDA_0, CUDA_0 }},
{"cutensorInitTensorDescriptor", {CUTENSOR_1010, CUDA_0, CUTENSOR_2000}},
{"cutensorDestroyTensorDescriptor", {CUTENSOR_2000, CUDA_0, CUDA_0 }},
};

const std::map<llvm::StringRef, hipAPIversions> HIP_TENSOR_FUNCTION_VER_MAP {
{"hiptensorCreate", {HIP_5070, HIP_0, HIP_0, }},
{"hiptensorDestroy", {HIP_5070, HIP_0, HIP_0, }},
{"hiptensorInitTensorDescriptor", {HIP_5070, HIP_0, HIP_0, }},
};

const std::map<unsigned int, llvm::StringRef> CUDA_TENSOR_API_SECTION_MAP {
Expand Down
Loading

0 comments on commit 57c535a

Please sign in to comment.