Loss Function Layer

The loss function layer API documentation

miopenCTCLossAlgo_t

enum miopenCTCLossAlgo_t

Algorithms available to execute the CTC loss operation

Values:

MIOPEN_CTC_LOSS_ALGO_DETERMINISTIC = 0

Results are guaranteed to be reproducible

miopenCreateCTCLossDescriptor

miopenStatus_t miopenCreateCTCLossDescriptor(miopenCTCLossDescriptor_t *ctcLossDesc)

Create a CTC loss function Descriptor.

API for creating an uninitialized CTC loss function descriptor.

Return
miopenStatus_t
Parameters
  • ctcLossDesc: Pointer to the CTC loss function descriptor type (output)

miopenGetCTCLossDescriptor

miopenStatus_t miopenGetCTCLossDescriptor(miopenCTCLossDescriptor_t ctcLossDesc, miopenDataType_t *dataType, int *blank_label_id, bool *apply_softmax_layer)

Retrieves a CTC loss function descriptor’s details.

Return
miopenStatus_t
Parameters
  • ctcLossDesc: CTC loss function descriptor (input)
  • dataType: Data type used in this CTC loss operation, only fp32 currently supported (output)
  • blank_label_id: User defined index for blank label (output)
  • apply_softmax_layer: Boolean to toggle input layer property (output)

miopenDestroyCTCLossDescriptor

miopenStatus_t miopenDestroyCTCLossDescriptor(miopenCTCLossDescriptor_t ctcLossDesc)

Destroys a CTC loss function descriptor object.

Return
miopenStatus_t
Parameters
  • ctcLossDesc: CTC loss function descriptor type (input)

miopenSetCTCLossDescriptor

miopenStatus_t miopenSetCTCLossDescriptor(miopenCTCLossDescriptor_t ctcLossDesc, miopenDataType_t dataType, const int blank_label_id, bool apply_softmax_layer)

Set the details of a CTC loss function descriptor.

Return
miopenStatus_t
Parameters
  • ctcLossDesc: CTC loss function descriptor type (input)
  • dataType: Data type used in this CTC loss operation, only fp32 currently supported (input)
  • blank_label_id: User defined index for blank label, default 0 (input)
  • apply_softmax_layer: Boolean to toggle input layer property (input)

miopenGetCTCLossWorkspaceSize

miopenStatus_t miopenGetCTCLossWorkspaceSize(miopenHandle_t handle, const miopenTensorDescriptor_t probsDesc, const miopenTensorDescriptor_t gradientsDesc, const int *labels, const int *labelLengths, const int *inputLengths, miopenCTCLossAlgo_t algo, const miopenCTCLossDescriptor_t ctcLossDesc, size_t *workSpaceSize)

Query the amount of memory required to execute miopenCTCLoss.

This function calculates the amount of memory required to run the CTC loss function given a CTC loss function descriptor with the specified algorithm.

Return
miopenStatus_t
Parameters
  • handle: MIOpen handle (input)
  • probsDesc: Tensor descriptor for probabilities (input)
  • gradientsDesc: Tensor descriptor for gradients (input)
  • labels: Pointer to the flattened labels list (input)
  • labelLengths: Pointer to the lengths list for “labels” (input)
  • inputLengths: Pointer to the list of the time steps in each batch (input)
  • algo: CTC loss algorithm selected (input)
  • ctcLossDesc: CTC loss function descriptor type (input)
  • workSpaceSize: Number of bytes of workspace required for CTC loss operation with selected algorithm (output)

miopenCTCLoss

miopenStatus_t miopenCTCLoss(miopenHandle_t handle, const miopenTensorDescriptor_t probsDesc, const void *probs, const int *labels, const int *labelLengths, const int *inputLengths, void *losses, const miopenTensorDescriptor_t gradientsDesc, void *gradients, miopenCTCLossAlgo_t algo, const miopenCTCLossDescriptor_t ctcLossDesc, void *workSpace, size_t workSpaceSize)

Execute forward inference for CTCLoss layer.

Interface for executing the forward inference pass on a CTCLoss.

Return
miopenStatus_t
Parameters
  • handle: MIOpen handle (input)
  • probsDesc: Tensor descriptor for probabilities (input)
  • probs: Pointer to the probabilities tensor (input)
  • labels: Pointer to the flattened labels list (input)
  • labelLengths: Pointer to the lengths list for “labels” (input)
  • inputLengths: Pointer to the list of the time steps in each batch (input)
  • losses: Pointer to the computed losses of CTC (Output)
  • gradientsDesc: Tensor descriptor for gradients (input)
  • gradients: Pointer to the computed gradients of CTC (Output)
  • algo: CTC loss algorithm selected (input)
  • ctcLossDesc: CTC loss function descriptor type (input)
  • workSpace: Pointer to memory allocated for execute CTC loss operation (input)
  • workSpaceSize: Number of bytes of workspace required for CTC loss operation with selected algorithm (input)