Skip to main content

cutensorCreatePermutation

Function cutensorCreatePermutation 

Source
pub unsafe extern "C" fn cutensorCreatePermutation(
    handle: cutensorHandle_t,
    desc: *mut cutensorOperationDescriptor_t,
    descA: cutensorTensorDescriptor_t,
    modeA: *const i32,
    opA: cutensorOperator_t,
    descB: cutensorTensorDescriptor_t,
    modeB: *const i32,
    descCompute: cutensorComputeDescriptor_t,
) -> cutensorStatus_t
Expand description

This function creates an operation descriptor for a tensor permutation.

The tensor permutation has the following general form: $$ B_{\Pi^B(i_0,i_1,…,i_n)} = \alpha op_A(A_{\Pi^A(i_0,i_1,…,i_n)}) $$

Consequently, this function performs an out-of-place tensor permutation and is a specialization of cutensorCreateElementwiseBinary.

Where

  • A and B are multi-mode tensors (of arbitrary data types),
  • $\Pi^A, \Pi^B$ are permutation operators that permute the modes of A, B respectively,
  • $op_A$ is an unary element-wise operators (e.g., IDENTITY, SQR, CONJUGATE), and

Broadcasting (of a mode) can be achieved by simply omitting that mode from the respective tensor.

Modes may appear in any order. The only restrictions are:

  • modes that appear in A must also appear in the output tensor.
  • each mode may appear in each tensor at most once.

Supported data-type combinations are:

typeAtypeBdescCompute
cudaDataType_t::CUDA_R_16FcudaDataType_t::CUDA_R_16FCUTENSOR_COMPUTE_DESC_16F
cudaDataType_t::CUDA_R_16FcudaDataType_t::CUDA_R_16FCUTENSOR_COMPUTE_DESC_32F
cudaDataType_t::CUDA_R_16FcudaDataType_t::CUDA_R_32FCUTENSOR_COMPUTE_DESC_32F
cudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_16FCUTENSOR_COMPUTE_DESC_32F
cudaDataType_t::CUDA_R_16BFcudaDataType_t::CUDA_R_16BFCUTENSOR_COMPUTE_DESC_16BF
cudaDataType_t::CUDA_R_16BFcudaDataType_t::CUDA_R_16BFCUTENSOR_COMPUTE_DESC_32F
cudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FCUTENSOR_COMPUTE_DESC_32F
cudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_R_64FCUTENSOR_COMPUTE_DESC_64F
cudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_64FCUTENSOR_COMPUTE_DESC_64F
cudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_R_32FCUTENSOR_COMPUTE_DESC_64F
cudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FCUTENSOR_COMPUTE_DESC_32F
cudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_C_64FCUTENSOR_COMPUTE_DESC_64F
cudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_64FCUTENSOR_COMPUTE_DESC_64F
cudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_C_32FCUTENSOR_COMPUTE_DESC_64F

Remark

calls asynchronous functions, no reentrant, and thread-safe.

§Parameters

  • handle: Opaque handle holding cuTENSOR’s library context.
  • desc: This opaque struct gets allocated and filled with the information that encodes the requested permutation.
  • descA: The descriptor that holds information about the data type, modes, and strides of A.
  • modeA: Array of size descA->numModes that holds the names of the modes of A (e.g., if A_{a,b,c} => modeA = {‘a’,’b’,’c’}).
  • opA: Unary operator that will be applied to each element of A before it is further processed. The original data of this tensor remains unchanged.
  • descB: The descriptor that holds information about the data type, modes, and strides of B.
  • modeB: Array of size descB->numModes that holds the names of the modes of B.
  • descCompute: Determines the precision in which this operations is performed.

§Return value