Tensors

Tensor types and functions.

miopenDataType_t

enum miopenDataType_t

MIOpen floating point datatypes. Both 32-bit and 16-bit floats are supported in MIOpen.

Values:

miopenHalf = 0

16-bit floating point (Fully supported)

miopenFloat = 1

32-bit floating point (Fully supported)

miopenInt32 = 2

32-bit int point (Not supported)

miopenInt8 = 3

8-bit int point (Partially supported)

miopenInt8x4 = 4

Pack of four 8-bit int points in NCHW_VECT_C format (Partially supported)

miopenTensorOp_t

enum miopenTensorOp_t

Element-wise tensor operation modes

Values:

miopenTensorOpAdd = 0

Add tensors element-wise

miopenTensorOpMul = 1

Multiply two tensors element-wise

miopenTensorOpMin = 2

Minimum of tensor element pairs

miopenTensorOpMax = 3

Maximum of tensor element pairs

miopenCreateTensorDescriptor

miopenStatus_t miopenCreateTensorDescriptor(miopenTensorDescriptor_t *tensorDesc)

Create a Tensor Descriptor.

API for creating an uninitialized tensor descriptor.

Return
miopenStatus_t
Parameters
  • tensorDesc: Pointer to a tensor descriptor type (output)

miopenSet4dTensorDescriptor

miopenStatus_t miopenSet4dTensorDescriptor(miopenTensorDescriptor_t tensorDesc, miopenDataType_t dataType, int n, int c, int h, int w)

Set shape of 4D tensor.

Interface for setting 4-D tensor shape. MIOpen currently only implements NCHW layout.

Return
miopenStatus_t
Parameters
  • tensorDesc: Tensor descriptor type (output)
  • dataType: MIOpen datatype (input)
  • n: Mini-batch size (input)
  • c: Number of channels (input)
  • h: Data height dimension size (input)
  • w: Data width dimension size (input)

miopenGet4dTensorDescriptor

miopenStatus_t miopenGet4dTensorDescriptor(miopenTensorDescriptor_t tensorDesc, miopenDataType_t *dataType, int *n, int *c, int *h, int *w, int *nStride, int *cStride, int *hStride, int *wStride)

Get the details of the tensor descriptor.

Interface to query the 4-D tensor shape.

Return
miopenStatus_t
Parameters
  • tensorDesc: Tensor descriptor type (input)
  • dataType: MIOpen datatype (input)
  • n: Mini-batch size (output)
  • c: Number of channels (output)
  • h: Data height dimension size (output)
  • w: Data width dimension size (output)
  • nStride: Mini-batch dimension stride (output)
  • cStride: Channel dimension stride (output)
  • hStride: Height dimension stride (output)
  • wStride: Width dimension stride (output)

miopenSetTensorDescriptor

miopenStatus_t miopenSetTensorDescriptor(miopenTensorDescriptor_t tensorDesc, miopenDataType_t dataType, int nbDims, int *dimsA, int *stridesA)

Set shape of N-dimensional tensor.

Interface for setting tensor shape. MIOpen has support for 1, 2, 3, 4, 5 dimensional tensor of layout.

Return
miopenStatus_t
Parameters
  • tensorDesc: Tensor descriptor type (input)
  • dataType: MIOpen datatype (input)
  • nbDims: Number of dimensions in the dimsA array (input)
  • dimsA: Array containing the size of dimensions (input)
  • stridesA: Array containing the size of stride (input)

miopenGetTensorDescriptorSize

miopenStatus_t miopenGetTensorDescriptorSize(miopenTensorDescriptor_t tensorDesc, int *size)

Set shape of N-dimensional tensor.

Interface for querying tensor size. MIOpen has support for 1, 2, 3, 4, 5 dimensional tensor of layout.

Return
miopenStatus_t
Parameters
  • tensorDesc: Tensor descriptor type (input)
  • size: number of elements in tensor described by the descriptor (output)

miopenGetTensorDescriptor

miopenStatus_t miopenGetTensorDescriptor(miopenTensorDescriptor_t tensorDesc, miopenDataType_t *dataType, int *dimsA, int *stridesA)

Get the details of the N-dimensional tensor descriptor.

Return
miopenStatus_t
Parameters
  • tensorDesc: Tensor descriptor type (input)
  • dataType: MIOpen datatype (input)
  • dimsA: Array containing the size of dimensions (output)
  • stridesA: Array containing the size of stride (output)

miopenDestroyTensorDescriptor

miopenStatus_t miopenDestroyTensorDescriptor(miopenTensorDescriptor_t tensorDesc)

Destroys the tensor descriptor.

Return
miopenStatus_t
Parameters
  • tensorDesc: Tensor descriptor type (input)

miopenOpTensor

miopenStatus_t miopenOpTensor(miopenHandle_t handle, miopenTensorOp_t tensorOp, const void *alpha1, const miopenTensorDescriptor_t aDesc, const void *A, const void *alpha2, const miopenTensorDescriptor_t bDesc, const void *B, const void *beta, const miopenTensorDescriptor_t cDesc, void *C)

Execute element-wise tensor operations.

This function implements: \( C = op ( alpha1[0] * A, alpha2[0] * B ) + beta[0] * C \)

For Forward Bias one can also use, miopenConvolutionForwardBias()

Return
miopenStatus_t
Parameters
  • handle: MIOpen handle (input)
  • tensorOp: Operation from miopenTensorOp_t (input)
  • alpha1: Tensor A’s floating point scaling factor, allocated on the host (input)
  • aDesc: Tensor descriptor for tensor A (input)
  • A: Tensor A (input)
  • alpha2: Tensor B’s floating point scaling factor, allocated on the host (input)
  • bDesc: Tensor descriptor for tensor B (input)
  • B: Tensor B (input)
  • beta: Tensor C’s floating point scaling factor, allocated on the host (input)
  • cDesc: Tensor descriptor for tensor C (input)
  • C: Tensor C (input and output)

miopenSetTensor

miopenStatus_t miopenSetTensor(miopenHandle_t handle, const miopenTensorDescriptor_t yDesc, void *y, const void *alpha)

Fills a tensor with a single value.

Return
miopenStatus_t
Parameters
  • handle: MIOpen handle (input)
  • yDesc: Tensor descriptor for tensor y (input)
  • y: Tensor y (input)
  • alpha: Pointer to fill value (input)

miopenScaleTensor

miopenStatus_t miopenScaleTensor(miopenHandle_t handle, const miopenTensorDescriptor_t yDesc, void *y, const void *alpha)

Scales all elements in a tensor by a single value.

Return
miopenStatus_t
Parameters
  • handle: MIOpen handle (input)
  • yDesc: Tensor descriptor for tensor y (input)
  • y: Tensor y (input and output)
  • alpha: Floating point scaling factor, allocated on the host (input)