Skip to content

Inappropriate detection of dynamic dimensions in executorch/backends/xnnpack/operators/op_squeeze.py #5794

@ezyang

Description

@ezyang

🐛 Describe the bug

You have this logic:

        num_dynamic_dims = 0
        for dim in dynamic_shape:
            if isinstance(dim, torch.SymInt):
                num_dynamic_dims += 1
                new_shape.append(0)
            else:
                new_shape.append(dim)

        check_or_raise(
            num_dynamic_dims <= 1,
            "XNNPACK reshape only supports 1 dynamic dimension. This may occur when ",
        )

This is not the right way to detect how many dynamic dimensions are going into the squeeze call. For one, you could potentially have a SymInt which internally contains a constant int (we try to decay this ASAP, but if you have a SymInt in hand and then later we do a replacement that refines it to an int, you are still going to have a SymInt.)

I think probably what's more right is to call free_symbols(dim). When there are no free symbols, you are convertible to int, which is what this code is trying to do right?

Versions

main

Metadata

Metadata

Assignees

Labels

module: xnnpackIssues related to xnnpack delegation and the code under backends/xnnpack/

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions