Skip to main content

cutensorCreateElementwiseBinary

Function cutensorCreateElementwiseBinary 

Source
pub unsafe extern "C" fn cutensorCreateElementwiseBinary(
    handle: cutensorHandle_t,
    desc: *mut cutensorOperationDescriptor_t,
    descA: cutensorTensorDescriptor_t,
    modeA: *const i32,
    opA: cutensorOperator_t,
    descC: cutensorTensorDescriptor_t,
    modeC: *const i32,
    opC: cutensorOperator_t,
    descD: cutensorTensorDescriptor_t,
    modeD: *const i32,
    opAC: cutensorOperator_t,
    descCompute: cutensorComputeDescriptor_t,
) -> cutensorStatus_t
Expand description

This function creates an operation descriptor for an elementwise binary operation.

The binary operation has the following general form: $$ D_{\Pi^C(i_0,i_1,…,i_n)} = \Phi_{AC}(\alpha op_A(A_{\Pi^A(i_0,i_1,…,i_n)}), \gamma op_C(C_{\Pi^C(i_0,i_1,…,i_n)})) $$

Call cutensorElementwiseBinaryExecute to perform the actual operation.

Supported data-type combinations are:

typeAtypeCdescCompute
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_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_C_32FcudaDataType_t::CUDA_C_32FCUTENSOR_COMPUTE_DESC_32F
cudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_C_64FCUTENSOR_COMPUTE_DESC_64F
cudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_16FCUTENSOR_COMPUTE_DESC_32F
cudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_R_32FCUTENSOR_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 elementwise operation.
  • descA: The descriptor that holds the information about the data type, modes, and strides of A.
  • modeA: Array (in host memory) of size descA->numModes that holds the names of the modes of A (e.g., if A_{a,b,c} => modeA = {‘a’,’b’,’c’}). The modeA[i] corresponds to extent[i] and stride[i] with respect to the arguments provided to cutensorCreateTensorDescriptor.
  • 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.
  • descC: The descriptor that holds information about the data type, modes, and strides of C.
  • modeC: Array (in host memory) of size descC->numModes that holds the names of the modes of C. The modeC[i] corresponds to extent[i] and stride[i] of the cutensorCreateTensorDescriptor.
  • opC: Unary operator that will be applied to each element of C before it is further processed. The original data of this tensor remains unchanged.
  • descD: The descriptor that holds information about the data type, modes, and strides of D. Notice that we currently request descD and descC to be identical.
  • modeD: Array (in host memory) of size descD->numModes that holds the names of the modes of D. The modeD[i] corresponds to extent[i] and stride[i] of the cutensorCreateTensorDescriptor.
  • opAC: Element-wise binary operator (corresponding to $\Phi_{AC}$ above).
  • descCompute: Determines the precision in which this operations is performed.

§Return value