cuPHY  0.1
CUDA PHY Layer Acceration Library
Functions
Tensor Operations

This section describes the tensor operation functions of the cuPHY application programming interface. More...

Functions

cuphyStatus_t cuphyConvertTensor (cuphyTensorDescriptor_t tensorDescDst, void *dstAddr, cuphyTensorDescriptor_t tensorDescSrc, const void *srcAddr, cudaStream_t strm)
 Converts a source tensor to a different type or layout. More...
 

Detailed Description

Function Documentation

◆ cuphyConvertTensor()

cuphyStatus_t cuphyConvertTensor ( cuphyTensorDescriptor_t  tensorDescDst,
void *  dstAddr,
cuphyTensorDescriptor_t  tensorDescSrc,
const void *  srcAddr,
cudaStream_t  strm 
)

Converts an input tensor (described by an address and a tensor descriptor) to an output tensor, possibly changing layout and/or data type in the process. The input and output tensors must have the same dimensions.

Tensors with identical data types, dimensions, and strides may be converted internally using a memory copy operation.

The following conversions are currently supported:

  • Conversion of all types to tensors with the same dimensions but different strides
  • Widening conversions (e.g. conversion of a signed, unsigned, or floating point fundamental type to the same fundamental type with a larger range (e.g. CUPHY_R_8I to CUPHY_R_32I)

Other conversions are possible and may be added in the future.

Parameters
tensorDescDst- previously allocated cuphyTensorDescriptor_t for the destination (output)
dstAddr- tensor address for output data
tensorDescSrc- previously allocated cuphyTensorDescriptor_t for source data
srcAddr- tensor address for input data
strm- CUDA stream for memory copy

Returns CUPHY_STATUS_INVALID_ARGUMENT if any of tensorDescDst, dstAddr, tensorDescSrc, or srcAddr is NULL, or if the data type of either tensorDescDst or tensorDescSrc is CUPHY_VOID.

Returns CUPHY_STATUS_SIZE_MISMATCH if all dimensions of tensor descriptors tensorDescDst and tensorDescSrc do not match.

Returns CUPHY_STATUS_MEMCPY_ERROR if an error occurred performing a memory copy from the source to the destination.

Returns CUPHY_STATUS_SUCCESS if the conversion operation was submitted to the given stream successfully.

Returns
CUPHY_STATUS_SUCCESS, CUPHY_STATUS_SIZE_MISMATCH CUPHY_STATUS_INVALID_ARGUMENT
See also
cuphyStatus_t,cuphyCreateTensorDescriptor,cuphySetTensorDescriptor