def _layernorm_op_check(op1: Operator, op2: Operator) -> bool:
    """Function to filter out bad layernorm candidates for group_layernorm
    and group_layernorm_sigmoid_mul.
    """
    if op1 == op2:
        return True

    # check for same eps
    if op1._attrs["eps"] != op2._attrs["eps"]:
        return False

    if len(op1._attrs["inputs"]) != 3 or len(op2._attrs["inputs"]) != 3:
        return False

    # check for same rank and batch dims
    input1 = op1._attrs["inputs"][0]
    input2 = op2._attrs["inputs"][0]
    if input1._rank() != input2._rank():
        return False

    norm_shapes_1 = op1._attrs["normalized_shape"]
    norm_shapes_2 = op2._attrs["normalized_shape"]
    # This may be relaxed in the future
    if len(norm_shapes_1) != len(norm_shapes_2):
        return False

    # All batch dims must be the same
    for i in range(input1._rank() - len(norm_shapes_1)):
        if input1._size(i) != input2._size(i):
            return False

    # check gamma and bias
    if op1._attrs["gamma_constant"] is not None:
        return False

    if op1._attrs["beta_constant"] is not None:
        return False

    return _check_layernorm_n_match(op1, op2)
Function to filter out bad layernorm candidates for group_layernorm
and group_layernorm_sigmoid_mul.
python/aitemplate/compiler/transform/fuse_group_ops.py