aclnnSwigluBackwardMxQuantWithDualAxis

📄 View Source Code

Applicable Products

  • Ascend 950PR&950DT products: Supported
  • Atlas A3 products: Not supported
  • Atlas A2 products: Not supported
  • Atlas 200I/500 A2 inference products: Not supported
  • Atlas inference products: Not supported
  • Atlas training products: Not supported

Function

  • Description: A fused operator that implements the combined computation of SwiGLU activation function backward gradient calculation and dual-axis dynamic block quantization. First, the SwiGLU backward gradient is computed based on the input x and gradient yGrad. Then, block-based dynamic quantization is performed on the gradient result along the -1 axis and -2 axis respectively, outputting low-precision FP8 tensors and the corresponding scaling factors.

  • Formula:

    Stage 1: SwiGLU backward gradient calculation

    • When activateLeft=true:
    Ai=xi first half,Bi=xi second halfA_i = x_i \text{ first half}, B_i = x_i \text{ second half}
    • When activateLeft=false:
    Ai=xi second half,Bi=xi first halfA_i = x_i \text{ second half}, B_i = x_i \text{ first half}
    • SwiGLU forward computation:
    swigluOuti=Swish(Ai)∗Bi=Ai1+e−Ai∗BiswigluOut_i = Swish(A_i) * B_i = \frac{A_i}{1 + e^{-A_i}} * B_i
    • SwiGLU backward computation:
    grad_A=yGrad∗B∗sigmoid(A)∗(1+A−(A∗sigmoid(A)))grad_B=yGrad∗A∗sigmoid(A)grad_x=concat(grad_A,grad_B)grad\_A = yGrad * B * sigmoid(A) * (1 + A - (A * sigmoid(A))) \\ grad\_B = yGrad * A * sigmoid(A) \\ grad\_x = concat(grad\_A, grad\_B)

    Stage 2: dual-axis dynamic block quantization

  • -1-axis quantization (column direction): The SwiGLU output is grouped along the -1 axis into groups of 32 values. Each group of 32 values {Vi}i=132\{V_i\}_{i=1}^{32} is quantized to {mxscale1,{Pi}i=132}\{mxscale1, \{P_i\}_{i=1}^{32}\}

    shared_exp=floor(log2(maxi(∣Vi∣)))−emaxshared\_exp = floor(log_2(max_i(|V_i|))) - emax mxscale1=2shared_expmxscale1 = 2^{shared\_exp} Pi=cast_to_dst_type(Vi/mxscale1,round_mode), i from 1 to 32P_i = cast\_to\_dst\_type(V_i/mxscale1, round\_mode), \space i\space from\space 1\space to\space 32
  • -2-axis quantization (row direction): The SwiGLU result is grouped along the -2 axis into groups of 32 numbers, and each group of 32 numbers {Vj}j=132\{V_j\}_{j=1}^{32} is quantized to {mxscale2,{Pj}j=132}\{mxscale2, \{P_j\}_{j=1}^{32}\}

    shared_exp=floor(log2(maxj(∣Vj∣)))−emaxshared\_exp = floor(log_2(max_j(|V_j|))) - emax mxscale2=2shared_expmxscale2 = 2^{shared\_exp} Pj=cast_to_dst_type(Vj/mxscale2,round_mode), j from 1 to 32P_j = cast\_to\_dst\_type(V_j/mxscale2, round\_mode), \space j\space from\space 1\space to\space 32
  • PiP_{i} obtained after -1-axis quantization forms the output y1Out according to the positions of the corresponding ViV_{i}, and mxscale1 forms the output mxscale1Out according to the groups along the -1-axis dimension. PjP_{j} obtained after -2-axis quantization forms the output y2Out according to the positions of the corresponding VjV_{j}, and mxscale2 forms the output mxscale2Out according to the groups along the -2-axis dimension.

  • emax: The exponent of the maximum normal number of the corresponding data type.

DataTypeEmax
FLOAT4_E2M12
FLOAT4_E1M20
FLOAT8_E4M3FN8
FLOAT8_E5M215

Function Prototype

Each operator uses a two-phase API. Call "aclnnSwigluBackwardMxQuantWithDualAxisGetWorkspaceSize" to obtain the workspace size required for the computation and the executor containing the operator computation process, and then call "aclnnSwigluBackwardMxQuantWithDualAxis" to execute the computation.

aclnnStatus aclnnSwigluBackwardMxQuantWithDualAxisGetWorkspaceSize(
  const aclTensor *x,
  const aclTensor *yGrad,
  const aclTensor *groupIndexOptional,
  bool             activateLeft,
  char            *roundModeOptional,
  int64_t          scaleAlg,
  int64_t          dstDtype,
  double           maxDtypeValue,
  const aclTensor *y1Out,
  const aclTensor *mxscale1Out,
  const aclTensor *y2Out,
  const aclTensor *mxscale2Out,
  uint64_t        *workspaceSize,
  aclOpExecutor   **executor)
aclnnStatus aclnnSwigluBackwardMxQuantWithDualAxis(
  void          *workspace,
  uint64_t       workspaceSize,
  aclOpExecutor *executor,
  aclrtStream    stream)

aclnnSwigluBackwardMxQuantWithDualAxisGetWorkspaceSize

  • Parameters:

    Parameter Input/Output Description Instruction Data Type Data Format Dimension (shape) Non-contiguous Tensor
    x (aclTensor*) Input Input tensor, x in the formula.
    • shape is [M, 2N], and the last dimension must be divisible by 64.
    • Empty tensors are not supported.
    FLOAT16, BFLOAT16 ND 2-6 √
    yGrad (aclTensor*) Input Backward gradient input, shape is [M, N], indicating the gradient of the forward SwiGLU output.
    • shape is [M, N], where N = last dimension of x / 2.
    • The data type must be the same as that of x.
    • Empty tensors are not supported.
    FLOAT16, BFLOAT16 ND 2-6 √
    groupIndexOptional (aclTensor*) Optional input Group index, used to control the boundaries of group quantization.
    • shape is [G], in cumsum mode, indicating the cumulative number of rows per group. Passing a null pointer indicates no grouping.
    • Passing an empty tensor is currently not supported.
    INT64 ND 1 √
    activateLeft (bool) Input SwiGLU activation side selection.
    • True indicates the left half is hidden and the right half is gate.
    • False indicates the right half is hidden and the left half is gate.
    BOOL - - -
    roundModeOptional (char*) Input Indicates the data conversion mode, corresponding to round_mode in the formula.
    • Only supported when dstDtype is 36, which corresponds to the data type FLOAT8_E4M3FN of outputs y1Out and y2Out. Only {"rint"} is supported.
    • If a null pointer is passed in, the "rint" mode is used.
    STRING - - -
    scaleAlg (int64_t) Input Indicates the computation method of mxscale1Out and mxscale2Out.
    • Value range: {1}, indicating the cuBLAS implementation.
    INT64 - - -
    dstDtype (int64_t) Input Indicates the data type of y1Out and y2Out after the specified data conversion.
    • The input range is {36}, corresponding to the data types of outputs y1Out and y2Out respectively, which are {36: FLOAT8_E4M3FN}.
    INT64 - - -
    maxDtypeValue (double) Input Reserved parameter.
    • Only the value 0 is supported for maxDtypeValue.
    DOUBLE - - -
    y1Out (aclTensor*) Output Indicates the corresponding result after quantizing the SwiGLU result along axis -1, which is Pi in the corresponding formula.
    • shape: [M, 2N].
    FLOAT8_E4M3FN ND 2-6 √
    mxscale1Out (aclTensor*) Output Indicates the quantization scale corresponding to each group along the -1 axis, which is mxscale1 in the corresponding formula.
    • The shape is [M, (ceil(2N/32) + 1) / 2, 2]. Even padding is required, and the padding value is 0.
    FLOAT8_E8M0 ND 3-7 √
    y2Out (aclTensor*) Output Indicates the SwiGLU result quantized along axis -2, corresponding to Pj in the formula.
    • The shape is [M, 2N].
    FLOAT8_E4M3FN ND 2-6 √
    mxscale2Out (aclTensor*) Output Indicates the quantization scale corresponding to each group along axis -2, corresponding to mxscale2 in the formula.
    • When groupIndexOptional exists, the shape is [floor(M/64)+G, N, 2].
    • Even padding is required, with the pad value set to 0.
    • The mxscale2Out output requires interleaving of every two rows of data.
    FLOAT8_E8M0 ND 3-7 √
    workspaceSize (uint64_t*) Output Returns the size of the workspace to be allocated on the Device. - - - - -
    executor (aclOpExecutor**) Output Returns the op executor, which contains the operator computation flow. - - - - -
  • Return value

    aclnnStatus: return status code. For details, see aclnn Error Codes.

    The first-phase API performs input parameter validation and returns an error in the following scenarios:

    Error Code Error Code Description
    ACLNN_ERR_PARAM_NULLPTR 161001 x, yGrad, y1Out, mxscale1Out, y2Out, or mxscale2Out is a null pointer.
    ACLNN_ERR_PARAM_INVALID 161002 The data type and data format of x, roundModeOptional, dstDtype, scaleAlg, y1Out, mxscale1Out, y2Out, or mxscale2Out are not within the supported range.
    The shape of x, y1Out, y2Out, mxscale1Out, or mxscale2Out does not meet the verification conditions.
    roundModeOptional, dstDtype, or scaleAlg does not match any currently supported value.
    ACLNN_ERR_RUNTIME_ERROR 361001 The current platform is not within the supported platform range.

aclnnSwigluBackwardMxQuantWithDualAxis

  • Parameters:

    Parameter Input/Output Description
    workspace Input Workspace memory address allocated on the Device.
    workspaceSize Input Size of the workspace allocated on the Device, obtained by calling the first-phase API aclnnSwigluBackwardMxQuantWithDualAxisGetWorkspaceSize.
    executor Input Op executor that contains the operator computation flow.
    stream Input Specifies the stream that executes the task.
  • Return value

    aclnnStatus: return status code. For details, see aclnn Error Codes.

Constraints

  • The last dimension of input x must be divisible by 64.
  • FP8 output type (FLOAT8_E4M3FN) supports only the "rint" rounding mode.
  • groupIndexOptional adopts the cumsum mode, where each value indicates the cumulative row count of the corresponding group. Each element of groupIndexOptional must be greater than 0, and the last element must be equal to M.
  • Shape constraints for mxscale1Out and mxscale2Out:
    • mxscale1Out.shape[-2] = (ceil(2N/32) + 1) / 2.
    • mxscale1Out.shape[-1] = 2.
    • mxscale2Out.shape[-1] = 2.
    • If groupIndexOptional is specified, mxscale2Out.shape[0] = floor(M/64) + G; otherwise, mxscale2Out.shape[0] = ceil(M/64).
    • Other dimensions are the same as those of the SwiGLU output.
  • Saturation mode is supported by default.
  • Deterministic computation: aclnnSwigluBackwardMxQuantWithDualAxis defaults to a deterministic implementation.

Example

The following sample code is for reference only. For details about compilation and execution, see Compile and Run Samples.

#include <iostream>
#include <memory>
#include <vector>
#include "acl/acl.h"
#include "aclnnop/aclnn_swiglu_backward_mx_quant_with_dual_axis.h"

#define CHECK_RET(cond, return_expr) \
    do {                             \
        if (!(cond)) {               \
            return_expr;             \
        }                            \
    } while (0)

#define CHECK_FREE_RET(cond, return_expr) \
    do {                                  \
        if (!(cond)) {                    \
            Finalize(deviceId, stream);   \
            return_expr;                  \
        }                                 \
    } while (0)

#define LOG_PRINT(message, ...)         \
    do {                                \
        printf(message, ##__VA_ARGS__); \
    } while (0)

int64_t GetShapeSize(const std::vector<int64_t>& shape)
{
    int64_t shapeSize = 1;
    for (auto i : shape) {
        if (i != 0 && shapeSize > INT64_MAX / i) {
            return -1;
        }
        shapeSize *= i;
    }
    return shapeSize;
}

int Init(int32_t deviceId, aclrtStream* stream)
{
    // Boilerplate for resource initialization
    auto ret = aclInit(nullptr);
    CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclInit failed. ERROR: %d\n", ret); return ret);
    ret = aclrtSetDevice(deviceId);
    CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSetDevice failed. ERROR: %d\n", ret); return ret);
    ret = aclrtCreateStream(stream);
    CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtCreateStream failed. ERROR: %d\n", ret); return ret);
    return 0;
}

template <typename T>
int CreateAclTensor(const std::vector<T>& hostData, const std::vector<int64_t>& shape, void** deviceAddr,
                    aclDataType dataType, aclTensor** tensor)
{
    auto size = GetShapeSize(shape) * sizeof(T);
    // Call aclrtMalloc to allocate device-side memory.
    auto ret = aclrtMalloc(deviceAddr, size, ACL_MEM_MALLOC_HUGE_FIRST);
    CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtMalloc failed. ERROR: %d\n", ret); return ret);
    // Call aclrtMemcpy to copy host-side data to device-side memory.
    ret = aclrtMemcpy(*deviceAddr, size, hostData.data(), size, ACL_MEMCPY_HOST_TO_DEVICE);
    CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtMemcpy failed. ERROR: %d\n", ret); return ret);

    // Calculate the strides of a contiguous tensor.
    std::vector<int64_t> strides(shape.size(), 1);
    for (int64_t i = shape.size() - 2; i >= 0; i--) {
        strides[i] = shape[i + 1] * strides[i + 1];
    }

    // Call the aclCreateTensor API to create an aclTensor.
    *tensor = aclCreateTensor(shape.data(), shape.size(), dataType, strides.data(), 0, aclFormat::ACL_FORMAT_ND,
                              shape.data(), shape.size(), *deviceAddr);
    return 0;
}

void Finalize(int32_t deviceId, aclrtStream stream)
{
    aclrtDestroyStream(stream);
    aclrtResetDevice(deviceId);
    aclFinalize();
}

int aclnnSwigluBackwardMxQuantWithDualAxisTest(int32_t deviceId, aclrtStream& stream)
{
    auto ret = Init(deviceId, &stream);
    CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Init acl failed. ERROR: %d\n", ret); return ret);

    // 2. Construct the inputs and outputs. Custom construction is required based on the API.
    // Input x shape: [M, 2N] = [256, 1024]
    std::vector<int64_t> xShape = {256, 1024};
    // Input yGrad shape: [M, N] = [256, 512]
    std::vector<int64_t> yGradShape = {256, 512};
    // group_index shape: [G] = [1], using the cumsum mode, where the value 256 indicates that one group contains all 256 rows.
    std::vector<int64_t> groupIndexShape = {1};
    // Backward output shape: [M, 2N] = [256, 1024] (quantization result of concat(gradA, gradB))
    std::vector<int64_t> y1OutShape = {256, 1024};
    std::vector<int64_t> y2OutShape = {256, 1024};
    std::vector<int64_t> mxscale1OutShape = {256, 16, 2};
    std::vector<int64_t> mxscale2OutShape = {5, 1024, 2};

    void* xDeviceAddr = nullptr;
    void* yGradDeviceAddr = nullptr;
    void* groupIndexDeviceAddr = nullptr;
    void* y1OutDeviceAddr = nullptr;
    void* mxscale1OutDeviceAddr = nullptr;
    void* y2OutDeviceAddr = nullptr;
    void* mxscale2OutDeviceAddr = nullptr;

    aclTensor* x = nullptr;
    aclTensor* yGrad = nullptr;
    aclTensor* groupIndex = nullptr;
    aclTensor* y1Out = nullptr;
    aclTensor* mxscale1Out = nullptr;
    aclTensor* y2Out = nullptr;
    aclTensor* mxscale2Out = nullptr;

    // Initialize the input data (BF16).
    std::vector<uint16_t> xHostData(256 * 1024, 0);
    for (int64_t i = 0; i < 256 * 1024; i++) {
        xHostData[i] = static_cast<uint16_t>(i % 100);
    }
    // Initialize the yGrad data (BF16).
    std::vector<uint16_t> yGradHostData(256 * 512, 0);
    for (int64_t i = 0; i < 256 * 512; i++) {
        yGradHostData[i] = static_cast<uint16_t>(i % 50);
    }
    // group_index data: cumsum mode. A value of 256 indicates a single group containing all rows.
    std::vector<int64_t> groupIndexHostData = {256};
    std::vector<uint8_t> y1OutHostData(256 * 1024, 0);
    std::vector<uint8_t> y2OutHostData(256 * 1024, 0);
    std::vector<uint8_t> mxscale1OutHostData(256 * 16 * 2, 0);
    std::vector<uint8_t> mxscale2OutHostData(5 * 1024 * 2, 0);

    // Parameter settings
    bool activateLeft = true;
    char* roundModeOptional = const_cast<char*>("rint");
    int64_t dstDtype = 36;  // FLOAT8_E4M3FN
    int64_t scaleAlg = 1;  // cuBLAS
    double maxDtypeValue = 0.0;

    // Create x aclTensor.
    ret = CreateAclTensor(xHostData, xShape, &xDeviceAddr, aclDataType::ACL_BF16, &x);
    std::unique_ptr<aclTensor, aclnnStatus (*)(const aclTensor*)> xTensorPtr(x, aclDestroyTensor);
    std::unique_ptr<void, aclError (*)(void*)> xDeviceAddrPtr(xDeviceAddr, aclrtFree);
    CHECK_RET(ret == ACL_SUCCESS, return ret);

    // Create yGrad aclTensor.
    ret = CreateAclTensor(yGradHostData, yGradShape, &yGradDeviceAddr, aclDataType::ACL_BF16, &yGrad);
    std::unique_ptr<aclTensor, aclnnStatus (*)(const aclTensor*)> yGradTensorPtr(yGrad, aclDestroyTensor);
    std::unique_ptr<void, aclError (*)(void*)> yGradDeviceAddrPtr(yGradDeviceAddr, aclrtFree);
    CHECK_RET(ret == ACL_SUCCESS, return ret);

    // Create groupIndex aclTensor.
    ret = CreateAclTensor(groupIndexHostData, groupIndexShape, &groupIndexDeviceAddr, aclDataType::ACL_INT64, &groupIndex);
    std::unique_ptr<aclTensor, aclnnStatus (*)(const aclTensor*)> groupIndexTensorPtr(groupIndex, aclDestroyTensor);
    std::unique_ptr<void, aclError (*)(void*)> groupIndexDeviceAddrPtr(groupIndexDeviceAddr, aclrtFree);
    CHECK_RET(ret == ACL_SUCCESS, return ret);

    // Create y1Out aclTensor.
    ret = CreateAclTensor(y1OutHostData, y1OutShape, &y1OutDeviceAddr, aclDataType::ACL_FLOAT8_E4M3FN, &y1Out);
    std::unique_ptr<aclTensor, aclnnStatus (*)(const aclTensor*)> y1OutTensorPtr(y1Out, aclDestroyTensor);
    std::unique_ptr<void, aclError (*)(void*)> y1OutDeviceAddrPtr(y1OutDeviceAddr, aclrtFree);
    CHECK_RET(ret == ACL_SUCCESS, return ret);

    // Create mxscale1Out aclTensor.
    ret = CreateAclTensor(mxscale1OutHostData, mxscale1OutShape, &mxscale1OutDeviceAddr, aclDataType::ACL_FLOAT8_E8M0, &mxscale1Out);
    std::unique_ptr<aclTensor, aclnnStatus (*)(const aclTensor*)> mxscale1OutTensorPtr(mxscale1Out, aclDestroyTensor);
    std::unique_ptr<void, aclError (*)(void*)> mxscale1OutDeviceAddrPtr(mxscale1OutDeviceAddr, aclrtFree);
    CHECK_RET(ret == ACL_SUCCESS, return ret);

    // Create y2Out aclTensor.
    ret = CreateAclTensor(y2OutHostData, y2OutShape, &y2OutDeviceAddr, aclDataType::ACL_FLOAT8_E4M3FN, &y2Out);
    std::unique_ptr<aclTensor, aclnnStatus (*)(const aclTensor*)> y2OutTensorPtr(y2Out, aclDestroyTensor);
    std::unique_ptr<void, aclError (*)(void*)> y2OutDeviceAddrPtr(y2OutDeviceAddr, aclrtFree);
    CHECK_RET(ret == ACL_SUCCESS, return ret);

    // Create mxscale2Out aclTensor.
    ret = CreateAclTensor(mxscale2OutHostData, mxscale2OutShape, &mxscale2OutDeviceAddr, aclDataType::ACL_FLOAT8_E8M0, &mxscale2Out);
    std::unique_ptr<aclTensor, aclnnStatus (*)(const aclTensor*)> mxscale2OutTensorPtr(mxscale2Out, aclDestroyTensor);
    std::unique_ptr<void, aclError (*)(void*)> mxscale2OutDeviceAddrPtr(mxscale2OutDeviceAddr, aclrtFree);
    CHECK_RET(ret == ACL_SUCCESS, return ret);

    // Call the CANN operator library API.
    uint64_t workspaceSize = 0;
    aclOpExecutor* executor;

    // Call the first-phase API of aclnnSwigluBackwardMxQuantWithDualAxis (with groupIndex input).
    ret = aclnnSwigluBackwardMxQuantWithDualAxisGetWorkspaceSize(x, yGrad, groupIndex, activateLeft, roundModeOptional,
        scaleAlg, dstDtype, maxDtypeValue, y1Out, mxscale1Out, y2Out, mxscale2Out, &workspaceSize, &executor);
    CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnSwigluBackwardMxQuantWithDualAxisGetWorkspaceSize failed. ERROR: %d\n", ret);
              return ret);

    // Allocate device memory based on the workspaceSize computed by the first-phase API.
    void* workspaceAddr = nullptr;
    std::unique_ptr<void, aclError (*)(void*)> workspaceAddrPtr(nullptr, aclrtFree);
    if (workspaceSize > 0) {
        ret = aclrtMalloc(&workspaceAddr, workspaceSize, ACL_MEM_MALLOC_HUGE_FIRST);
        CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("allocate workspace failed. ERROR: %d\n", ret); return ret);
        workspaceAddrPtr.reset(workspaceAddr);
    }

    // Call the second-phase API of aclnnSwigluBackwardMxQuantWithDualAxis.
    ret = aclnnSwigluBackwardMxQuantWithDualAxis(workspaceAddr, workspaceSize, executor, stream);
    CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnSwigluBackwardMxQuantWithDualAxis failed. ERROR: %d\n", ret); return ret);

    // (Boilerplate) Wait for the task execution to complete synchronously.
    ret = aclrtSynchronizeStream(stream);
    CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSynchronizeStream failed. ERROR: %d\n", ret); return ret);

    // Obtain the output value and copy the result from device memory to host memory.
    auto size1 = GetShapeSize(y1OutShape);
    auto size2 = GetShapeSize(y2OutShape);
    std::vector<uint8_t> y1OutData(size1, 0);
    std::vector<uint8_t> y2OutData(size2, 0);

    ret = aclrtMemcpy(y1OutData.data(), y1OutData.size() * sizeof(uint8_t), y1OutDeviceAddr,
                      size1 * sizeof(uint8_t), ACL_MEMCPY_DEVICE_TO_HOST);
    CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("copy y1Out from device to host failed. ERROR: %d\n", ret);
              return ret);
    ret = aclrtMemcpy(y2OutData.data(), y2OutData.size() * sizeof(uint8_t), y2OutDeviceAddr,
                      size2 * sizeof(uint8_t), ACL_MEMCPY_DEVICE_TO_HOST);
    CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("copy y2Out from device to host failed. ERROR: %d\n", ret);
              return ret);

    // Print some output results.
    LOG_PRINT("y1Out first 10 elements:\n");
    for (int64_t i = 0; i < 10 && i < size1; i++) {
        LOG_PRINT("y1Out[%ld] = %d\n", i, y1OutData[i]);
    }
    LOG_PRINT("y2Out first 10 elements:\n");
    for (int64_t i = 0; i < 10 && i < size2; i++) {
        LOG_PRINT("y2Out[%ld] = %d\n", i, y2OutData[i]);
    }

    return ACL_SUCCESS;
}

int main()
{
    // 1. (Boilerplate) Initialize device/stream. For details, see the acl API manual.
    // Fill in deviceId according to your actual device.
    int32_t deviceId = 0;
    aclrtStream stream;
    auto ret = aclnnSwigluBackwardMxQuantWithDualAxisTest(deviceId, stream);
    CHECK_FREE_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnSwigluBackwardMxQuantWithDualAxisTest failed. ERROR: %d\n", ret); return ret);

    Finalize(deviceId, stream);
    return 0;
}