def get_patterns():
    """
    We create the pattern of fusion here.
    The format should be in the form of (pattern, replacement)

    pattern: This would be a list of operator which are chained which we
             want to match
    replacement: The op to replace pattern.
    """
    bmm_ccr_patterns = [
        ((bmm_ccr(), elementwise(FuncEnum.ADD)), bmm_ccr_add),
    ]

    bmm_crr_patterns = [
        ((bmm_crr(), elementwise(FuncEnum.ADD)), bmm_crr_add),
    ]

    bmm_rrr_patterns = [
        ((bmm_rrr(), elementwise(FuncEnum.ADD)), bmm_rrr_add),
    ]

    gemm_rcr_bias_activation_patterns = [
        (
            (
                gemm_rcr_bias(),
                elementwise(FuncEnum.RELU),
            ),
            gemm_rcr_bias_relu,
        ),
        (
            (
                gemm_rcr_bias(),
                elementwise(FuncEnum.SIGMOID),
                elementwise(FuncEnum.MUL),
                elementwise(FuncEnum.TANH),
            ),
            gemm_rcr_bias_sigmoid_mul_tanh,
        ),
        (
            (
                gemm_rcr_bias(),
                elementwise(FuncEnum.SIGMOID),
                elementwise(FuncEnum.MUL),
            ),
            gemm_rcr_bias_sigmoid_mul,
        ),
        (
            (
                gemm_rcr_bias(),
                elementwise(FuncEnum.SIGMOID),
            ),
            gemm_rcr_bias_sigmoid,
        ),
        (
            (
                gemm_rcr_bias(),
                elementwise(FuncEnum.TANH),
            ),
            gemm_rcr_bias_tanh,
        ),
        (
            (
                gemm_rcr_bias(),
                elementwise(FuncEnum.GELU),
            ),
            gemm_rcr_bias_gelu,
        ),
        (
            (
                gemm_rcr_bias(),
                elementwise(FuncEnum.FASTGELU),
            ),
            gemm_rcr_bias_fast_gelu,
        ),
    ]

    gemm_rcr_bias_add_patterns = [
        (
            (
                gemm_rcr_bias(),
                elementwise(FuncEnum.ADD),
                elementwise(FuncEnum.RELU),
            ),
            gemm_rcr_bias_add_relu,
        ),
        (
            (
                gemm_rcr_bias(),
                elementwise(FuncEnum.ADD),
                elementwise(FuncEnum.ADD),
                elementwise(FuncEnum.RELU),
            ),
            gemm_rcr_bias_add_add_relu,
        ),
        (
            (
                gemm_rcr_bias(),
                elementwise(FuncEnum.ADD),
                elementwise(FuncEnum.ADD),
            ),
            gemm_rcr_bias_add_add,
        ),
        (
            (gemm_rcr_bias(), elementwise(FuncEnum.ADD)),
            gemm_rcr_bias_add,
        ),
    ]

    gemm_rcr_bias_mul_patterns = [
        (
            (
                gemm_rcr_bias(),
                elementwise(FuncEnum.MUL),
                elementwise(FuncEnum.ADD),
            ),
            gemm_rcr_bias_mul_add,
        ),
        (
            (
                gemm_rcr_bias(),
                elementwise(FuncEnum.MUL),
                elementwise(FuncEnum.TANH),
            ),
            gemm_rcr_bias_mul_tanh,
        ),
        (
            (
                gemm_rcr_bias(),
                elementwise(FuncEnum.MUL),
            ),
            gemm_rcr_bias_mul,
        ),
    ]

    fusion_patterns = (
        bmm_ccr_patterns
        + bmm_crr_patterns
        + bmm_rrr_patterns
        + gemm_rcr_bias_activation_patterns
        + gemm_rcr_bias_add_patterns
        + gemm_rcr_bias_mul_patterns
    )

    return fusion_patterns
We create the pattern of fusion here.
The format should be in the form of (pattern, replacement)

pattern: This would be a list of operator which are chained which we
want to match
replacement: The op to replace pattern.
python/aitemplate/compiler/transform/fuse_mm_elementwise_patterns.py