def gemm_bias_broadcast_instance(
    op_def,
    func_attrs,
    for_profiler,
    layout,
    unary_op1,
    binary_op1,
    binary_op2,
    unary_op2,
    elem_type,
    cutlass_3x=False,
):
    """
    adjust gemm instance with respect to input_accessors, layout and epilogue ops
    """
    if cutlass_3x:
        return _replace_epilogue_cutlass_3x(
            op_def=op_def,
            unary_op1=unary_op1,
            binary_op1=binary_op1,
            binary_op2=binary_op2,
            unary_op2=unary_op2,
        )

    op_def = common.update_alignments_in_gemm_instance(op_def, func_attrs, for_profiler)
    gemm_universal_params = common.get_gemm_instance_template_params(op_def)
    epilogue_pattern = re.compile(r"\s*(cutlass::epilogue::thread::.*)\s*<")
    match = epilogue_pattern.match(gemm_universal_params[9])
    if match is None:
        raise RuntimeError("Invalid epilogue functor:\n" + gemm_universal_params[9])
    epilogue_functor = match.groups()[0]

    if (
        "use_fp16_acc" in Target.current()._kwargs
        and Target.current()._kwargs["use_fp16_acc"]
        and elem_type == "cutlass::half_t"
    ):
        acc_type = "cutlass::half_t"
    else:
        acc_type = "float"
    gemm_universal_with_broadcast_params = (
        GEMM_UNIVERSAL_WITH_BROADCAST_TEMPLATE.render(
            arch=gemm_universal_params[5],
            tb_shape=gemm_universal_params[6],
            warp_shape=gemm_universal_params[7],
            instruction_shape=gemm_universal_params[8],
            epilogue_functor=epilogue_functor,
            epilogue_vector_length=gemm_universal_params[11],
            unary_op1=unary_op1,
            binary_op1=binary_op1,
            binary_op2=binary_op2,
            unary_op2=unary_op2,
            stage=gemm_universal_params[16],
            alignment_a=gemm_universal_params[17],
            alignment_b=gemm_universal_params[18],
            layout=layout,
            acc_type=acc_type,
            elem_type=elem_type,
            has_d1=(binary_op2 is not None),
        )
    )
    res = re.sub(
        r"cutlass::gemm::device::Gemm<[\s\S]+>;",
        gemm_universal_with_broadcast_params,
        op_def,
    )
    return res
adjust gemm instance with respect to input_accessors, layout and epilogue ops
python/aitemplate/backend/cuda/gemm_universal/common_bias_broadcast.py