Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions examples/qualcomm/oss_scripts/mobilevit_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
build_executorch_binary,
get_backend_type,
make_output_dir,
make_quantizer,
parse_skip_delegation_node,
setup_common_args_and_variables,
SimpleADB,
Expand Down Expand Up @@ -90,9 +91,12 @@ def main(args):

pte_filename = "mobilevit_v2_qnn"
backend = get_backend_type(args.backend)
quant_dtype = {
quantizer = {
QnnExecuTorchBackendType.kGpuBackend: None,
QnnExecuTorchBackendType.kHtpBackend: QuantDtype.use_16a8w,
QnnExecuTorchBackendType.kHtpBackend: make_quantizer(
quant_dtype=QuantDtype.use_16a8w,
eps=2**-10,
),
}[backend]
build_executorch_binary(
module,
Expand All @@ -102,7 +106,7 @@ def main(args):
inputs,
skip_node_id_set=skip_node_id_set,
skip_node_op_set=skip_node_op_set,
quant_dtype=quant_dtype,
custom_quantizer=quantizer,
backend=backend,
shared_buffer=args.shared_buffer,
online_prepare=args.online_prepare,
Expand Down
8 changes: 7 additions & 1 deletion examples/qualcomm/util_scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def __iter__(self):

def quantize(args):
logger = get_logger()

# get corresponding QnnQuantizer
try:
quant_dtype = getattr(QuantDtype, args.config)
Expand All @@ -147,6 +146,7 @@ def quantize(args):
act_observer=act_observer,
backend=get_backend_type(args.backend),
soc_model=args.model,
eps=args.eps,
)
except Exception:
logger.error(
Expand Down Expand Up @@ -450,6 +450,12 @@ def main():
default="htp",
help="Backend to be deployed ('htp'/'gpu' are currently supported).",
)
sub_quantize.add_argument(
"--eps",
help="EPS value for quantizer. Accepts floating‑point literal. E.g., 0.0009765625.",
type=float,
default=None,
)
sub_quantize.set_defaults(callback=quantize)

sub_compile = subparsers.add_parser(
Expand Down
2 changes: 1 addition & 1 deletion examples/qualcomm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,9 @@ def make_quantizer(
act_symmetric=False,
is_qat=False,
submodule_qconfig_list: Optional[List[Tuple[Callable, ModuleQConfig]]] = None,
eps=None,
backend=QnnExecuTorchBackendType.kHtpBackend,
soc_model="SM8750",
eps=None,
):
quantizer = QnnQuantizer(backend=backend, soc_model=getattr(QcomChipset, soc_model))
quantizer.add_custom_quant_annotations(custom_annotations)
Expand Down
Loading