[object Object]

[object Object][object Object]undefined
[object Object]
  • API function: Calculates the variable step-size Recurrent Gated Delta Rule (RGDR).

  • Formula:

    RGDR is an operator designed for recurrent neural networks (RNNs) and serves as a key component in linear attention mechanisms. At each time step tt, the network processes the current inputs query qtq_t, key ktk_t, and value vtv_t along with the previous hidden state St1S_{t-1} to produce the attention output oto_t and new hidden state StS_t. The gating mechanism controls what proportion of new information enters the hidden state and what proportion of existing information is discarded.

    St:=St1(αtDiag(αkt)(IβtktktT))+βtvtktT=αtDiag(αkt)St1+βt(vtαtDiag(αkt)St1kt)ktTS_t := S_{t-1}(\alpha_t Diag(\alpha_{kt})(I - \beta_t k_t k_t^T)) + \beta_t v_t k_t^T = \alpha_t Diag(\alpha_{kt})S_{t-1} + \beta_t (v_t - \alpha_t Diag(\alpha_{kt})S_{t-1}k_t)k_t^T o:=Stqtdko := \frac{S_t q_t}{\sqrt{d_k}}

    In the preceding information, St1,StRdv×dkS_{t-1},S_t \in R^{d_v \times d_k}, qt,ktRdkq_t, k_t \in R^{d_k}, vtRdvv_t \in R^{d_v}, αtR\alpha_t \in R, αkRdk\alpha_k \in R^{d_k}, βtR\beta_t \in R, oRdvo \in R^{d_v}

[object Object]

Each operator has calls. First, [object Object] is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, [object Object] is called to perform computation.

[object Object]
[object Object]
[object Object]
  • Parameters

    [object Object]

    BB indicates the batch size. Let LiL_i be the length of the ith sequence, then T=iBLiT=\sum_i^B L_i represents the cumulative sequence length. NkN_k indicates the number of key heads, NvN_v indicates the number of value heads, DkD_k indicates the dimension of the key vector, and DvD_v indicates the dimension of the value vector.

  • Returns

    [object Object]: status code. For details, see .

    The first-phase API implements input parameter verification. The following errors may be thrown:

    [object Object]
[object Object]
  • Parameters

    [object Object]
  • Returns

    [object Object]: status code. For details, see .

[object Object]
  • Deterministic computing:
    • [object Object] defaults to a deterministic implementation.
  • The input shape size must meet the following constraints: Li8L_i \le 8, Nk256N_k \le 256, Nv256N_v \le 256, Dk256D_k \le 256, Dv256D_v \le 256.
[object Object]

The following example is for reference only. For details, see .

[object Object]