def gen_function_src(
    sorted_graph: List[Tensor], workdir: str, model_name: str = ""
) -> List[Tuple[str, str]]:
    """Generate functions source code files for the given graph

    Parameters
    ----------
    sorted_graph : List[Tensor]
        The network after running toposort transformation
    workdir : str
        Target directory for generated C++ source code files
    model_name : str, optional
        Sub working directory in the workdir for the given model, by default ""

    Returns
    -------
    List[Tuple[str, str]]
        List of tuple (source file path, object file path)
    """
    target = Target.current()
    file_pairs = []
    exist_func = set()
    prefix = os.path.join(workdir, model_name)
    for node in sorted_graph:
        for func in node.src_ops():
            fname = func._attrs["name"]
            if fname not in exist_func:
                src_path = os.path.join(prefix, fname + target.src_extension())
                obj_path = os.path.join(prefix, fname + ".obj")
                file_pairs.append((src_path, obj_path))
                with open(src_path, "w") as fo:
                    fo.write(func.gen_function())
                exist_func.add(fname)
    _LOGGER.info(f"generated {len(file_pairs)} function srcs")
    return file_pairs
Generate functions source code files for the given graph

Parameters
----------
sorted_graph : List[Tensor]
The network after running toposort transformation
workdir : str
Target directory for generated C++ source code files
model_name : str, optional
Sub working directory in the workdir for the given model, by default ""

Returns
-------
List[Tuple[str, str]]
List of tuple (source file path, object file path)
python/aitemplate/backend/codegen.py