Skip to content

Swin_v2_t model fails to lower on QNN #14052

@GregoryComer

Description

@GregoryComer

🐛 Describe the bug

The swin_v2_t model from torchvision does not successfully lower on the QNN backend. It fails with multiple errors. I see a number of instances of "incorrect Rank 6", though I'm not sure if this is fatal. It fails at the end, fatally, with "Failed to validate op aten_view_copy_default_17".

Output excerpt:

[QNN Partitioner Op Support]: aten.permute_copy.default | False
[ERROR] [Qnn ExecuTorch]:  <E> [4294967295] has incorrect Rank 6.

[ERROR] [Qnn ExecuTorch]:  <E> QnnBackend_validateOpConfig failed 3110

[ERROR] [Qnn ExecuTorch]:  <E> Failed to validate op aten_view_copy_default_17 with error 0xc26

[WARNING] [Qnn ExecuTorch]: Qnn Backend op validation failed with error: 3110

...

INFO:executorch.backends.qualcomm.qnn_preprocess:Visiting: aten_slice_copy_tensor_7, aten.slice_copy.Tensor
[ERROR] [Qnn ExecuTorch]: graph_prepare.cc:3490::ERROR:node 11 has input with id 0

[ERROR] [Qnn ExecuTorch]:  <E> Failed to append node qti.aisw::QNN_StridedSlice                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         [ERROR] [Qnn ExecuTorch]:  <E> Failed to construct common node for graph 257                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            [ERROR] [Qnn ExecuTorch]:  <E> Failed to add node with err 6007                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         [ERROR] [Qnn ExecuTorch]: Failed to add node to Qnn Graph with error: 6007                                                                                                                                                                                                                                                  [ERROR] [Qnn ExecuTorch]: Fail to compile QNN graph

This can be reproduced with the following test case command or standalone script.

python -m executorch.backends.test.suite.runner models --flow qnn --filter "test_swin_v2_t_qnn_float32$"

Standalone repro:

from typing import Tuple

import executorch
import torch
import torchvision

from executorch.backends.qualcomm.utils.utils import (
    generate_qnn_executorch_compiler_spec,
    generate_htp_compiler_spec,
    QcomChipset,
    to_edge_transform_and_lower_to_qnn,
)

inputs = (torch.randn(1, 3, 224, 224),)
model = torchvision.models.swin_v2_t().eval()

ep = torch.export.export(model, inputs)

backend_options = generate_htp_compiler_spec(
    use_fp16=True,
)

compile_spec = generate_qnn_executorch_compiler_spec(
    soc_model=QcomChipset.SM8650,
    backend_options=backend_options,
)

model = to_edge_transform_and_lower_to_qnn(
    model,
    inputs,
    compile_spec
).to_executorch()

Note that running the backend test case requires executorch's python bindings to be built with the QNN backend. An example build command is below, Note that it will still need the library paths to be set up properly as described in the ET QNN docs.

CMAKE_ARGS="-DEXECUTORCH_BUILD_QNN=ON -DQNN_SDK_ROOT=$QNN_SDK_ROOT" ./install_executorch.sh --editable

Versions

Commit fbda3a9, x86-64 simulator, WSL

cc @cccclai @winskuo-quic @shewu-quic @cbilgin

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend testerThis bug was found by the backend test suite.module: qnnIssues related to Qualcomm's QNN delegate and code under backends/qualcomm/partner: qualcommFor backend delegation, kernels, demo, etc. from the 3rd-party partner, Qualcomm

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions