()
| 68 | |
| 69 | |
| 70 | def _get_args(): |
| 71 | parser = argparse.ArgumentParser( |
| 72 | "Evaluate a model quantized and/or delegated for the Arm backend." |
| 73 | " Evaluations include numerical comparison to the original model" |
| 74 | "and/or top-1/top-5 accuracy if applicable." |
| 75 | ) |
| 76 | parser.add_argument( |
| 77 | "-m", |
| 78 | "--model_name", |
| 79 | required=True, |
| 80 | help="Model file .py/.pth/.pt or a model from examples/models." |
| 81 | f" Available models from examples/models: {', '.join(MODEL_NAME_TO_MODEL.keys())}", |
| 82 | ) |
| 83 | parser.add_argument( |
| 84 | "-t", |
| 85 | "--target", |
| 86 | action="store", |
| 87 | required=True, |
| 88 | help=( |
| 89 | "For Arm backend delegated models, pick the target." |
| 90 | " Examples of valid targets: TOSA-1.0+INT, TOSA-1.0+FP+bf16" |
| 91 | ), |
| 92 | ) |
| 93 | parser.add_argument( |
| 94 | "-q", |
| 95 | "--quant_mode", |
| 96 | required=False, |
| 97 | default=None, |
| 98 | choices=_QUANT_MODES, |
| 99 | help="Quantize the model using the requested mode.", |
| 100 | ) |
| 101 | parser.add_argument( |
| 102 | "--calibration_data", |
| 103 | required=False, |
| 104 | default=None, |
| 105 | help=( |
| 106 | "Optional calibration data file or directory. If a directory is " |
| 107 | "provided, up to 1000 samples are used for calibration. " |
| 108 | "Supported files: Common image formats (e.g., .png or .jpg) if " |
| 109 | "using imagenet evaluator, otherwise .pt/.pth files. If not provided," |
| 110 | "quantized models are calibrated on their example inputs." |
| 111 | ), |
| 112 | ) |
| 113 | parser.add_argument( |
| 114 | "--no_delegate", |
| 115 | action="store_false", |
| 116 | dest="delegate", |
| 117 | default=True, |
| 118 | help=( |
| 119 | "Disable delegation for cases where a quantized but non-delegated " |
| 120 | "model is to be tested." |
| 121 | ), |
| 122 | ) |
| 123 | parser.add_argument( |
| 124 | "-e", |
| 125 | "--evaluators", |
| 126 | required=True, |
| 127 | help=( |
no test coverage detected