Shortcuts

DIOPI C API

Author

OpenComputeLab

Copyright

(c) 2023, OpenComputeLab.

Enums

enum diopiReduction_t

Values:

enumerator ReductionNone
enumerator ReductionMean
enumerator ReductionSum
enumerator ReductionEND
enum diopiRoundMode_t

Values:

enumerator RoundModeNone
enumerator RoundModeTrunc
enumerator RoundModeFloor
enumerator RoundModeEND
enum diopiMemoryFormat_t

Values:

enumerator Contiguous
enumerator ChannelsLast
enumerator ChannelsLast3d
enumerator Preserve
enumerator ChannelsLast1d

Functions

DIOPI_RT_API const char * diopiGetVendorName ()

get the vendor’s name who implements the functions

DIOPI_RT_API const char * diopiGetImplVersion ()
DIOPI_RT_API const char * diopiGetLastErrorString ()
DIOPI_API diopiError_t diopiConvolution2d (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight, diopiConstTensorHandle_t bias, diopiSize_t stride, diopiSize_t padding, diopiSize_t dilation, int64_t groups)

Applies a 2D convolution over an input image composed of several input planes.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float32, float16, float64].

  • weight – the weight tensor; dimension of kernel_size must match the number of input spatial dimensions. type = [float32, float16, float64].

  • bias – bias tensor. type = [float32, float16, float64].

  • stride – an array with dimension matching the number of input spatial dimensions. type = [int32, int64].

  • padding – an array with dimension matching the number of input spatial dimensions. type = [int32, int64].

  • dilation – an array with dimension matching the number of input spatial dimensions. type = [int32, int64].

  • groups – number of groups for grouped convolution. type = [int64].

  • out[out] the result tensor. type = [float32, float16, float64].

DIOPI_API diopiError_t diopiConvolution2dBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiTensorHandle_t grad_weight, diopiTensorHandle_t grad_bias, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight, diopiSize_t *bias_sizes, diopiSize_t stride, diopiSize_t padding, diopiSize_t dilation, bool transposed, diopiSize_t output_padding, int64_t groups)

Backward pass for convolution2d. Computes gradients for input, weight, and bias.

参见

Other parameters refer to diopiConvolution2d().

参数
  • grad_output[in] the grad tensor of output. type = [float32, float16, float64].

  • bias_sizes – an array, indicates that a bias was used in the forward pass and contains the shape of the bias. type = [int32, int64].

  • transposed – indicating whether the convolution is transposed.

  • output_padding – an array, dimension == number of input spatial dimensions; only supported when transposed is true. type = [int32, int64].

  • grad_input[out] the grad of input. type = [float32, float16, float64].

  • grad_weight – the grad of weight. type = [float32, float16, float64].

  • grad_bias – the grad of bias. type = [float32, float16, float64].

DIOPI_API diopiError_t diopiBatchNorm (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiTensorHandle_t save_mean, diopiTensorHandle_t save_invstd, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight, diopiConstTensorHandle_t bias, diopiTensorHandle_t running_mean, diopiTensorHandle_t running_var, bool training, double momentum, double eps)

Applies Batch Normalization for each channel across a batch of data.

参数
  • ctx[in] Context environment.

  • input – input tensor. type = [float32, float16, float64].

  • weight – weight tensor. type = [float32, float16, float64].

  • bias – bias tensor. type = [float32, float16, float64].

  • running_mean – weighted average tensor. type = [float32, float16, float64].

  • running_var – weighted variance tensor. type = [float32, float16, float64].

  • training – check if in training mode.

  • momentum – Used to calculate the running mean and variance during runtime. type = [float32, float64]

  • eps – The value added to the denominator during batch normalization to ensure numerical stability. type = [float32, float64]

  • out[out] normalized result. type = [float32, float16, float64].

  • save_mean – Mean tensor,the mean value for each feature channel of the input tensor. type = [float32, float16, float64].

  • save_invstd – Backup of inverse standard deviation computed during training. type = [float32, float16, float64].

DIOPI_API diopiError_t diopiBatchNormBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiTensorHandle_t grad_weight, diopiTensorHandle_t grad_bias, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight, diopiConstTensorHandle_t running_mean, diopiConstTensorHandle_t running_var, diopiConstTensorHandle_t save_mean, diopiConstTensorHandle_t save_invstd, bool training, double eps)

compute the backward pass of batch normalization

参见

Other parameters refer to diopiBatchNorm().

参数
  • grad_output[in] Gradient of normalized layer output, with the same shape as the forward pass output. type=[float32, float16, float64].

  • grad_input[out] Gradient of the input data, with the same shape as the input data. type = [float32, float16, float64].

  • grad_weight – Gradient of the weight parameter, with the same shape as the weight parameter. type = [float32, float16, float64].

  • grad_bias – Gradient of the bias parameter, with the same shape as the bias parameter. type = [float32, float16, float64].

DIOPI_API diopiError_t diopiRelu (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Applies the rectified linear unit function element-wise.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64].

  • out[out] the result tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiReluInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of diopiRelu().

参数
  • ctx[in] Context environment.

  • input – the input tensor and will be stored result tensor.type = [float32, float64].

DIOPI_API diopiError_t diopiHardtanh (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *min_val, const diopiScalar_t *max_val)

It clips the tensor values within a range defined by the lower and upper bounds. Any values below the lower bound are set to the lower bound, and any values above the upper bound are set to the upper bound.

参数
  • ctx[in] Context environment.

  • input – the input tensor,type = [float32, float64].

  • min_val – scalar, the lower bound. type = [float32, float64].

  • max_val – scalar, the upper bound. type = [float32, float64].

  • out[out] the output tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiHardtanhInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *min_val, const diopiScalar_t *max_val)

the in-place version of diopiHardtanh().

参见

Other parameters refer to diopiHardtanh().

参数

input – the input tensor and will be stored result tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiHardtanhBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, const diopiScalar_t *min_val, const diopiScalar_t *max_val)

compute the backward pass of diopiHardtanhInp().

参见

Other parameters refer to diopiHardtanh().

参数
  • grad_output[in] the grad of output. type = [float32, float64].

  • grad_input[out] the grad of input. type = [float32, float64].

DIOPI_API diopiError_t diopiHardswish (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)
DIOPI_API diopiError_t diopiHardswishInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)
DIOPI_API diopiError_t diopiHardswishBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input)
DIOPI_API diopiError_t diopiThreshold (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *threshold, const diopiScalar_t *value)

The function thresholds the input tensor by setting elements greater than a given threshold to the threshold value, while leaving elements less than or equal to the threshold unchanged.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float16, float32, float64].

  • threshold – the value to threshold at. type = [float16, float32, float64].

  • value – the value to replace with. type = [float16, float32, float64].

  • out[out] the output tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiThresholdInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *threshold, const diopiScalar_t *value)

the in-place version of diopiThreshold().

参见

Other parameters refer to diopiThreshold().

参数
  • ctx[in] Context environment.

  • input – the input tensor and will be stored result tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiThresholdBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, const diopiScalar_t *threshold)

compute the backward pass of diopiThreshold().

参见

Other parameters refer to diopiThreshold().

参数
  • grad_output[in] the grad of output. type = [float16, float32, float64].

  • grad_input[out] the grad of input. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiGelu (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const char *approximate)

Applies the gaussian error linear unit function element-wise.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float32, float64].

  • approximate – Whether to use an approximate estimation. If it equals to “tanh”, it will use an approximate estimation.

  • out[out] theout put tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiGeluBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, const char *approximate)

compute the backward pass of diopiGelu().

参见

Other parameters refer to diopiHardtanh().

参数
  • grad_output[in] the grad of output. type = [float32, float64].

  • grad_input[out] the grad of input. type = [float32, float64].

DIOPI_API diopiError_t diopiLeakyRelu (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *negative_slope)

Applies element-wise, LeakyReLU(x) = max(0,x) + negative_slope*min(0,x)

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float32, float64].

  • negative_slope – Controls the angle of the negative slope.

  • out[out] the output tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiLeakyReluInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *negative_slope)

the in-place version of diopiLeakyRelu().

参见

Other parameters refer to diopiLeakyRelu().

参数

input[in] the input and output tensor and will be stored result tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiLeakyReluBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, const diopiScalar_t *negative_slope, bool input_is_result)

compute the backward pass of diopiLeakyRelu().

参见

Other parameters refer to diopiLeakyRelu().

参数
  • grad_output[in] the grad of output. type = [float32, float64].

  • input_is_result – boolean.

  • grad_input[out] the grad of input. type = [float32, float64].

DIOPI_API diopiError_t diopiAvgPool2d (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t kernel_size, diopiSize_t stride, diopiSize_t padding, bool ceil_mode, bool count_include_pad, const int64_t *divisor_override)

Applies 2D average-pooling operation in kH×kW regions by step size sH×sW steps.

参数
  • ctx[in] Context environment.

  • input – input tensor, type = [float32, float64]

  • kernel_size – an array, the size of the pooling region. type = [int32, int64].

  • stride – an array, the stride of the pooling operation. type = [int32, int64].

  • padding – an array. type = [int32, int64].

  • ceil_mode – boolean, when set to True, uses ceil instead of floor in the formula to compute the output shape.

  • count_include_pad – boolean, when True, zero-padding will be included in the mean calculation.

  • divisor_override – If specified, it will be used as the divisor when computing the average pooling, otherwise the default is to divide by the total number of pooling elements.

  • out[out] the output tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiAvgPool2dBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiSize_t kernel_size, diopiSize_t stride, diopiSize_t padding, bool ceil_mode, bool count_include_pad, const int64_t *divisor_override)

compute the backward pass of diopiAvgPool2d().

参见

Other parameters refer to diopiAvgPool2d().

参数
  • grad_output[in] the grad of output. type = [float32, float64].

  • grad_input[out] the grad of input. type = [float32, float64].

DIOPI_API diopiError_t diopiMaxPool2d (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t kernel_size, diopiSize_t stride, diopiSize_t padding, diopiSize_t dilation, bool ceil_mode)

Applies a 2D max pooling over an input signal composed of several input planes.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float16, float32]

  • kernel_size – an array, size of the pooling region. type = [int32, int64].

  • stride – an array, stride of the pooling operation. type = [int32, int64].

  • padding – an array, implicit negative infinity padding on both sides of the input tensor, its value should be >= 0 and <= kernel_size / 2. type = [int32, int64].

  • dilation – an array, spacing between the elements within the sliding window, its value should be greater than 0. type = [int32, int64].

  • ceil_mode – boolean, if True, use ceil instead of the default floor operation when computing the output shape. This ensures that every element in the input tensor is covered by a sliding window.

  • out[out] the output tensor. type = [float16, float32].

DIOPI_API diopiError_t diopiMaxPool2dWithIndices (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiTensorHandle_t indices, diopiConstTensorHandle_t input, diopiSize_t kernel_size, diopiSize_t stride, diopiSize_t padding, diopiSize_t dilation, bool ceil_mode)

With indices, applies a 2D max pooling over an input signal composed of several input planes.

参见

Other parameters refer to diopiMaxPool2d().

参数
  • ctx[in] Context environment.

  • indices – It contains the flattened index positions of each maximum value in the max pooling operation. type = [int32, int64].

DIOPI_API diopiError_t diopiMaxPool2dBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiSize_t kernel_size, diopiSize_t stride, diopiSize_t padding, diopiSize_t dilation, bool ceil_mode, diopiConstTensorHandle_t indices)

compute the backward pass of diopiMaxPool2d().

参见

Other parameters refer to diopiMaxPool2d().

参数
  • grad_output[in] the grad of output. type = [float16, float32].

  • grad_input[out] the grad of input. type = [float16, float32].

DIOPI_API diopiError_t diopiAdaptiveAvgPool2d (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t output_size)

Applies a 2D adaptive average pooling over an input signal composed of several input planes.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float16, float32, float64]

  • output_size – an array, the size of the output tensor. type = [int32, int64].

  • out[out] the output tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiAdaptiveAvgPool2dBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input)

compute the backward pass of diopiAdaptiveAvgPool2d().

参见

Other parameters refer to diopiAdaptiveAvgPool2d().

参数
  • grad_output[in] the grad of output. type = [float16, float32, float64].

  • grad_input[out] the grad of input. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiAdaptiveMaxPool2d (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t output_size)

Applies a 2D adaptive max pooling over an input signal composed of several input planes.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float32, float16, float64]

  • output_size – an array, the size of the output tensor. type = [int32, int64].

  • out[out] the output tensor. type = [float32, float16, float64].

DIOPI_API diopiError_t diopiAdaptiveMaxPool2dWithIndices (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiTensorHandle_t indices, diopiConstTensorHandle_t input, diopiSize_t output_size)
DIOPI_API diopiError_t diopiAdaptiveMaxPool2dBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t indices)

compute the backward pass of diopiAdaptiveMaxPool2d().

参见

Other parameters refer to diopiAdaptiveMaxPool2d().

参数
  • grad_output[in] the grad of output. type = [float32, float16, float64].

  • grad_input[out] the grad of input. type = [float32, float16, float64].

DIOPI_API diopiError_t diopiDropout (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiTensorHandle_t mask, diopiConstTensorHandle_t input, double p, bool train)

Randomly zeroes some of the elements of the input tensor with probability p using samples from a Bernoulli distribution.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64].

  • p – the probability of an element in the input tensor being zeroed out. type = [float32, float64].

  • train – boolean, whether the module is in training mode. When set to False, the dropout operation will not be performed.

  • out[out] the output tensor. type = [float32, float64].

  • mask – A binary mask tensor of the same shape as the input tensor, where each element’s value is either 0 or 1, indicating whether the corresponding neuron at that position is dropped or not. type = [int32].

DIOPI_API diopiError_t diopiDropoutInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiTensorHandle_t mask, double p, bool train)

the in-place version of diopiDropout().

参见

Other parameters refer to diopiDropout().

参数

input[in] the input tensor and will be stored result tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiMSELoss (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t target, diopiReduction_t reduction)

Measures the element-wise mean squared error.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float32, float64].

  • target – the target tensor. type = [float32, float64].

  • reduction – Specifies the reduction to apply to the output.

  • out[out] the result tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiMSELossBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t target, diopiReduction_t reduction)

Measures the element-wise mean squared error.

参数
  • input[in] the input tensor. type = [float32, float64].

  • grad_output – the grad tensor of output. type = [float32, float64].

  • target – the target tensor. type = [float32, float64].

  • reduction – Specifies the reduction to apply to the output.

  • grad_input[out] the grad of input. type = [float32, float64].

DIOPI_API diopiError_t diopiSigmoidFocalLoss (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t inputs, diopiConstTensorHandle_t targets, float alpha, float gamma, diopiReduction_t reduction)
DIOPI_API diopiError_t diopiSigmoidFocalLossBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t target, diopiTensorHandle_t grad_input, float gamma, float alpha, diopiReduction_t reduction)
DIOPI_API diopiError_t diopiCrossEntropyLoss (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t target, diopiConstTensorHandle_t weight, diopiReduction_t reduction, int64_t ignore_index, double label_smoothing)

Measures thee Cross Entropy between the target and input probabilities.

参数
  • ctx[in] Context environment.

  • input – Input tensor representing the unnormalized scores, often referred to as logits. type = [float32, float64].

  • target – Target tensor representing the true class index or class probabilities. type = [float32, float64].

  • weight – Manual rescaling weight for each class. type = [float32, float64].

  • reduction – Specifies the reduction to apply to the output.

  • ignore_index – Specifies a target value that is to be ignored and does not contribute to the input gradient. Only used when targets are class indices. type = [int64].

  • label_smoothing – Float value in [0.0, 1.0]. Specifies the amount of smoothing to be applied while computing the loss. type = [float32, float64]

  • out[out] the output tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiCrossEntropyLossBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t target, diopiConstTensorHandle_t weight, diopiReduction_t reduction, int64_t ignore_index, double label_smoothing)

compute the backward pass of diopiCrossEntropyLoss().

参见

Other parameters refer to diopiCrossEntropyLoss().

参数
  • grad_output[in] the grad of output. type = [float32, float64].

  • grad_input[out] the grad of input. type = [float32, float64].

DIOPI_API diopiError_t diopiNLLLoss (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t target, diopiConstTensorHandle_t weight, diopiReduction_t reduction, int64_t ignore_index)

Measures thee nll loss between the target and input probabilities.

参数
  • ctx[in] Context environment.

  • input – Input tensor, usually representing log probabilities. type = [float32, float64]

  • target – Target tensor representing class indices, with values in the range of [0, C). type = [int64]

  • weight – weights manually assigned to each class. type = [float32, float64]

  • reduction – Loss reduction mode, which can be none, sum, or mean.

  • ignore_index – Specifies a target value to be ignored and does not contribute to the input gradient. This parameter can only be used when the target contains class indices. type = [int64].

  • out[out] the output tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiNLLLossBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t target, diopiConstTensorHandle_t weight, diopiReduction_t reduction, int64_t ignore_index)

compute the backward pass of diopiNLLLoss().

参见

Other parameters refer to diopiNLLLoss().

参数
  • grad_output[in] the grad of output. type = [float32, float64].

  • grad_input[out] the grad of input. type = [float32, float64].

DIOPI_API diopiError_t diopiBCEWithLogits (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t target, diopiConstTensorHandle_t weight, diopiConstTensorHandle_t pos_weight, diopiReduction_t reduction)

Measures the Binary Cross Entropy between the target and input probabilities.

参数
  • ctx[in] Context environment.

  • input – Tensor of arbitrary shape as unnormalized scores (often referred to as logits). type = [float32, float64].

  • target – Tensor of the same shape as input with values between 0 and 1. type = [float32, float64].

  • weight – a manual rescaling weight given to the loss of each batch element. If given, has to be a Tensor of size nbatch. type = [float32, float64].

  • pos_weight – a weight of positive examples. Must be a vector with length equal to the number of classes. type = [int64].

  • reduction – Specifies the reduction to apply to the output

  • out[out] the output tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiBCEWithLogitsBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t target, diopiConstTensorHandle_t weight, diopiConstTensorHandle_t pos_weight, diopiReduction_t reduction)

compute the backward pass of diopiBCEWithLogits().

参见

Other parameters refer to diopiBCEWithLogits().

参数
  • grad_output[in] the grad of output. type = [float32, float64].

  • grad_input[out] the grad of input. type = [float32, float64].

DIOPI_API diopiError_t diopiBCELoss (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t target, diopiConstTensorHandle_t weight, diopiReduction_t reduction)
DIOPI_API diopiError_t diopiBCELossBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t target, diopiConstTensorHandle_t weight, diopiReduction_t reduction)
DIOPI_API diopiError_t diopiSign (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Element-wise math functions.

DIOPI_API diopiError_t diopiAbsInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of diopiAbs().

参数

input[in] the input and output tensor and will be stored result tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8].

DIOPI_API diopiError_t diopiAbs (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Computes the absolute value of each element in the input tensor element-wise.

参数
  • ctx[in] Context environment.

  • input – Input tensor, type = [float16, float32, float64, int16, int32, int64, uint8, int8].

  • out[out] the output tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8].

DIOPI_API diopiError_t diopiNegInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of diopiNeg().

参数

input[in] the input and output tensor and will be stored result tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8].

DIOPI_API diopiError_t diopiNeg (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Returns a new tensor with the negative of the elements of input.

参数
  • ctx[in] Context environment.

  • input – Input tensor, type = [float16, float32, float64, int16, int32, int64, uint8, int8].

  • out[out] the output tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8].

DIOPI_API diopiError_t diopiFloorInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of floor.

参数
  • ctx[in] Context environment.

  • input – the input tensor, and will be stored result tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiFloor (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Returns a new tensor with the floor of the elements of input, the largest integer less than or equal to each element.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float16, float32, float64].

  • out[out] the output tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiCeilInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)
DIOPI_API diopiError_t diopiCeil (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)
DIOPI_API diopiError_t diopiSqrtInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of diopiSqrt().

参数

input[in] the input and output tensor and will be stored result tensor, type = [float16, float32]

DIOPI_API diopiError_t diopiSqrt (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Take the element-wise square root of the input tensor.

参数
  • ctx[in] Context environment.

  • input – Input tensor, type = [float16, float32].

  • out[out] the output tensor. type = [float16, float32].

DIOPI_API diopiError_t diopiRsqrtInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)
DIOPI_API diopiError_t diopiRsqrt (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)
DIOPI_API diopiError_t diopiSinInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of diopiSin().

参数

input[in] the input and output tensor and will be stored result tensor, type = [float16, float32, float64, int16, int32, int64, uint8, int8].

DIOPI_API diopiError_t diopiSin (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Compute the element-wise sine values of the input tensor input.

参数
  • ctx[in] Context environment.

  • input – Input tensor, type = [float16, float32, float64, int16, int32, int64, uint8, int8].

  • out[out] the output tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiAsinInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)
DIOPI_API diopiError_t diopiAsin (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)
DIOPI_API diopiError_t diopiCosInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of diopiCos().

参数

input[in] the input and output tensor and will be stored result tensor, type = [float16, float32, float64, int16, int32, int64, uint8, int8].

DIOPI_API diopiError_t diopiCos (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Compute the element-wise cosine values of the input tensor input.

参数
  • ctx[in] Context environment.

  • input – Input tensor, type = [float16, float32, float64, int16, int32, int64, uint8, int8].

  • out[out] the output tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiTanhInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of tanh.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiTanh (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Returns a new tensor with the hyperbolic tangent of the elements of input.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float16, float32, float64].

  • out[out] the input tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiTanhBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t output)

Backward pass for tanh.

参数
  • grad_output[in] the grad tensor of output.

  • output – the output tensor. type = [float16, float32, float64].

  • grad_input[out] the grad tensor of input. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiAtan (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Returns a new tensor with the hyperbolic arctan of the elements of input.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float16, float32, float64].

  • out[out] the input tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiAtanInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of atan.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiSigmoidInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of diopiSigmoid().

参数

input[in] the input tensor and will be stroed reuslt tensor. type = [float16, float32].

DIOPI_API diopiError_t diopiSigmoid (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Element-wise applies the sigmoid function to the input tensor input.

参数
  • ctx[in] Context environment.

  • input – the input tensor.type = [float16, float32].

  • out[out] the output tensor. type = [float16, float32].

DIOPI_API diopiError_t diopiSigmoidBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t output)

compute the backward pass of diopiSigmoid().

参见

Other parameters refer to diopiSigmoid().

参数
  • grad_output[in] the grad of output. type = [float16, float32].

  • output – the output tensor of diopiSigmoid(). type = [float16, float32].

  • grad_input[out] the grad of input. type = [float16, float32].

DIOPI_API diopiError_t diopiSiluInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)
DIOPI_API diopiError_t diopiSilu (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)
DIOPI_API diopiError_t diopiSiluBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input)
DIOPI_API diopiError_t diopiExpInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of diopiExp().

参数

input[in] the input tensor and will be stroed reuslt tensor. type = [float16, float32, float64]

DIOPI_API diopiError_t diopiExp (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Returns a new tensor with the exponential of the elements of the input tensor input.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8, bool].

  • out[out] the output tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiLogInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of diopiLog().

参数

input[in] the input tensor and will be stroed reuslt tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8].

DIOPI_API diopiError_t diopiLog (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Compute the element-wise natural logarithm of input tensor input.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8].

  • out[out] the output tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiLog2Inp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of diopiLog2().

参数

input[in] the input tensor and will be stroed reuslt tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8].

DIOPI_API diopiError_t diopiLog2 (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Compute the logarithm (base-2) of each element in the input tensor element-wise.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8].

  • out[out] the output tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiLog10Inp (diopiContextHandle_t ctx, diopiTensorHandle_t input)
DIOPI_API diopiError_t diopiLog10 (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)
DIOPI_API diopiError_t diopiErfInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)
DIOPI_API diopiError_t diopiErf (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)
DIOPI_API diopiError_t diopiPowScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, const diopiScalar_t *input, diopiConstTensorHandle_t exponent)
DIOPI_API diopiError_t diopiPow (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *exponent)

Raise each element in the input to the power of the exponent.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [int32, int64, uint8, int8, int16, float32, float64, float16].

  • exponent – the value of exponent. type = [int32, int64, uint8, int8, int16, float32, float64, float16, bool].

  • out[out] the output tensor. type = [int32, int64, uint8, int8, int16, float32, float64, float16].

DIOPI_API diopiError_t diopiPowInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *exponent)

the in-place version of diopiPow().

参见

Other parameters refer to diopiPow().

参数

input[in] the input tensor andw will be stored result tensor. type = [int32, int64, uint8, int8, int16, float32, float64, float16].

DIOPI_API diopiError_t diopiPowTensor (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t exponent)

Raise each element in the input to the power of the corresponding element in exponent.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [int32, int64, uint8, int8, int16, float32, float64, float16].

  • exponent – the exponent tensor. type = [int32, int64, uint8, int8, int16, float32, float64, float16, bool].

  • out[out] the output tensor. type = [int32, int64, uint8, int8, int16, float32, float64, float16].

DIOPI_API diopiError_t diopiPowInpTensor (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t exponent)

the in-place version of diopiPowTensor().

参见

Other parameters refer to diopiPowTensor().

参数

input[in] the input tensor andw will be stored result tensor. type = [float32, float64, float16].

DIOPI_API diopiError_t diopiAdd (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other, const diopiScalar_t *alpha)

This function is used to perform addition operations between tensors.

参数
  • ctx[in] Context environment.

  • input – the first input tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the second input tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool]

  • alpha – Scaling factor, i.e., the scaling factor of the second tensor.type = [float32, float64, int32, int64].

  • out[out] Output tensor for storing the result of the addition operation. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiAddInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other, const diopiScalar_t *alpha)

the in-place version of diopiAdd()

参见

Other parameters refer to diopiAdd().

参数

input[in] the first input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiAddScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *other, const diopiScalar_t *alpha)

Add a scalar to a tensor.

参见

Other parameters refer to diopiAdd().

参数

other[in] The scalar value to be added. type = [float64, float32, float16, int64, int32, int16, int8, uint8].

DIOPI_API diopiError_t diopiAddInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *other, const diopiScalar_t *alpha)

the in-place version of diopiAddScalar().

参见

Other parameters refer to diopiAddScalar().

参数

input[in] the first input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiSub (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other, const diopiScalar_t *alpha)

perform subtraction operations between tensors.

参数
  • ctx[in] Context environment.

  • input – the first input tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the second input tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • alpha – Scaling factor, i.e., the scaling factor of the second tensor. type = [float32, float64, int32, int64].

  • out[out] the output tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiSubInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other, const diopiScalar_t *alpha)

the in-place version of diopiSub().

参见

Other parameters refer to diopiSub().

参数

input[in] the first input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiSubScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *other, const diopiScalar_t *alpha)

sub a scalar to a tensor.

参见

Other parameters refer to diopiSub().

参数

other[in] The scalar value to be sub. type = [float64, float32, float16, int64, int32, int16, int8, uint8].

DIOPI_API diopiError_t diopiSubInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *other, const diopiScalar_t *alpha)

the in-place version of diopiSubScalar().

参见

Other parameters refer to diopiSub().

参数

input[in] the first input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiMul (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Multiply tensor input with other (matrix multiplication)

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the second tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • out[out] the output tensor.

DIOPI_API diopiError_t diopiMulInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other)

the in-place version of diopiMul().

参见

Other parameters refer to diopiMul().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiMulScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *other)

Multiply tensor input with other (element-wise multiplication)

参见

Other parameters refer to diopiMul().

参数

other[in] The scalar value to be added. type = [float64, float32, float16, int64, int32, int16, int8, uint8].

DIOPI_API diopiError_t diopiMulInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *other)

the in-place version of diopiMulScalar().

参见

Other parameters refer to diopiMul().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiDiv (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other, diopiRoundMode_t rounding_mode)

Divides each element of input tensor by the corresponding element in other tensor.

参数
  • ctx[in] Context environment.

  • input – the input tensor, dividend. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the second tensor, Divisor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • rounding_mode – Rounding mode applied to the result, None: no rounding is performed, if both input and other are integer types, the inputs are promoted to the default scalar type; trunc: truncate towards zero; floor: round down towards negative infinity for the result of the division.

  • out[out] the output tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiDivInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other, diopiRoundMode_t rounding_mode)

the in-place version of diopiDiv().

参见

Other parameters refer to diopiDiv().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiDivScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *other, diopiRoundMode_t rounding_mode)

Divides each element of input tensor by the scalar element.

参见

Other parameters refer to diopiDiv().

参数

other[in] float scalar, Divisor. type = [int32, int64, float32, float64].

DIOPI_API diopiError_t diopiDivInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *other, diopiRoundMode_t rounding_mode)

the in-place version of diopiDivScalar().

参见

Other parameters refer to diopiDivScalar().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiBmm (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t mat2)

Broadcast-BLAS functions.

参数
  • ctx[in] Context environment.

  • input – the first batch of matrices to be multiplied. type = [float16, float32, float64].

  • mat2 – the second batch of matrices to be multiplied. type = [float16, float32, float64].

  • out[out] the output tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiBaddbmm (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t batch1, diopiConstTensorHandle_t batch2, double beta, double alpha)
DIOPI_API diopiError_t diopiBaddbmmInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t batch1, diopiConstTensorHandle_t batch2, double beta, double alpha)
DIOPI_API diopiError_t diopiAddcmul (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t tensor1, diopiConstTensorHandle_t tensor2, const diopiScalar_t *value)

Performs the element-wise multiplication.

参数
  • ctx[in] Context environment.

  • input – the input tensor to be added. type = [float16, float32, float64].

  • tensor1 – the tensor to be multiplied. type = [float16, float32, float64].

  • tensor2 – the tensor to be multiplied. type = [float16, float32, float64].

  • value – multiplier tensor1 * tensor2, type=[float16, float32, float64].

  • out[out] the out tensor. type=[float16, float32, float64].

DIOPI_API diopiError_t diopiAddcmulInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t tensor1, diopiConstTensorHandle_t tensor2, const diopiScalar_t *value)

the in-place version of addcmul.

参数
  • ctx[in] Context environment.

  • tensor1 – the tensor to be multiplied. type = [float16, float32, float64].

  • tensor2 – the tensor to be multiplied. type = [float16, float32, float64].

  • value – multiplier for tensor1 * tensor2, type=[float16, float32, float64].

  • input[out] the input tensor to be added and will be stored result tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiMatmul (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Matrix multiplication. The multiplication rules depend on the dimensions of the input tensors.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float32, float64].

  • other – the second tensor. type = [float32, float64].

  • out[out] the output tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiAddcdiv (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t tensor1, diopiConstTensorHandle_t tensor2, const diopiScalar_t *value)

Performs the element-wise division.

参数
  • ctx[in] Context environment.

  • input – the input tensor to be added. type = [float16, float32, float64].

  • tensor1 – the numerator tensor. type = [float16, float32, float64].

  • tensor2 – the denominator tensor. type = [float16, float32, float64].

  • value – multiplier for tensor1 / tensor2, type=[float16, float32, float64].

  • out[out] the out tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiAddcdivInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t tensor1, diopiConstTensorHandle_t tensor2, const diopiScalar_t *value)

the in-place version of addcdiv.

参数
  • ctx[in] Context environment.

  • tensor1 – the numerator tensor. type = [float16, float32, float64].

  • tensor2 – the denominator tensor. type = [float16, float32, float64].

  • value – multiplier for tensor1 / tensor2, type=[float16, float32, float64].

  • input[out] the input tensor to be added and will be stored result tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiAddmm (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t mat1, diopiConstTensorHandle_t mat2, const diopiScalar_t *beta, const diopiScalar_t *alpha)

Performs matrix multiplication between mat1 and mat2, multiplies the result by scalar value alpha, adds it to input tensor beta x input.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float32, float64, float16]].

  • mat1 – the first martix. type = [float32, float64, float16].

  • mat2 – the second martix. type = [float32, float64, float16].

  • beta – scale factor of input. type = [int32, int64, float32, float64].

  • alpha – the scaling factor for the multiplication result of the tensors. type = [int32, int64, float32, float64].

  • out[out] the output tensor. type = [float32, float64, float16].

DIOPI_API diopiError_t diopiCholesky (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiTensorHandle_t info, diopiConstTensorHandle_t mat, bool upper, bool checkerror)
DIOPI_API diopiError_t diopiCholeskyBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_mat, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t L, bool upper)
DIOPI_API diopiError_t diopiTriangularSolve (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiTensorHandle_t cloned_mat, diopiConstTensorHandle_t b, diopiConstTensorHandle_t mat, bool upper, bool transpose, bool unitriangular)
DIOPI_API diopiError_t diopiTriangularSolveBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_b, diopiTensorHandle_t grad_mat, diopiConstTensorHandle_t grad_x, diopiConstTensorHandle_t grad_cloned_mat, diopiConstTensorHandle_t x, diopiConstTensorHandle_t b, diopiConstTensorHandle_t mat, bool upper, bool transpose, bool unitriangular)
DIOPI_API diopiError_t diopiClampInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *min, const diopiScalar_t *max)

the in-place version of diopiClampScalar().

参见

Other parameters refer to diopiClampScalar()

参数

input – the input tensor and will be stored result tensor. type = [float32, float64, float16, int16, int32, int64, int8].

DIOPI_API diopiError_t diopiClampInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t min, diopiConstTensorHandle_t max)

the in-place version of diopiClamp().

参见

Other parameters refer to diopiClamp()

参数

input[in] the input tensor and will be stored result tensor. type = [float32, float64, float16, int16, int32, int64, int8].

DIOPI_API diopiError_t diopiClampScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *min, const diopiScalar_t *max)

Clamps all elements in input into the range [min, max].

参数
  • ctx[in] Context environment.

  • input – the input tensor and output tensor.type = [float32, float64, float16, int16, int32, int64, int8].

  • min – scalar, the lower-bound value. type = [float32, float64].

  • max – scalar, the upper-bound value. type = [float32, float64].

  • out[out] the output tensor. type = [float32, float64, float16].

DIOPI_API diopiError_t diopiClamp (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t min, diopiConstTensorHandle_t max)

Clamps all elements in input into the range [min, max].

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64, float16, int16, int32, int64, int8, uint8]

  • min – The lower-bound value tensor. type=[float32, float64].

  • max – The upper-bound value tensor. type=[float32, float64].

  • out[out] the output tensor. type = [float32, float64, float16].

DIOPI_API diopiError_t diopiClampMaxInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *max)
DIOPI_API diopiError_t diopiClampMaxInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t max)
DIOPI_API diopiError_t diopiClampMaxScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *max)
DIOPI_API diopiError_t diopiClampMax (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t max)
DIOPI_API diopiError_t diopiClampMinInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *min)
DIOPI_API diopiError_t diopiClampMinInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t min)
DIOPI_API diopiError_t diopiClampMinScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *min)
DIOPI_API diopiError_t diopiClampMin (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t min)
DIOPI_API diopiError_t diopiFill (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *value)

Fills elements of self tensor with value.

参数
  • ctx[in] Context environment.

  • input – the input tensor and output tensor. type = [float32, float64, float16, int16, int32, int64, int8, uint8].

  • value – the value to fill the tensor with. type = [float32, float64, float16, int16, int32, int64, int8, uint8].

DIOPI_API diopiError_t diopiLogicalAnd (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Computes the element-wise logical AND of the given input tensors.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the second tesnor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool]

  • out[out] the output tensor. type = [bool].

DIOPI_API diopiError_t diopiLogicalAndInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other)

the in-place version of diopiLogicalAnd().

参见

Other parameters refer to diopiLogicalAnd().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiLogicalOr (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Computes the element-wise logical OR of the given input tensors.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the second tesnor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • out[out] the output tensor. type = [bool].

DIOPI_API diopiError_t diopiLogicalOrInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other)

the in-place version of diopiLogicalOr().

参见

Other parameters refer to diopiLogicalOr().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiLogicalNot (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)
DIOPI_API diopiError_t diopiLogicalNotInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)
DIOPI_API diopiError_t diopiBitwiseAnd (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Computes the bitwise AND of the given input tensors.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [int16, int32, int64, int8, uint8, bool].

  • other – the second tesnor. type = [int16, int32, int64, int8, uint8, bool].

  • out[out] the output tensor. type = [int16, int32, int64, int8, uint8, bool].

DIOPI_API diopiError_t diopiBitwiseAndInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other)

the in-place version of diopiBitwiseAnd().

参见

Other parameters refer to diopiBitwiseAnd().

参数

input[in] the input tensor and will be stored result tensor. type = [int16, int32, int64, int8, uint8, bool].

DIOPI_API diopiError_t diopiBitwiseAndScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *other)

Computes the bitwise AND of the given input tensors.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [int16, int32, int64, int8, uint8, bool].

  • other – The scalar value to be bitwise and. type = [int16, int32, int64, int8, uint8, bool].

  • out[out] the output tensor. type = [int16, int32, int64, int8, uint8, bool].

DIOPI_API diopiError_t diopiBitwiseAndInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *other)

the in-place version of diopiBitwiseAndScalar().

参见

Other parameters refer to diopiBitwiseAndScalar().

参数

input[in] the input tensor and will be stored result tensor. type = [int16, int32, int64, int8, uint8, bool].

DIOPI_API diopiError_t diopiBitwiseOr (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)
DIOPI_API diopiError_t diopiBitwiseOrInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other)
DIOPI_API diopiError_t diopiBitwiseOrScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *other)
DIOPI_API diopiError_t diopiBitwiseOrInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *other)
DIOPI_API diopiError_t diopiBitwiseNot (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Computes the bitwise NOT of the given input tensor. The input tensor must be of integral or Boolean types. For bool tensors, it computes the logical NOT.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type=[int16, int32, int64, uint8, int8, bool].

  • out[out] the result tensor. type=[int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiBitwiseNotInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of diopiBitwiseNot.

参数
  • ctx[in] Context environment. type=[int16, int32, int64, uint8, int8, bool].

  • input – the input tensor and will be stored result tensor. type=[int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiEqScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *other)

Computes equal element-wise comparison with a scalar, “>=”.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the scalar to be compared. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • out[out] the output tensor.Each element has a boolean value, i.e. either false or true. type = [bool].

DIOPI_API diopiError_t diopiEqInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *other)

the in-place version of diopiEqScalar().

参见

Other parameters refer to diopiEqScalar().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiEq (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Computes equal element-wise comparison, “=”.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the second tensor. The dimenson should be same as input tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • out[out] the output tensor.Each element has a boolean value, i.e. either false or true. type = [bool].

DIOPI_API diopiError_t diopiEqInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other)

the in-place version of diopiEq().

参见

Other parameters refer to diopiEq().

参数

input[in] the input tensor and will be stored result tensor.

DIOPI_API diopiError_t diopiNeScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *other)

Computes not equal element-wise comparison with a scalar, “!=”.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the scalar to be compared. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • out[out] the output tensor.Each element has a boolean value, i.e. either false or true. type = [bool].

DIOPI_API diopiError_t diopiNeInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *other)

the in-place version of diopiNeScalar().

参见

Other parameters refer to diopiNeScalar().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiNe (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Computes not equal element-wise comparison, “!=”.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the second tensor.The dimenson should be same as input tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • out[out] the output tensor.Each element has a boolean value, i.e. either false or true. type = [bool].

DIOPI_API diopiError_t diopiNeInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other)

the in-place version of diopiNe().

参见

Other parameters refer to diopiNe().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiGeScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *other)

Computes greater or equal element-wise comparison with a scalar, “>=”.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the scalar to be compared. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • out[out] the output tensor.Each element has a boolean value, i.e. either false or true. type = [bool].

DIOPI_API diopiError_t diopiGeInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *other)

the in-place version of diopiGeScalar().

参见

Other parameters refer to diopiGeScalar().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiGe (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Computes greater or equal element-wise comparison, “>=”.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the second tensor.The dimenson should be same as input tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • out[out] the output tensor.Each element has a boolean value, i.e. either false or true. type = [bool].

DIOPI_API diopiError_t diopiGeInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other)

the in-place version of diopiGe().

参见

Other parameters refer to diopiGe().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiGtScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *other)

Computes greater element-wise comparison with a scalar, “>”.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the scalar to be compared. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • out[out] the output tensor.Each element has a boolean value, i.e. either false or true. type = [bool].

DIOPI_API diopiError_t diopiGtInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *other)

the in-place version of diopiGtScalar().

参见

Other parameters refer to diopiGtScalar().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiGt (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Computes greater element-wise comparison, “>”.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the second tensor.The dimenson should be same as input tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • out[out] the output tensor.Each element has a boolean value, i.e. either false or true. type = [bool].

DIOPI_API diopiError_t diopiGtInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other)

the in-place version of diopiGt().

参见

Other parameters refer to diopiGt().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiLeScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *other)

Computes smaller or equal element-wise comparison with a scalar, “<=”.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the scalar to be compared. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • out[out] the output tensor.Each element has a boolean value, i.e. either false or true. type = [bool].

DIOPI_API diopiError_t diopiLeInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *other)

the in-place version of diopiLeScalar().

参见

Other parameters refer to diopiLeScalar().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiLe (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Computes smaller or equal element-wise comparison, “<=”.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the second tensor. The dimenson should be same as input tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • out[out] the output tensor.Each element has a boolean value, i.e. either false or true. type = [bool].

DIOPI_API diopiError_t diopiLeInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other)

the in-place version of diopiLe().

参见

Other parameters refer to diopiLe().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiLtScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *other)

Computes smaller element-wise comparison with a scalar, “<”.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the scalar to be compared. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • out[out] the output tensor.Each element has a boolean value, i.e. either false or true.

DIOPI_API diopiError_t diopiLtInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, const diopiScalar_t *other)

the in-place version of diopiLtScalar().

参见

Other parameters refer to diopiLtScalar().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiLt (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Computes smaller element-wise comparison, “<”.

参数
  • ctx[in] Context environment.

  • input – the first tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

  • other – the second tensor.The dimenson should be same as input tensor.

  • out[out] the output tensor.Each element has a boolean value, i.e. either false or true. type = [bool].

DIOPI_API diopiError_t diopiLtInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t other)

the in-place version of diopiLt().

参见

Other parameters refer to diopiLt().

参数

input[in] the input tensor and will be stored result tensor. type = [float64, float32, float16, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiMean (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t dim)

Returns the mean value of all elements in the input tensor.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64, float16].

  • dim – an array, dimension for reduction. type = [int32, int64].

  • out[out] the output tensor depend on dim. type = [float32, float64, float16].

DIOPI_API diopiError_t diopiSum (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t dim)

Returns the sum value of all elements in the input tensor.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64, float16]

  • dim – an array, dimension for reduction. type = [int32, int64]

  • out[out] the output tensor depend on dim. type = [float32, float64, float16].

DIOPI_API diopiError_t diopiStd (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t dim, bool unbiased)

Returns the standard derivation of all elements in the input tensor.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64, float16].

  • dim – an array, dimension for reduction. type = [int32, int64].

  • unbiased – whether to compute the unbiased standard deviation.

  • out[out] the output tensor depend on dim. type = [float32, float64, float16].

DIOPI_API diopiError_t diopiMin (diopiContextHandle_t ctx, diopiTensorHandle_t min, diopiTensorHandle_t min_indices, diopiConstTensorHandle_t input, int64_t dim)

Return the minimum value of each row in the input tensor along the given dimension dim.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool]

  • dim – The dimension along which to reduce. type = [int64]

  • min[out] the output tensor, min element. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

  • min_indices – the index of the min element. type = [int32, int64].

DIOPI_API diopiError_t diopiMinAll (diopiContextHandle_t ctx, diopiTensorHandle_t min, diopiConstTensorHandle_t input)

Returns the minimum value of all elements in the input tensor.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

  • max[out] the output tensor, min element. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiMax (diopiContextHandle_t ctx, diopiTensorHandle_t max, diopiTensorHandle_t max_indices, diopiConstTensorHandle_t input, int64_t dim)

Return the maximum value of each row in the input tensor along the given dimension dim.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool]

  • dim – The dimension along which to reduce. type = [int64]

  • max[out] the output tensor, max element. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

  • max_indices – the index of the max element. type = [int32, int64].

DIOPI_API diopiError_t diopiMaxAll (diopiContextHandle_t ctx, diopiTensorHandle_t max, diopiConstTensorHandle_t input)

Returns the maximum value of all elements in the input tensor.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool]

  • max[out] the output tensor, max element. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiAny (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const int64_t *dim)

Returns True if any element in each row of the tensor in the given dimension dim are True, False otherwise.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type=[bool, float16, float32, float64, int16, int32, int64, uint8, int8]

  • dim – a int-64 type pointer, the dimension, it can be none.

  • out[out] the output tensor. type = [bool].

DIOPI_API diopiError_t diopiAll (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const int64_t *dim)

Returns True if all elements in each row of the tensor in the given dimension dim are True, False otherwise.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [bool, float16, float32, float64, int16, int32, int64, uint8, int8]

  • dim – a int pointer, the dimension along which the reduction is performed.

  • out[out] the output tensor. type = [bool].

DIOPI_API diopiError_t diopiSoftmax (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t dim)

Applies a softmax function.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64]

  • dim – The dimension on which to apply the softmax function to the input tensor. type = [int64]

  • out[out] the output tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiSoftmaxBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t output, int64_t dim)

compute the backward pass of diopiSoftmax().

参见

Other parameters refer to diopiNLLLoss().

参数
  • grad_output[in] the grad of output. type = [float32, float64].

  • output – the output tensor of diopiSoftmax(). type = [float32, float64].

  • grad_input[out] the grad of input. type = [float32, float64].

DIOPI_API diopiError_t diopiLogSoftmax (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t dim)

Applies a log_softmax function.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64].

  • dim – the dimension on which to apply the log_softmax function to the input tensor. type = [int64].

  • out[out] the output tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiLogSoftmaxBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t output, int64_t dim)

compute the backward pass of diopiLogSoftmax().

参见

Other parameters refer to diopiLogSoftmax().

参数
  • grad_output[in] the grad of output. type = [float32, float64].

  • output – the output tensor of diopiLogSoftmax(). type = [float32, float64].

  • grad_input[out] the grad of input. type = [float32, float64].

DIOPI_API diopiError_t diopiIndex (diopiContextHandle_t ctx, diopiTensorHandle_t *out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t *indices, int64_t nums)

Returns a new tensor which indexes the input tensor along dimension dim using the entries in index.

DIOPI_API diopiError_t diopiIndexBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiTensorHandle_t zeros_like_input, diopiConstTensorHandle_t *indices, int64_t nums, diopiConstTensorHandle_t grad)
DIOPI_API diopiError_t diopiIndexSelect (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t dim, diopiConstTensorHandle_t index)

Returns a new tensor that indexes the input tensor along dimension dim using the entries in the index tensor.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [int32, int16, int64, uint8, int8, bool, float32, float64, float16].

  • dim – the dimension along which to index. type = [int64].

  • index – the index tensor, type = [int32, int64].

  • out[out] the output tensor. type = [int32, int16, int64, uint8, int8, bool, float32, float64, float16].

DIOPI_API diopiError_t diopiIndexSelectBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad, diopiSize_t input_sizes, int64_t dim, diopiConstTensorHandle_t index)

compute the backward pass of diopiIndexSelect().

参见

Other parameters refer to diopiIndexSelect().

参数
  • grad_output[in] the grad of output. type = [float32, float64, float16].

  • grad – the grad tensor of diopiIndexSelect(). type = [float32, float64, float16].

  • input_sizes – the input tensor sizes of diopiIndexSelect(). type = [int32, int64].

  • grad_input[out] the grad of input. type = [float32, float64, float16].

DIOPI_API diopiError_t diopiSelect (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t dim, int64_t index)

Slices the input tensor along the selected dimension at the given index.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [int32, int16, int64, uint8, int8, bool, float32, float64, float16].

  • dim – the dimension along which to slice. type = [int64].

  • index – the index of the slice to return. type = [int64].

  • out[out] the output tensor. type = [int32, int16, int64, uint8, int8, bool, float32, float64, float16].

DIOPI_API diopiError_t diopiSelectBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiSize_t input_sizes, int64_t dim, int64_t index)

compute the backward pass of diopiSelect().

参见

Other parameters refer to diopiSelect().

参数
  • grad_output[in] the grad of output. type = [int32, int16, int64, uint8, int8, bool, float32, float64, float16].

  • input_sizes – the input tensor sizes of diopiSelect(). type = [int32, int16, int64, uint8, int8].

  • grad_input[out] the grad of input. type = [int32, int16, int64, uint8, int8, bool, float32, float64, float16].

DIOPI_API diopiError_t diopiSelectScatter (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t src, int64_t dim, int64_t index)

Embeds the values of the src tensor into input at the given index/dimension. This function returns a tensor with fresh storage; it does not create a view.

DIOPI_API diopiError_t diopiSliceScatter (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t src, int64_t dim, int64_t start, int64_t end, int64_t step)
DIOPI_API diopiError_t diopiSlice (diopiContextHandle_t ctx, diopiTensorHandle_t null_out, diopiConstTensorHandle_t input, int64_t dim, int64_t start, int64_t end, int64_t step)

Slices the input tensor along the selected dimension at the given index.

DIOPI_API diopiError_t diopiSliceBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiSize_t input_sizes, int64_t dim, int64_t start, int64_t end, int64_t step)
DIOPI_API diopiError_t diopiMaskedScatter (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t mask, diopiConstTensorHandle_t source)

Copies elements from source into self tensor at positions where the mask is True.

DIOPI_API diopiError_t diopiNms (diopiContextHandle_t ctx, diopiTensorHandle_t *out, diopiConstTensorHandle_t dets, diopiConstTensorHandle_t scores, double iou_threshold)
DIOPI_API diopiError_t diopiNonzero (diopiContextHandle_t ctx, diopiTensorHandle_t *out, diopiConstTensorHandle_t input)

Returns a tensor containing the indices of all non-zero elements of input.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type=[float32, float16, float64, int16, int32, int64, uint8, int8]

  • out[out] the output tensor. type = [int32, int64].

DIOPI_API diopiError_t diopiLinear (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight, diopiConstTensorHandle_t bias)

Applies a linear transformation to the incoming data: y=xAT+b.

参数
  • ctx[in] Context environment.

  • input – Input tensor, type = [float16, float32, float64].

  • weight – weight tensor, type = [float16, float32, float64].

  • bias – bias tensor, type = [float16, float32, float64].

  • out[out] the output tensor. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiLinearBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiTensorHandle_t grad_weight, diopiTensorHandle_t grad_bias, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight)

compute the backward pass of diopiLinear().

参见

Other parameters refer to diopiLinear().

参数
  • grad_output[in] the grad of output. type = [float16, float32, float64].

  • grad_input[out] the grad of input. type = [float16, float32, float64].

DIOPI_API diopiError_t diopiRoiAlign (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t rois, double spatial_scale, int64_t pooled_height, int64_t pooled_width, int64_t sampling_ratio, bool aligned)
DIOPI_API diopiError_t diopiRoiAlignBackward (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t grad, diopiConstTensorHandle_t rois, double spatial_scale, int64_t pooled_height, int64_t pooled_width, int64_t batch_size, int64_t channels, int64_t height, int64_t width, int64_t sampling_ratio, bool aligned)
DIOPI_API diopiError_t diopiSgd (diopiContextHandle_t ctx, diopiTensorHandle_t w, diopiTensorHandle_t dw, diopiTensorHandle_t buf, double lr, double momentum, double dampening, double weight_decay, bool nesterov)

Implements stochastic gradient descent optimizer, type=[float32, float16, float64].

参数
  • ctx[in] Context environment.

  • w – the params tensor. type = [float32, float64].

  • dw – the grad tensor of the params tensor. type = [float32, float64].

  • buf – the buffer tensor of Momentum. type = [float32, float64].

  • lr – leaning rate, type = [float32, float64].

  • momentum – Momentum factor. type = [float32, float64].

  • dampening – dampening factor. type = [float32, float64].

  • weight_decay – weight_decay factor. type = [float32, float64].

  • nesterov – boolean, whether to use Nesterov momentum.

DIOPI_API diopiError_t diopiClipGradNorm (diopiContextHandle_t ctx, double *out, diopiTensorHandle_t *grads, int64_t num_grads, double max_norm, double norm_type, bool error_if_nonfinite)

Clips gradient norm of an iterable of parameters.

参数
  • ctx[in] Context environment.

  • grads – an iterable of Tensors that will have gradients normalized. type = [float32, float64].

  • num_grads – the number of grads. type = [int64].

  • max_norm – max norm of the gradients. type = [float32, float64].

  • norm_type – type of the used p-norm. Can be 'inf' for infinity norm. type = [float32, float64].

  • error_if_nonfinite – If True, the operation will return an error if the total norm of the gradients is nan or inf.

  • out[out] total norm of the parameter gradients. type = [float32, float64].

DIOPI_API diopiError_t diopiEmbeddingRenorm_ (diopiContextHandle_t ctx, diopiTensorHandle_t inout, diopiConstTensorHandle_t indices, double max_norm, double norm_type)
DIOPI_API diopiError_t diopiEmbedding (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t weight, diopiConstTensorHandle_t indices, int64_t padding_idx, bool scale_grad_byfreq, bool sparse)

A simple lookup table that looks up embeddings in a fixed dictionary and size.

参数
  • ctx[in] Context environment.

  • weight – the embedding tensor. type = [float32, float64].

  • indices – the indices tensor. type = [int64].

  • padding_idx – padding_idx. type = [int64].

  • scale_grad_byfreq – boolean, whether to scale grad by freq.

  • sparse – boolean, whether to use sparse update.

  • out[out] the output tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiEmbeddingBackward (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t grad, diopiConstTensorHandle_t indices, int64_t num_weights, int64_t padding_idx, bool scale_grad_byfreq, bool sparse)

compute the backward pass of diopiEmbedding().

参见

Other parameters refer to diopiEmbedding().

参数
  • grad[in] the grad of output. type = [float32, float64].

  • grad_weight[out] the grad of weight. type = [float32, float64].

DIOPI_API diopiError_t diopiTril (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t diagonal)

Returns the lower triangular part of the matrix (2-D tensor) or batch of matrices input.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float32, float64, float16, int16, int32,int64, uint8, int8, bool].

  • diagonal – the diagonal to consider. type = [int64].

  • out[out] the output tensor. type = [float32, float64, float16, int16, int32,int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiCat (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t *tensors, int64_t num_inputs, int64_t dim)

Concatenates the given sequence of seq tensors in the given dimension.

参数
  • ctx[in] Context environment.

  • tensors – the list of the input tensor list. type = [float32, float16, float64, int16, int64, uint8, int8, bool, int32].

  • num_inputs – the number of input tensor list. type = [int64].

  • dim – the dimension over which the tensors are concatenated. type = [int64].

  • out[out] the output tensor. type = [float32, float16, float64, int16, int64, uint8, int8, bool, int32].

DIOPI_API diopiError_t diopiSplitWithSizes (diopiContextHandle_t ctx, diopiTensorHandle_t *outs, int64_t num_outs, diopiConstTensorHandle_t input, const diopiSize_t splitSizes, int64_t dim)

Splits the tensor into chunks.

参数
  • ctx[in] Context environment.

  • num_outs – the number of output tensor list. type = [int64].

  • input – the intput tensor. type = [float32, float16, float64, int16, int64, uint8, int8, bool, int32].

  • splitSizes – an array, size of each block or list of sizes for each block. type = [int32, int64].

  • dim – the dimension along which to split the tensor. type = [int64].

  • outs[out] the output tensor list.

DIOPI_API diopiError_t diopiStack (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t *tensors, int64_t numTensors, int64_t dim)

Concatenates a sequence of tensors along a new dimension.

参数
  • ctx[in] Context environment.

  • tensors – the list of tensor. type = [float32, float16, float64, int16, int64, uint8, int8, bool, int32]

  • numTensors – the number of tensor list. type = [int64].

  • dim – dimension along which to insert. Value must be between 0 and the number of dimensions of the tensor. type = [int64].

  • out[out] the output tensor. type = [float32, float16, float64, int16, int64, uint8, int8, bool, int32].

DIOPI_API diopiError_t diopiSort (diopiContextHandle_t ctx, diopiTensorHandle_t values, diopiTensorHandle_t indices, diopiConstTensorHandle_t input, int64_t dim, bool descending, const bool *stable)

Sorts the elements of the input tensor along a given dimension in ascending order by value.

参数
  • ctx[in] Context environment.

  • input – the intput tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8]

  • dim – the dimension to sort along. type = [int64].

  • descending – boolean, controls the sorting order (ascending or descending).

  • stable – a boolean pointer, selects a stable sorting algorithm to use, where stable sorting algorithms guarantee that the order of equal elements remains unchanged.

  • values[out] the sorted tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8].

  • indices – the index of corresponding element in the sorted tensor. type = [int32, int64].

DIOPI_API diopiError_t diopiTopk (diopiContextHandle_t ctx, diopiTensorHandle_t values, diopiTensorHandle_t indices, diopiConstTensorHandle_t input, int64_t k, int64_t dim, bool largest, bool sorted)

Returns the k largest elements of the given input tensor along a given dimension.

参数
  • ctx[in] Context environment.

  • input – the input tesnor.type=[float16, float32, float64, int16, int32, int64, uint8, int8]

  • k – the k in top-k. type = [int64].

  • dim – the dimension to sort along. type = [int64].

  • largest – boolean, whether to return the top k largest elements.

  • sorted – boolean, whether to return the top k elements in sorted order.

  • values[out] the top-k value tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8].

  • indices – the index of top-k value tensor. type = [int32, int64].

DIOPI_API diopiError_t diopiTranspose (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t dim0, int64_t dim1)

Returns a tensor that is a transposed version of input. The given dimensions dim0 and dim1 are swapped.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float16, float32, float64, int16, int64, uint8, int8, bool, int32].

  • dim0 – The first dimension to be transposed. type = [int32, int64].

  • dim1 – The second dimension to be transposed. type = [int32, int64].

  • out[out] the output tensor. type = [float16, float32, float64, int16, int64, uint8, int8, bool, int32].

DIOPI_API diopiError_t diopiOneHot (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t num_classes)

Returns a long tensor that has one more dimension with 1 values at the index of last dimension indicated by the input, and 0 everywhere else.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [int32, int64].

  • num_classes – The total number of categories. If set to -1, the total number of categories will be inferred as the maximum category value of the input tensor plus one. type = [int64].

  • out[out] the output tensor. type = [int32, int64].

DIOPI_API diopiError_t diopiWhere (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t condition, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Return a tensor of elements selected from either x or y, depending on condition.

参数
  • ctx[in] Context environment.

  • condition – A boolean tensor of the same shape as x and y. For elements/positions where the corresponding value is true, the value from x is returned, otherwise the value from y is returned. type = [uint8, bool].

  • input – the input tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8, bool]

  • other – the other tensor. type = [float16, float32, float64, int16, int32, int64, uint8, int8, bool]

  • out[out] the output tensor. type = [float16, float32, float64, int16,int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiMaskedFill (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t mask, diopiConstTensorHandle_t value)

Fills elements of self tensor with value where mask is True.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type=[float32, float64, float16].

  • mask – the boolean mask. type=[bool]

  • value – the value to fill in with. type=[float32, float64, float16]

  • out[out] the result tensor. type=[float32, float64, float16].

DIOPI_API diopiError_t diopiMaskedFillInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t mask, diopiConstTensorHandle_t value)

the in-place version of diopiMaskedFill.

参数
  • ctx[in] Context environment.

  • input – the input tensor, and will be stored result tensor, type=[float32, float64, float16].

  • mask – the boolean mask. type=[bool].

  • value – the value to fill in with. type=[float32, float64, float16].

DIOPI_API diopiError_t diopiMaskedFillScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t mask, const diopiScalar_t *value)

Fills elements of self tensor with scalar value where mask is True.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type=[float32, float64, float16].

  • mask – the boolean mask. type=[bool].

  • value – the value to fill in with, type=[float32, float64, float16].

  • out[out] the result tensor. type=[float32, float64, float16].

DIOPI_API diopiError_t diopiMaskedFillInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t mask, const diopiScalar_t *value)

the in-place version of diopiMaskedFillScalar.

参数
  • ctx[in] Context environment.

  • input – the input tensor, and will be stored result tensor.

  • mask – the boolean mask. type=[bool].

  • value – the value to fill in with, type=[float32, float64, float16].

DIOPI_API diopiError_t diopiReciprocal (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Computes the reciprocal of the elements of input.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type=[float16, float32, float64].

  • out[out] the result tensor. type=[float16, float32, float64].

DIOPI_API diopiError_t diopiReciprocalInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)

the in-place version of reciprocal.

参数
  • ctx[in] Context environment.

  • input – the result tensor, and will be stored result tensor. type=[float16, float32, float64].

DIOPI_API diopiError_t diopiAdamW (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiTensorHandle_t grad, diopiTensorHandle_t exp_avg, diopiTensorHandle_t exp_avg_sq, diopiTensorHandle_t max_exp_avg_sq, float lr, float beta1, float beta2, float eps, float weight_decay, int64_t step, bool amsgrad)

Implements AdamW optimizer.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type=[float16, float32, float64].

  • grad – the grad tensor. type=[float16, float32, float64].

  • exp_avg – the first momentum is related to the number of iterations, that is, the gradient mean value of the i th iteration. type=[float16, float32, float64].

  • exp_avg_sq – the second momentum is related to the number of iterations, that is, the mean value of the gradient square of the i iteration. type=[float16, float32, float64].

  • max_exp_avg_sq – the maximum second momentum. When the parameter ‘amsgrad’ is true, it will replace the second momentum to participate in the calculation. type=[float16, float32, float64].

  • lr – learning rate.

  • beta1 – coefficients used for computing running averages of gradient.

  • beta2 – square of coefficients.

  • eps – term added to the denominator to improve numerical stability.

  • weight_decay – weight decay coefficient.

  • step – step. type = [int64].

  • amsgrad – whether to use the AMSGrad variant of this algorithm from the paper On the Convergence of Adam and Beyond_.

DIOPI_API diopiError_t diopiConvTranspose2d (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight, diopiConstTensorHandle_t bias, diopiSize_t stride, diopiSize_t padding, diopiSize_t output_padding, int64_t groups, diopiSize_t dilation)

Applies a 2D transposed convolution operator over an input image composed of several input planes, sometimes also called “deconvolution”.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float32, float16, float64].

  • weight – the weight tensor; dimension of kernel_size must match the number of input spatial dimensions. type = [float32, float16, float64].

  • bias – bias tensor. type = [float32, float16, float64].

  • stride – an array with dimension matching the number of input spatial dimensions. type = [int32, int64].

  • padding – an array with dimension matching the number of input spatial dimensions. type = [int32, int64].

  • output_padding – an array, dimension == number of input spatial dimensions; only supported when transposed is true. type = [int32, int64].

  • dilation – an array with dimension matching the number of input spatial dimensions. type = [int32, int64].

  • groups – number of groups for grouped convolution. type = [int64].

  • out[out] the result tensor. type = [float32, float16, float64].

DIOPI_API diopiError_t diopiConvTranspose2dBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiTensorHandle_t grad_weight, diopiTensorHandle_t grad_bias, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight, diopiSize_t *bias_sizes, diopiSize_t stride, diopiSize_t padding, diopiSize_t dilation, diopiSize_t output_padding, int64_t groups)

Backward pass for ConvTranspose2dBackward. Computes gradients for input, weight, and bias.

参数
  • grad_output[in] the grad tensor of output. type = [float32, float16, float64].

  • bias_sizes – an array, indicates that a bias was used in the forward pass and contains the shape of the bias. type = [int32, int64].

  • output_padding – an array, dimension == number of input spatial dimensions; only supported when transposed is true. type = [int32, int64].

  • grad_input[out] the grad of input. type = [float32, float16, float64].

  • grad_weight – the grad of weight. type = [float32, float16, float64].

  • grad_bias – the grad of bias. type = [float32, float16, float64].

  • input – the input tensor. type = [float32, float16, float64].

  • weight – the weight tensor; dimension of kernel_size must match the number of input spatial dimensions.

  • stride – an array with dimension matching the number of input spatial dimensions. type = [int32, int64].

  • padding – an array with dimension matching the number of input spatial dimensions. type = [int32, int64].

  • output_padding – an array, dimension == number of input spatial dimensions; only supported when transposed is true. type = [int32, int64].

  • dilation – an array with dimension matching the number of input spatial dimensions. type = [int32, int64].

  • groups – number of groups for grouped convolution. type = [int64].

DIOPI_API diopiError_t diopiUnfold (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t dim, int64_t size, int64_t step)

Extracts sliding local blocks from a batched input tensor.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64, float16].

  • dim – dimension in which unfolding happens. type = [int64].

  • size – the size of each slice that is unfolded. type = [int64].

  • step – the step between each slice. type = [int64].

  • out[out] the output tensor. type=[float16, float32, float64].

DIOPI_API diopiError_t diopiUnfoldBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiSize_t input_sizes, int64_t dim, int64_t size, int64_t step)

Backward pass for diopiUnfold.

参数
  • grad_output[in] the grad tensor of output, with the same shape as the forward pass output. type=[float16, float32, float64].

  • input_sizes – an array, the size of grad_input.

  • dim – dimension in which unfolding happens. type = [int64].

  • size – the size of each slice that is unfolded. type = [int64].

  • step – the step between each slice. type = [int64].

  • grad_input[out] the grad tensor of input, with the same shape as the forward pass input. type=[float16, float32, float64].

DIOPI_API diopiError_t diopiCumsum (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t dim)

Returns the cumulative sum of elements of input in the dimension dim.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type=[float32, float64, float16, int16, int32, int64, uint8, int8, bool].

  • dim – the dimension to do the operation over. type = [int64].

  • out[out] the output tensor. type=[float32, float64, float16, int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiCdist (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input1, diopiConstTensorHandle_t input2, double p, const int64_t *compute_mode)

Computes batched the p-norm distance between each pair of the two collections of row vectors.

参数
  • ctx[in] Context environment.

  • input1 – input tensor of shape B * P * M. type=[float32, float64].

  • input2 – input tensor of shape B * R * M. type=[float32, float64].

  • p – double p value for the p-norm distance to calculate between each vector pair.

  • compute_mode – int64_t* the mode of compute.

  • out[out] the output tensor. type=[float32, float64].

DIOPI_API diopiError_t diopiCdistBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input1, diopiConstTensorHandle_t input2, double p, diopiConstTensorHandle_t cdist)

Backward pass for cdist.

参数
  • grad_output[in] the grad tensor of output, with the same shape as the forward pass output. type=[float32, float64].

  • input1 – input tensor. type=[float32, float64].

  • input2 – input tensor. type=[float32, float64].

  • p – double p value for the p-norm distance to calculate between each vector pair.

  • cdist – input tensor. type=[float32, float64].

  • grad_input[out] the grad tensor of input, with the same shape as the forward pass input. type=[float32, float64].

DIOPI_API diopiError_t diopiArgmax (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const int64_t *dim, bool keepdim)

Returns the indices of the maximum values of a tensor across a dimension.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type=[float32, float64, float16, int16, int32, int64, uint8, int8, bool].

  • dim – the dimension to do the operation over. type=[int32, int64].

  • keepdim – whether the output tensor has dim retained or not.

  • out[out] the output tensor. type=[int32, int64].

DIOPI_API diopiError_t diopiAdadelta (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiTensorHandle_t grad, diopiTensorHandle_t square_avg, diopiTensorHandle_t acc_delta, float lr, float rho, float eps, float weight_decay)

Implements Adadelta algorithm.

DIOPI_API diopiError_t diopiAdam (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiTensorHandle_t grad, diopiTensorHandle_t exp_avg, diopiTensorHandle_t exp_avg_sq, diopiTensorHandle_t max_exp_avg_sq, float lr, float beta1, float beta2, float eps, float weight_decay, int64_t step, bool amsgrad)

Implements Adam optimizer.

DIOPI_API diopiError_t diopiRmsprop (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiTensorHandle_t grad, diopiTensorHandle_t square_avg, diopiTensorHandle_t grad_avg, diopiTensorHandle_t momentum_buf, float lr, float alpha, float eps, float weight_decay, float momentum, bool centered)

Implements Rmsprop optimizer.

DIOPI_API diopiError_t diopiSmoothL1Loss (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t target, diopiReduction_t reduction, double beta)

Creates a criterion that uses a squared term if the absolute element-wise error falls below beta and an L1 term otherwise.

DIOPI_API diopiError_t diopiSmoothL1LossBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t target, diopiReduction_t reduction, double beta)
DIOPI_API diopiError_t diopiConvolution3d (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight, diopiConstTensorHandle_t bias, diopiSize_t stride, diopiSize_t padding, diopiSize_t dilation, int64_t groups)

Applies a 3D convolution over an input image composed of several input planes.

DIOPI_API diopiError_t diopiConvolution3dBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiTensorHandle_t grad_weight, diopiTensorHandle_t grad_bias, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight, diopiSize_t *bias_sizes, diopiSize_t stride, diopiSize_t padding, diopiSize_t dilation, bool transposed, diopiSize_t output_padding, int64_t groups)
DIOPI_API diopiError_t diopiMaxPool3d (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t kernel_size, diopiSize_t stride, diopiSize_t padding, diopiSize_t dilation, bool ceil_mode)

Applies a 3D max pooling over an input signal composed of several input planes.

DIOPI_API diopiError_t diopiMaxPool3dWithIndices (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiTensorHandle_t indices, diopiConstTensorHandle_t input, diopiSize_t kernel_size, diopiSize_t stride, diopiSize_t padding, diopiSize_t dilation, bool ceil_mode)
DIOPI_API diopiError_t diopiMaxPool3dBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiSize_t kernel_size, diopiSize_t stride, diopiSize_t padding, diopiSize_t dilation, bool ceil_mode, diopiConstTensorHandle_t indices)
DIOPI_API diopiError_t diopiAdaptiveAvgPool3d (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t output_size)

Applies a 3D adaptive average pooling over an input signal composed of several input planes.

DIOPI_API diopiError_t diopiAdaptiveAvgPool3dBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input)
DIOPI_API diopiError_t diopiAdaptiveMaxPool3d (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t output_size)

Applies a 3D adaptive max pooling over an input signal composed of several input planes.

DIOPI_API diopiError_t diopiAdaptiveMaxPool3dWithIndices (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiTensorHandle_t indices, diopiConstTensorHandle_t input, diopiSize_t output_size)
DIOPI_API diopiError_t diopiAdaptiveMaxPool3dBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t indices)
DIOPI_API diopiError_t diopiMaskedSelect (diopiContextHandle_t ctx, diopiTensorHandle_t *out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t mask)

Returns a new 1-D tensor which indexes the input tensor according to the boolean mask.

DIOPI_API diopiError_t diopiMaskedSelectBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t mask)
DIOPI_API diopiError_t diopiMaximum (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Element-wise math functions.

DIOPI_API diopiError_t diopiMinimum (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)
DIOPI_API diopiError_t diopiMm (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t mat2)
DIOPI_API diopiError_t diopiIndexFillScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t dim, diopiConstTensorHandle_t index, const diopiScalar_t *value)

Fills the elements of the input tensor with value by selecting the indices in the order given in index.

DIOPI_API diopiError_t diopiIndexFill (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t dim, diopiConstTensorHandle_t index, diopiConstTensorHandle_t value)
DIOPI_API diopiError_t diopiIndexFillInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, int64_t dim, diopiConstTensorHandle_t index, const diopiScalar_t *value)
DIOPI_API diopiError_t diopiIndexFillInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, int64_t dim, diopiConstTensorHandle_t index, diopiConstTensorHandle_t value)
DIOPI_API diopiError_t diopiExpand (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Expand tensor to the same size as out.

参数
  • ctx[in] Context environment.

  • input[in] the input tensor, type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool]

  • out[out] the output tensor. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool]

DIOPI_API diopiError_t diopiLinspace (diopiContextHandle_t ctx, diopiTensorHandle_t out, const diopiScalar_t *start, const diopiScalar_t *end, int64_t steps)

Creates a one-dimensional tensor of size steps whose values are evenly spaced from start to end, inclusive.

参数
  • ctx[in] Context environment.

  • start – the starting value for the set of points. type = [float32, float64, float16, int16, int32, int64]

  • end – the ending value for the set of points. type = [float32, float64, float16, int16, int32, int64]

  • steps – the number of steps to take from start to end. type = [int64].

  • out[out] the output tensor. type = [float32, float64, float16, int16, int32, int64]

DIOPI_API diopiError_t diopiPermute (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t dims)

Returns a new tensor with its dimensions permuted.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool]

  • dims – an array, position order of tensor dimensions during permutation. type = [int32, int64].

  • out[out] the output tensor. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiPad (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t pad, const char *mode, const double *value)

Pads tensor.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type=[float32, float64, float16].

  • pad – m-elements tuple.

  • mode – ‘constant’, ‘reflect’, ‘replicate’ or ‘circular’.

  • value – value fill value for ‘constant’ padding.

  • out[out] the output tensor. type=[float32, float64, float16].

DIOPI_API diopiError_t diopiRoll (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t shifts, diopiSize_t dims)

Roll the tensor along the given dimension(s).

参数
  • ctx[in] Context environment.

  • input – the input tensor. type=[float32, float64, float16, bool, int64, int32, int16, int8, uint8, bool].

  • shifts – The number of places by which the elements of the tensor are shifted.

  • dims – Axis along which to roll.

  • out[out] the output tensor. ype=[float32, float64, float16, bool, int64, int32, int16, int8, uint8, bool].

DIOPI_API diopiError_t diopiFlip (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t dims)

Reverse the order of a n-D tensor along given axis in dims.

DIOPI_API diopiError_t diopiNorm (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *p, diopiSize_t dim)

Returns the matrix norm or vector norm of a given tensor.

参数
  • ctx[in] Context environment.

  • input – the input tesnor, type=[float32, float64, float16].

  • p – an array, the order of norm.

  • dim – Specifies which dimension or dimensions of input to calculate the norm across.

  • out[out] the output tensor. type=[float32, float64, float16].

DIOPI_API diopiError_t diopiGroupNorm (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiTensorHandle_t save_mean, diopiTensorHandle_t save_invstd, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight, diopiConstTensorHandle_t bias, int64_t num_groups, double eps)

Applies Group Normalization over a mini-batch of inputs.

DIOPI_API diopiError_t diopiGroupNormBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiTensorHandle_t grad_weight, diopiTensorHandle_t grad_bias, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight, diopiConstTensorHandle_t mean, diopiConstTensorHandle_t rstd, int64_t num_groups)
DIOPI_API diopiError_t diopiUnique (diopiContextHandle_t ctx, diopiTensorHandle_t *out, diopiConstTensorHandle_t input, const int64_t *dim, bool sorted, bool return_counts, diopiTensorHandle_t indices, diopiTensorHandle_t *counts)

Returns the unique elements of the input tensor.

参数
  • ctx[in] Context environment.

  • input – the input tensor,type = [int64, float32, float64, float16, int16, int32, uint8, int8, bool]

  • dim – Specifies the dimension along which the duplicates are removed. It can be None, which means removing duplicates from the entire input tensor.

  • sorted – boolean, whether to sort the result in ascending order.

  • return_counts – boolean, whether to return the count tensor

  • out[out] the output tensor. type = [int64, float32, float64, float16, int16, int32, uint8, int8, bool].

  • indices – if none, return new indices of each element in the output tensor. type = [int32, int64].

  • counts – representing the count of occurrences of each element in the output tensor. type = [int32, int64].

DIOPI_API diopiError_t diopiProd (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const int64_t *dim)

Returns the product of all elements in the input tensor.

DIOPI_API diopiError_t diopiCTCLoss (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiTensorHandle_t neg_log_likelihood, diopiTensorHandle_t log_alpha, diopiConstTensorHandle_t log_probs, diopiConstTensorHandle_t targets, diopiConstTensorHandle_t input_lengths, diopiConstTensorHandle_t target_lengths, int64_t blank, diopiReduction_t reduction, bool zero_infinity)

Computes the Connectionist Temporal Classification loss.

DIOPI_API diopiError_t diopiCTCLossBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t log_probs, diopiConstTensorHandle_t targets, diopiConstTensorHandle_t input_lengths, diopiConstTensorHandle_t target_lengths, diopiConstTensorHandle_t neg_log_likelihood, diopiConstTensorHandle_t log_alpha, int64_t blank, diopiReduction_t reduction, bool zero_infinity)
DIOPI_API diopiError_t diopiLerpTensor (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t end, diopiConstTensorHandle_t weight)
DIOPI_API diopiError_t diopiLerpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t end, const diopiScalar_t *weight)
DIOPI_API diopiError_t diopiRemainderTensor (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t other)

Applies modulus operation.

DIOPI_API diopiError_t diopiRemainderScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, const diopiScalar_t *other)
DIOPI_API diopiError_t diopiRemainder (diopiContextHandle_t ctx, diopiTensorHandle_t out, const diopiScalar_t *input, diopiConstTensorHandle_t other)
DIOPI_API diopiError_t diopiGather (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t dim, diopiConstTensorHandle_t index)

Gathers values along an axis specified by dim.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

  • dim – the axis along which to index. type = [int64].

  • index – the indices of elements to gather. type = [int32, int64].

  • out[out] the output tensor. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiGatherBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, int64_t dim, diopiConstTensorHandle_t index)

compute the backward pass of diopiGather().

参见

other parameters refer to diopiGather().

参数
  • ctx[in] Context environment.

  • grad_output – the gradient w.r.t. the output of gather. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

  • grad_input[out] the gradient w.r.t. the input of gather. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiScatterInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, int64_t dim, diopiConstTensorHandle_t src, diopiConstTensorHandle_t index, const char *reduce)

the in-place version of diopiScatter().

参见

other parameters refer to diopiScatter().

参数
  • ctx[in] Context environment.

  • input – the input and output tensor. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiScatterInpScalar (diopiContextHandle_t ctx, diopiTensorHandle_t input, int64_t dim, const diopiScalar_t *value, diopiConstTensorHandle_t index, const char *reduce)

the in-place version of diopiScatterScalar().

参见

other parameters refer to diopiScatterScalar().

参数

input[in] the input and output tensor. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiScatter (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t dim, diopiConstTensorHandle_t src, diopiConstTensorHandle_t index, const char *reduce)

Writes all values from the tensor src into input at the indices specified in the index tensor.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

  • dim – the axis along which to index. type = [int64].

  • src – the source tensor. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

  • index – the indices of elements to scatter. type = [int32, int64].

  • reduce – the reduce operation. type = [string].

  • out[out] the output tensor. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiScatterScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t dim, const diopiScalar_t *value, diopiConstTensorHandle_t index, const char *reduce)

Writes all values from the tensor value into input at the indices specified in the index tensor.

参见

other parameters refer to diopiScatter().

参数

value[in] the value to write into input at the indices. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiIndexPutInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t values, diopiConstTensorHandle_t *indices, int64_t indices_counts, bool accumulate)

the in-place version of diopiIndexPut().

参见

other parameters refer to diopiIndexPut().

参数

input[in] the input and output tensor. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiIndexPut (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t values, diopiConstTensorHandle_t *indices, int64_t indices_counts, bool accumulate)

Puts values from the tensor values into the tensor input using the indices specified in indices.

参数
  • ctx[in] Context environment.

  • input – the input tensor. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

  • values – the tensor containing the values to copy into input. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

  • indices – the indices into input. type = [int32, int64].

  • indices_counts – the number of indices. type = [int64].

  • accumulate – whether to accumulate into input (if true) or perform a copy (if false).

  • out[out] the output tensor. type = [float32, float64, float16, int16, int32, int64, uint8, int8, bool].

DIOPI_API diopiError_t diopiRandomInp (diopiContextHandle_t ctx, diopiTensorHandle_t inout, int64_t from, const int64_t *to, int64_t idx)

Distribution and random numbers.

参数
  • ctx[in] Context environment.

  • inout – the input and output tensor, type = [float32, float64, float16, int64, int32, int16, int8]

  • from – the lower bound of the random function. type = [int64].

  • to – a pointer, the upper bound of the random function, it can be none.

  • idx – idx

DIOPI_API diopiError_t diopiUniformInp (diopiContextHandle_t ctx, diopiTensorHandle_t inout, double from, double to, int64_t idx)
DIOPI_API diopiError_t diopiBernoulli (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t idx)
DIOPI_API diopiError_t diopiBernoulliInp (diopiContextHandle_t ctx, diopiTensorHandle_t inout, int64_t idx)
DIOPI_API diopiError_t diopiBernoulliScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, double p, int64_t idx)
DIOPI_API diopiError_t diopiArange (diopiContextHandle_t ctx, diopiTensorHandle_t out, const diopiScalar_t *start, const diopiScalar_t *end, const diopiScalar_t *step)

Returns a one-dimensional tensor that starts from start, increments by step, and ends at end.

参数
  • ctx[in] Context environment.

  • start – an array, starting value of the resulting tensor. type = [float32, float64].

  • end – an array, upper bound of the resulting tensor (exclusive). type = [float32, float64].

  • step – an array, difference between adjacent elements of the resulting tensor. type = [float32, float64].

  • out[out] the output tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiRandperm (diopiContextHandle_t ctx, diopiTensorHandle_t out, int64_t n, int64_t idx)

Randomly generate an integer between 0 and n-1.

参数
  • ctx[in] Context environment.

  • n – the upper bound(excluding), type = [int64].

  • idx

  • out[out] the output tensor. type = [int32, int64].

DIOPI_API diopiError_t diopiNormal (diopiContextHandle_t ctx, diopiTensorHandle_t out, double mean, double std)
DIOPI_API diopiError_t diopiNormalTensorScalar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t mean, double std)
DIOPI_API diopiError_t diopiNormalScalarTensor (diopiContextHandle_t ctx, diopiTensorHandle_t out, double mean, diopiConstTensorHandle_t std)
DIOPI_API diopiError_t diopiNormalTensor (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t mean, diopiConstTensorHandle_t std)
DIOPI_API diopiError_t diopiNormalInp (diopiContextHandle_t ctx, diopiTensorHandle_t inout, double mean, double std)
DIOPI_API diopiError_t diopiMeshGrid (diopiContextHandle_t ctx, diopiTensorHandle_t *outs, diopiConstTensorHandle_t *inputs, int64_t inputsNum)
DIOPI_API diopiError_t diopiMultinomial (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t num_samples, bool replacement)
DIOPI_API diopiError_t diopiLayerNorm (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiTensorHandle_t save_mean, diopiTensorHandle_t save_invstd, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight, diopiConstTensorHandle_t bias, diopiSize_t normalized_shape, double eps)

Applies Layer Normalization over a mini-batch of inputs. type=[float32, float64, float16].

参数
  • ctx[in] Context environment.

  • save_mean – Mean tensor,the mean value for each feature channel of the input tensor. type=[float32, float64, float16].

  • save_invstd – Backup of inverse standard deviation computed during training. type=[float32, float64, float16].

  • input – input tensor. type=[float32, float64, float16].

  • weight – weight tensor. type=[float32, float64, float16].

  • bias – bias tensor. type=[float32, float64, float16].

  • normalized_shape – an array, input shape from an expected input of size.

  • eps – float64 a value added to the denominator for numerical stability.

  • out[out] normalized result. type=[float32, float64, float16].

DIOPI_API diopiError_t diopiLayerNormBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiTensorHandle_t grad_weight, diopiTensorHandle_t grad_bias, diopiConstTensorHandle_t grad_output, diopiConstTensorHandle_t input, diopiConstTensorHandle_t weight, diopiConstTensorHandle_t bias, diopiConstTensorHandle_t mean, diopiConstTensorHandle_t rstd, diopiSize_t normalized_shape)

Backward pass for diopiLayerNorm. Computes gradients for input, weight, and bias. type=[float32, float64, float16].

参数
  • grad_output[in] the grad tensor of output. type=[float32, float64, float16].

  • grad_bias – the grad of bias. type=[float32, float64, float16].

  • grad_weight – the grad of weight. type=[float32, float64, float16].

  • mean – Mean tensor,the mean value for each feature channel of the input tensor. type=[float32, float64, float16].

  • rstd – Backup of inverse standard deviation computed during training. type=[float32, float64, float16].

  • input – input tensor. type=[float32, float64, float16].

  • weight – weight tensor. type=[float32, float64, float16].

  • bias – bias tensor. type=[float32, float64, float16].

  • normalized_shape – an array, input shape from an expected input of size.

  • grad_input[out] the grad of input. type=[float32, float64, float16].

DIOPI_API diopiError_t diopiCopyInp (diopiContextHandle_t ctx, diopiConstTensorHandle_t src, diopiTensorHandle_t dest)

Copies the elements from src into dest tensor.

参数
  • ctx[in] Context environment.

  • src – the source tensor.type = [float32, float64, float16, bool, int64, int32, int16, int8, uint8].

  • dest[out] the destination tensor.type = [float32, float64, float16, bool, int64, int32, int16, int8, uint8].

DIOPI_API diopiError_t diopiUpsampleNearest (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t size)

Upsamples a given multi-channel 1D (temporal), 2D (spatial) or 3D (volumetric) data.

DIOPI_API diopiError_t diopiUpsampleNearestBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiSize_t out_size, diopiSize_t in_size)
DIOPI_API diopiError_t diopiUpsampleLinear (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t size, bool align_corners, const char *mode)
DIOPI_API diopiError_t diopiUpsampleLinearBackward (diopiContextHandle_t ctx, diopiTensorHandle_t grad_input, diopiConstTensorHandle_t grad_output, diopiSize_t out_size, diopiSize_t in_size, bool align_corners, const char *mode)
DIOPI_API diopiError_t diopiErfinv (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Computes the inverse error function of input tensor.

DIOPI_API diopiError_t diopiErfinvInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)
DIOPI_API diopiError_t diopiIm2Col (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t kernel_size, diopiSize_t dilation, diopiSize_t padding, diopiSize_t stride)

Extracts sliding local blocks from a batched input tensor.

DIOPI_API diopiError_t diopiCol2Im (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t output_size, diopiSize_t kernel_size, diopiSize_t dilation, diopiSize_t padding, diopiSize_t stride)

Combines an array of sliding local blocks into a large containing tensor.

DIOPI_API diopiError_t diopiRepeat (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiSize_t repeats_size)

Repeats tensor input along the specified dimensions.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64].

  • repeats_size – an integer array containing the number of repetitions needed on each dimension. type = [int32, int64].

  • out[out] the output tensor. type = [float32, float64].

DIOPI_API diopiError_t diopiCastDtype (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)
DIOPI_API diopiError_t diopiPolar (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t abs, diopiConstTensorHandle_t angle)
DIOPI_API diopiError_t diopiTriu (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, int64_t diagonal)
DIOPI_API diopiError_t diopiTriuInp (diopiContextHandle_t ctx, diopiTensorHandle_t input, int64_t diagonal)
DIOPI_API diopiError_t diopiSgn (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)
DIOPI_API diopiError_t diopiSgnInp (diopiContextHandle_t ctx, diopiTensorHandle_t input)
DIOPI_API diopiError_t diopiIsNan (diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input)

Returns a new tensor with boolean elements representing if each element of input is NaN or not. Complex values are considered NaN when either their real and/or imaginary part is NaN.

参数
  • ctx[in] Context environment.

  • input – the input tensor, type = [float32, float64, float16, bool, int64, int32, int16, int8, uint8].

  • out[out] the output tensor. type = [bool].

struct diopiScalar_t

Public Functions

inline diopiDtype_t type()
inline double val()

Public Members

diopiDtype_t stype
double fval
int64_t ival
union diopiScalar_t::[anonymous] [anonymous]

© Copyright 2025, DeepLink.