Skip to content

[XNNPACK] Yolo12 model quantization #11523

@daniil-lyakhov

Description

@daniil-lyakhov

🚀 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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

To triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions