def get_conv2d_bias_elementwise_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.
    """

    conv2d_bias_patterns = [
        (
            (
                conv2d_bias(stride=1, pad=0),
                elementwise(FuncEnum.ADD),
                elementwise(FuncEnum.RELU),
            ),
            conv2d_bias_add_relu,
        ),
        (
            (
                conv2d_bias(stride=1, pad=0),
                elementwise(FuncEnum.RELU),
            ),
            conv2d_bias_relu,
        ),
        (
            (
                conv2d_bias(stride=1, pad=0),
                elementwise(FuncEnum.SIGMOID),
            ),
            conv2d_bias_sigmoid,
        ),
    ]

    transposed_conv2d_bias_patterns = [
        (
            (
                transposed_conv2d_bias(stride=1, pad=0),
                elementwise(FuncEnum.RELU),
            ),
            transposed_conv2d_bias_relu,
        ),
    ]

    transposed_conv2d_patterns = [
        (
            (
                transposed_conv2d(stride=1, pad=0),
                elementwise(FuncEnum.ADD),
                elementwise(FuncEnum.RELU),
            ),
            transposed_conv2d_bias_relu,
        ),
        (
            (
                transposed_conv2d_bias(stride=1, pad=0),
                elementwise(FuncEnum.RELU),
            ),
            transposed_conv2d_bias_relu,
        ),
    ]

    fusion_patterns = (
        conv2d_bias_patterns
        + transposed_conv2d_bias_patterns
        + transposed_conv2d_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_conv_patterns.py