def fuse_group_ops(sorted_graph: List[Tensor], workdir: str = None) -> List[Tensor]:
    """Horizontal fusion of grouped gemm and layernorm ops

    Parameters
    ----------
    sorted_graph : List[Tensor]
        Input graph
    workdir : str, optional
        working dir, by default None

    Returns
    -------
    List[Tensor]
        New graph after fusion
    """
    # gemms need to be fused first
    # TODO: enable after adding heuristics and fixing dynamic shapes
    from aitemplate.backend.target import Target

    if Target.current().name() == "cuda":
        if "fuse_group_gemm" in Target.current()._kwargs:
            sorted_graph = fuse_group_gemm_ops(sorted_graph)
        sorted_graph = fuse_group_layernorm_ops(sorted_graph)

    return sorted_graph
Horizontal fusion of grouped gemm and layernorm ops

    Parameters
    ----------
    sorted_graph : List[Tensor]
        Input graph
    workdir : str, optional
        working dir, by default None

    Returns
    -------
    List[Tensor]
        New graph after fusion
    
python/aitemplate/compiler/transform/fuse_group_ops.py