def validate_unstructured_params()

in args.py [0:0]


def validate_unstructured_params(args):
    """
    Esnures that the specified unstructured sparsity parameters are valid
    """
    lb = args.topk_lower_bound
    ub = args.topk_upper_bound

    if (lb is not None and ub is None) or (lb is None and ub is not None):
        raise ValueError("Both upper and lower TopK bounds must be specified")

    if lb is not None:
        if lb < 0:
            raise ValueError("TopK lower bound must be >= 0")
        if ub > 1:
            raise ValueError("TopK upper bound must be <= 1")
        if lb >= ub:
            raise ValueError("TopK lower bound must be < upper bound")
        if args.eval_topk_grid is None:
            raise ValueError(
                "eval_topk_grid must be specified when TopK bounds are"
            )

    return args