pytorch / pytorch/executorch

[XNNPACK] Yolo12 model quantization

Open
#11,523 7 comments 0 reactions 2 assignees View on GitHub

@GregoryComer is already working on this.

Since Oct 3, 2025.

Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

🚀 The feature, motivation and pitch

During the development of the Yolo12 detection sample, it was found that the model quantized by the XNNPACKQuantizer could not be lowered to the XNNPACK:

After installation with the XNNPACK backend:

python /examples/models/yolo12/export_and_validate.py --model_name yolo12s  --backend xnnpack --video_path cycling.mp4 --quantize

leads to the following error

Quantized succsessfully!
Traceback (most recent call last):
  File "/home/devuser/dlyakhov/executorch/examples/models/yolo12/export_and_validate.py", line 395, in <module>
    subset_size=args.subset_size,
  File "/home/devuser/dlyakhov/executorch/examples/models/yolo12/export_and_validate.py", line 263, in main
    subset_size=subset_size,
  File "/home/devuser/dlyakhov/executorch/examples/models/yolo12/export_and_validate.py", line 161, in lower_to_xnnpack
    ),
  File "/home/devuser/dlyakhov/executorch/env/lib/python3.10/site-packages/executorch/exir/program/_program.py", line 113, in wrapper
    return func(self, *args, **kwargs)
  File "/home/devuser/dlyakhov/executorch/env/lib/python3.10/site-packages/executorch/exir/program/_program.py", line 1261, in to_edge_transform_and_lower
    edge_manager = edge_manager.to_backend(method_to_partitioner)
  File "/home/devuser/dlyakhov/executorch/env/lib/python3.10/site-packages/executorch/exir/program/_program.py", line 113, in wrapper
    return func(self, *args, **kwargs)
  File "/home/devuser/dlyakhov/executorch/env/lib/python3.10/site-packages/executorch/exir/program/_program.py", line 1532, in to_backend
    new_edge_programs = to_backend(method_to_programs_and_partitioners)
  File "/usr/lib/python3.10/functools.py", line 889, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/home/devuser/dlyakhov/executorch/env/lib/python3.10/site-packages/executorch/exir/backend/backend_api.py", line 761, in _
    lower_all_submodules_to_backend(
  File "/home/devuser/dlyakhov/executorch/env/lib/python3.10/site-packages/executorch/exir/backend/backend_api.py", line 595, in lower_all_submodules_to_backend
    backend_name_to_subclass[backend_id].preprocess_multimethod(
  File "/home/devuser/dlyakhov/executorch/env/lib/python3.10/site-packages/executorch/exir/backend/backend_details.py", line 124, in preprocess_multimethod
    preprocess_result = cls.preprocess(program, compile_spec_for_program)
  File "/home/devuser/dlyakhov/executorch/env/lib/python3.10/site-packages/executorch/backends/xnnpack/xnnpack_preprocess.py", line 149, in preprocess
    assert_default_dim_order(graph_module)
  File "/home/devuser/dlyakhov/executorch/env/lib/python3.10/site-packages/executorch/backends/xnnpack/xnnpack_preprocess.py", line 94, in assert_default_dim_order
    raise RuntimeError(
RuntimeError: XNNPACK backend only supports contiguous memory format for inputs.Expecting dim_order: (0, 1, 2), but got (2, 0, 1) for a placeholder node b__frozen_param129.

The task is to support quantization of the yolo12 models family in XNNPACK backend

Alternatives

No response

Additional context

No response

RFC (Optional)

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.