o
    "j
                     @   s   d dl mZ dd ZdS )    )LayerHelperc           	   	   C   sJ   t d	i t }|j| jd}|jd| |||||dd|id|id |S )
a$  
    Applies fused ec_moe kernel.
    This method requires SM_ARCH in sm75, sm80, sm86.

    Args:
        x (Tensor): the input Tensor. Its shape is [bsz, seq_len, d_model].
        gate (Tensor): the gate Tensor to choose expert. Its shape is [bsz, seq_len, e].
        bmm0_weight (Tensor): the first batch matrix matmul weight. Its shape is [e, d_model, d_feed_forward].
        bmm0_bias (Tensor): the first batch matrix matmul bias. Its shape is [e, 1, d_feed_forward].
        bmm1_weight (Tensor): the second batch matrix matmul weight. Its shape is [e, d_model, d_feed_forward].
        bmm1_bias (Tensor): the second batch matrix matmul bias. Its shape is [e, 1, d_feed_forward].
        act_type (string): the Activation Type. Currently only support `gelu`, `relu`.

    Returns:
        Tensor: the output Tensor.

    Examples:
        .. code-block:: python

            >>> # doctest: +REQUIRES(env:GPU)
            >>> import paddle
            >>> from paddle.incubate.nn.functional import fused_ec_moe

            >>> paddle.set_device('gpu')
            >>> x = paddle.randn([10, 128, 1024])
            >>> gate = paddle.randn([10, 128, 8])
            >>> bmm0_weight = paddle.randn([8, 1024, 4096])
            >>> bmm0_bias = paddle.randn([8, 1024, 4096])
            >>> bmm1_weight = paddle.randn([8, 1024, 4096])
            >>> bmm1_bias = paddle.randn([8, 1024, 4096])
            >>> out = fused_ec_moe(x, gate, bmm0_weight, bmm0_bias, bmm1_weight, bmm1_bias, act_type="gelu")
            >>> print(out.shape)
            [10, 128, 1024]
    	fused_moe)dtypeZmoe)XZGateZBmm0ZBias0ZBmm1ZBias1ZOutact_type)typeZinputsZoutputsattrsN)r   )r   localsZ"create_variable_for_type_inferencer   Z	append_op)	xZgateZbmm0_weightZ	bmm0_biasZbmm1_weightZ	bmm1_biasr   helperout r   k/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddle/incubate/nn/functional/fused_ec_moe.pyfused_ec_moe   s   %r   N)Zpaddle.base.layer_helperr   r   r   r   r   r   <module>   s   