Skip to content

Commit

Permalink
[HIPIFY][Tensor][feature] Introduce cuTensor support - Part 4 - Dat…
Browse files Browse the repository at this point in the history
…a Types

+ Updated the regenerated `hipify-perl` and `TENSOR` `CUDA2HIP` docs accordingly
  • Loading branch information
emankov committed Nov 19, 2024
1 parent 058882d commit 749524a
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 4 deletions.
66 changes: 64 additions & 2 deletions bin/hipify-perl
Original file line number Diff line number Diff line change
Expand Up @@ -6784,6 +6784,7 @@ sub simpleSubstitutions {
subst("cusparseSparseToDenseAlg_t", "hipsparseSparseToDenseAlg_t", "type");
subst("cusparseStatus_t", "hipsparseStatus_t", "type");
subst("cutensorDataType_t", "hiptensorComputeType_t", "type");
subst("cutensorOperator_t", "hiptensorOperator_t", "type");
subst("cutensorStatus_t", "hiptensorStatus_t", "type");
subst("gesvdjInfo_t", "hipsolverGesvdjInfo_t", "type");
subst("nvrtcProgram", "hiprtcProgram", "type");
Expand Down Expand Up @@ -7284,6 +7285,9 @@ sub simpleSubstitutions {
subst("CUSPARSE_STATUS_ZERO_PIVOT", "HIPSPARSE_STATUS_ZERO_PIVOT", "numeric_literal");
subst("CUTENSOR_C_32F", "HIPTENSOR_COMPUTE_C32F", "numeric_literal");
subst("CUTENSOR_C_64F", "HIPTENSOR_COMPUTE_C64F", "numeric_literal");
subst("CUTENSOR_OP_IDENTITY", "HIPTENSOR_OP_IDENTITY", "numeric_literal");
subst("CUTENSOR_OP_SQRT", "HIPTENSOR_OP_SQRT", "numeric_literal");
subst("CUTENSOR_OP_UNKNOWN", "HIPTENSOR_OP_UNKNOWN", "numeric_literal");
subst("CUTENSOR_R_16BF", "HIPTENSOR_COMPUTE_16BF", "numeric_literal");
subst("CUTENSOR_R_16F", "HIPTENSOR_COMPUTE_16F", "numeric_literal");
subst("CUTENSOR_R_32F", "HIPTENSOR_COMPUTE_32F", "numeric_literal");
Expand Down Expand Up @@ -11243,7 +11247,6 @@ sub warnHipOnlyUnsupportedFunctions {
my $line_num = shift;
my $k = 0;
foreach $func (
"cutensorOperator_t",
"cusparseZhybsv_solve",
"cusparseZhybsv_analysis",
"cusparseZhyb2dense",
Expand Down Expand Up @@ -11825,6 +11828,36 @@ sub warnHipOnlyUnsupportedFunctions {
"CUTENSOR_R_4I",
"CUTENSOR_R_16U",
"CUTENSOR_R_16I",
"CUTENSOR_OP_TANH",
"CUTENSOR_OP_TAN",
"CUTENSOR_OP_SWISH",
"CUTENSOR_OP_SOFT_SIGN",
"CUTENSOR_OP_SOFT_PLUS",
"CUTENSOR_OP_SINH",
"CUTENSOR_OP_SIN",
"CUTENSOR_OP_SIGMOID",
"CUTENSOR_OP_RELU",
"CUTENSOR_OP_RCP",
"CUTENSOR_OP_NEG",
"CUTENSOR_OP_MUL",
"CUTENSOR_OP_MISH",
"CUTENSOR_OP_MIN",
"CUTENSOR_OP_MAX",
"CUTENSOR_OP_LOG",
"CUTENSOR_OP_FLOOR",
"CUTENSOR_OP_EXP",
"CUTENSOR_OP_COSH",
"CUTENSOR_OP_COS",
"CUTENSOR_OP_CONJ",
"CUTENSOR_OP_CEIL",
"CUTENSOR_OP_ATANH",
"CUTENSOR_OP_ATAN",
"CUTENSOR_OP_ASINH",
"CUTENSOR_OP_ASIN",
"CUTENSOR_OP_ADD",
"CUTENSOR_OP_ACOSH",
"CUTENSOR_OP_ACOS",
"CUTENSOR_OP_ABS",
"CUTENSOR_C_8U",
"CUTENSOR_C_8I",
"CUTENSOR_C_64U",
Expand Down Expand Up @@ -13401,7 +13434,6 @@ sub warnRocOnlyUnsupportedFunctions {
my $line_num = shift;
my $k = 0;
foreach $func (
"cutensorOperator_t",
"cusparseZhybsv_solve",
"cusparseZhybsv_analysis",
"cusparseZhyb2dense",
Expand Down Expand Up @@ -14089,6 +14121,36 @@ sub warnRocOnlyUnsupportedFunctions {
"CUTENSOR_R_4I",
"CUTENSOR_R_16U",
"CUTENSOR_R_16I",
"CUTENSOR_OP_TANH",
"CUTENSOR_OP_TAN",
"CUTENSOR_OP_SWISH",
"CUTENSOR_OP_SOFT_SIGN",
"CUTENSOR_OP_SOFT_PLUS",
"CUTENSOR_OP_SINH",
"CUTENSOR_OP_SIN",
"CUTENSOR_OP_SIGMOID",
"CUTENSOR_OP_RELU",
"CUTENSOR_OP_RCP",
"CUTENSOR_OP_NEG",
"CUTENSOR_OP_MUL",
"CUTENSOR_OP_MISH",
"CUTENSOR_OP_MIN",
"CUTENSOR_OP_MAX",
"CUTENSOR_OP_LOG",
"CUTENSOR_OP_FLOOR",
"CUTENSOR_OP_EXP",
"CUTENSOR_OP_COSH",
"CUTENSOR_OP_COS",
"CUTENSOR_OP_CONJ",
"CUTENSOR_OP_CEIL",
"CUTENSOR_OP_ATANH",
"CUTENSOR_OP_ATAN",
"CUTENSOR_OP_ASINH",
"CUTENSOR_OP_ASIN",
"CUTENSOR_OP_ADD",
"CUTENSOR_OP_ACOSH",
"CUTENSOR_OP_ACOS",
"CUTENSOR_OP_ABS",
"CUTENSOR_C_8U",
"CUTENSOR_C_8I",
"CUTENSOR_C_64U",
Expand Down
35 changes: 34 additions & 1 deletion docs/tables/CUTENSOR_API_supported_by_HIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,39 @@
|`CUTENSOR_C_64U`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_C_8I`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_C_8U`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_OP_ABS`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_ACOS`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_ACOSH`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_ADD`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_ASIN`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_ASINH`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_ATAN`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_ATANH`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_CEIL`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_CONJ`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_COS`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_COSH`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_EXP`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_FLOOR`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_IDENTITY`|1.0.1.0| | | |`HIPTENSOR_OP_IDENTITY`|5.7.0| | | | |
|`CUTENSOR_OP_LOG`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_MAX`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_MIN`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_MISH`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_OP_MUL`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_NEG`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_RCP`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_RELU`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_SIGMOID`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_SIN`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_SINH`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_SOFT_PLUS`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_OP_SOFT_SIGN`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_OP_SQRT`|1.0.1.0| | | |`HIPTENSOR_OP_SQRT`|6.2.0| | | | |
|`CUTENSOR_OP_SWISH`|2.0.0.0| | | | | | | | | |
|`CUTENSOR_OP_TAN`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_TANH`|1.0.1.0| | | | | | | | | |
|`CUTENSOR_OP_UNKNOWN`|1.0.1.0| | | |`HIPTENSOR_OP_UNKNOWN`|5.7.0| | | | |
|`CUTENSOR_R_16BF`|2.0.0.0| | | |`HIPTENSOR_COMPUTE_16BF`|5.7.0| | | | |
|`CUTENSOR_R_16F`|2.0.0.0| | | |`HIPTENSOR_COMPUTE_16F`|5.7.0| | | | |
|`CUTENSOR_R_16I`|2.0.0.0| | | | | | | | | |
Expand Down Expand Up @@ -48,7 +81,7 @@
|`CUTENSOR_STATUS_NOT_SUPPORTED`| | | | |`HIPTENSOR_STATUS_NOT_SUPPORTED`| | | | | |
|`CUTENSOR_STATUS_SUCCESS`| | | | |`HIPTENSOR_STATUS_SUCCESS`| | | | | |
|`cutensorDataType_t`|2.0.0.0| | | |`hiptensorComputeType_t`|5.7.0| | | | |
|`cutensorOperator_t`| | | | | | | | | | |
|`cutensorOperator_t`|1.0.1.0| | | |`hiptensorOperator_t`|5.7.0| | | | |
|`cutensorStatus_t`| | | | |`hiptensorStatus_t`| | | | | |

## **2. CUTENSOR Function Reference**
Expand Down
73 changes: 72 additions & 1 deletion src/CUDA2HIP_TENSOR_API_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,40 @@ const std::map<llvm::StringRef, hipCounter> CUDA_TENSOR_TYPE_NAME_MAP {
{"CUTENSOR_R_64U", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_C_64U", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},

{"cutensorOperator_t", {"", "", CONV_TYPE, API_TENSOR, 1, UNSUPPORTED}},
{"cutensorOperator_t", {"hiptensorOperator_t", "", CONV_TYPE, API_TENSOR, 1}},
{"CUTENSOR_OP_IDENTITY", {"HIPTENSOR_OP_IDENTITY", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1}},
{"CUTENSOR_OP_SQRT", {"HIPTENSOR_OP_SQRT", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1}},
{"CUTENSOR_OP_RELU", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_CONJ", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_RCP", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_SIGMOID", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_TANH", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_EXP", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_LOG", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_ABS", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_NEG", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_SIN", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_COS", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_TAN", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_SINH", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_COSH", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_ASIN", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_ACOS", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_ATAN", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_ASINH", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_ACOSH", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_ATANH", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_CEIL", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_FLOOR", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_MISH", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_SWISH", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_SOFT_PLUS", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_SOFT_SIGN", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_ADD", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_MUL", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_MAX", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_MIN", {"", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1, UNSUPPORTED}},
{"CUTENSOR_OP_UNKNOWN", {"HIPTENSOR_OP_UNKNOWN", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1}},

{"cutensorStatus_t", {"hiptensorStatus_t", "", CONV_TYPE, API_TENSOR, 1}},
{"CUTENSOR_STATUS_SUCCESS", {"HIPTENSOR_STATUS_SUCCESS", "", CONV_NUMERIC_LITERAL, API_TENSOR, 1}},
Expand Down Expand Up @@ -105,6 +138,40 @@ const std::map<llvm::StringRef, cudaAPIversions> CUDA_TENSOR_TYPE_NAME_VER_MAP {
{"CUTENSOR_C_64I", {CUTENSOR_2000, CUDA_0, CUDA_0, }},
{"CUTENSOR_R_64U", {CUTENSOR_2000, CUDA_0, CUDA_0, }},
{"CUTENSOR_C_64U", {CUTENSOR_2000, CUDA_0, CUDA_0, }},
{"cutensorOperator_t", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_IDENTITY", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_SQRT", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_RELU", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_CONJ", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_RCP", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_SIGMOID", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_TANH", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_EXP", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_LOG", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_ABS", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_NEG", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_SIN", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_COS", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_TAN", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_SINH", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_COSH", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_ASIN", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_ACOS", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_ATAN", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_ASINH", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_ACOSH", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_ATANH", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_CEIL", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_FLOOR", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_MISH", {CUTENSOR_2000, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_SWISH", {CUTENSOR_2000, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_SOFT_PLUS", {CUTENSOR_2000, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_SOFT_SIGN", {CUTENSOR_2000, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_ADD", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_MUL", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_MAX", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_MIN", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
{"CUTENSOR_OP_UNKNOWN", {CUTENSOR_1010, CUDA_0, CUDA_0, }},
};

const std::map<llvm::StringRef, hipAPIversions> HIP_TENSOR_TYPE_NAME_VER_MAP {
Expand All @@ -119,4 +186,8 @@ const std::map<llvm::StringRef, hipAPIversions> HIP_TENSOR_TYPE_NAME_VER_MAP {
{"HIPTENSOR_COMPUTE_8U", {HIP_5070, HIP_0, HIP_0, }},
{"HIPTENSOR_COMPUTE_32I", {HIP_5070, HIP_0, HIP_0, }},
{"HIPTENSOR_COMPUTE_32U", {HIP_5070, HIP_0, HIP_0, }},
{"hiptensorOperator_t", {HIP_5070, HIP_0, HIP_0, }},
{"HIPTENSOR_OP_IDENTITY", {HIP_5070, HIP_0, HIP_0, }},
{"HIPTENSOR_OP_SQRT", {HIP_6020, HIP_0, HIP_0, }},
{"HIPTENSOR_OP_UNKNOWN", {HIP_5070, HIP_0, HIP_0, }},
};
11 changes: 11 additions & 0 deletions tests/unit_tests/synthetic/libraries/cutensor2hiptensor.cu
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ int main() {
cutensorDataType_t TENSOR_R_32U = CUTENSOR_R_32U;
#endif

#if CUTENSOR_MAJOR >= 1
// CHECK: hiptensorOperator_t tensorOperator_t;
// CHECK-NEXT hiptensorOperator_t TENSOR_OP_IDENTITY = HIPTENSOR_OP_IDENTITY;
// CHECK-NEXT hiptensorOperator_t TENSOR_OP_SQRT = HIPTENSOR_OP_SQRT;
// CHECK-NEXT hiptensorOperator_t TENSOR_OP_UNKNOWN = HIPTENSOR_OP_UNKNOWN;
cutensorOperator_t tensorOperator_t;
cutensorOperator_t TENSOR_OP_IDENTITY = CUTENSOR_OP_IDENTITY;
cutensorOperator_t TENSOR_OP_SQRT = CUTENSOR_OP_SQRT;
cutensorOperator_t TENSOR_OP_UNKNOWN = CUTENSOR_OP_UNKNOWN;
#endif

// CHECK: hiptensorStatus_t tensorStatus_t;
// CHECK-NEXT hiptensorStatus_t TENSOR_STATUS_SUCCESS = HIPTENSOR_STATUS_SUCCESS;
// CHECK-NEXT hiptensorStatus_t TENSOR_STATUS_NOT_INITIALIZED = HIPTENSOR_STATUS_NOT_INITIALIZED;
Expand Down

0 comments on commit 749524a

Please sign in to comment.