Support `math.floor` on symbolic scalars (`executorch_prim::floor.Scalar`)
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Bereich
- backend, machine-learning
Rechercherichtung
Start with exir/passes/executorch_prim_ops_registry.py and the existing ceil, round, and trunc mappings, then inspect their implementations in kernels/prim_ops/register_prim_ops.cpp. Add matching math.floor support for symbolic scalars and verify the reproduction through to_edge(ep).to_executorch(); done means lowering succeeds for the provided dynamically shaped example. An open linked pull request already tracks this issue.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
🐛 Describe the bug
Lowering a dynamically-shaped exported program that calls math.floor on a symbolic expression fails in to_executorch() with AttributeError: 'builtin_function_or_method' object has no attribute '_schema'.
ceil, round, and trunc are mapped in exir/passes/executorch_prim_ops_registry.py and implemented in kernels/prim_ops/register_prim_ops.cpp, but floor is not. EdgeToBackendOpsPass therefore leaves math.floor as a Python builtin, which fails in ToOutVarPass.
Hit while exporting Hugging Face Transformers vision models (Swin, FocalNet, Depth Pro); tracked in https://github.com/huggingface/transformers/issues/51303 (item 10).
import math
import torch
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
from executorch.exir import to_edge_transform_and_lower
class M(torch.nn.Module):
def forward(self, x):
return x[: math.floor(x.shape[0] / 3)]
ep = torch.export.export(
M(), (torch.randn(8, 4),), dynamic_shapes=({0: torch.export.Dim.AUTO},)
)
to_edge_transform_and_lower(ep, partitioner=[XnnpackPartitioner()]).to_executorch()
Traceback (most recent call last):
File "repro.py", line 17, in <module>
to_edge_transform_and_lower(ep, partitioner=[XnnpackPartitioner()]).to_executorch()
File ".../executorch/exir/program/_program.py", line 118, in wrapper
return func(*args, **kwargs)
File ".../executorch/exir/program/_program.py", line 1823, in to_executorch
new_gm_res = p(new_gm)
File ".../torch/fx/passes/infra/pass_base.py", line 46, in __call__
res = self.call(graph_module)
File ".../executorch/exir/passes/__init__.py", line 378, in call
elif _get_overload_schema(target).kind() == SchemaKind.inplace:
File ".../executorch/exir/operator/convert.py", line 88, in _get_overload_schema
native_schema = _pybind_schema_to_native_schema(op_overload._schema)
AttributeError: 'builtin_function_or_method' object has no attribute '_schema'
The same error happens without XnnpackPartitioner (to_edge(ep).to_executorch()).
Versions
ExecuTorch: 1.6.0 (main @ ddb19caa)
PyTorch version: 2.15.0
Is debug build: False
CUDA used to build PyTorch: None
ROCm SDK used to build PyTorch: N/A
HIP used to build PyTorch: N/A
OS: macOS 27.2.1 (arm64)
Clang version: 21.0.0 (clang-2100.4.1.1)
CMake version: version 4.3.1
Python version: 3.11.14 (64-bit runtime)
Python platform: macOS-27.2.1-arm64-arm-64bit
Is CUDA available: False
CPU: Apple M4 Pro
- Vorherrschende Sprache
- Python
- Sterne
- 5.2k
- Forks
- 1.3k
- Ø Merge
- 1 T. 7 Std.
- Gemergte PRs (30 T.)
- 644
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus pytorch/executorch
-
to_edge_transform_and_lower ignores some ops_to_not_decompose requests: multi-output ops, and non-core ops without a decompositionEvtl. vergeben @Eureka-Zhang hat das vor 7 Tagen übernommen. Offenmodule: exir
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
pytorch/executorch#25620 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Qualcomm AI Engine Direct - fp16a8w quantization crashes on layer_normEvtl. vergeben @psiddh hat das vor 21 Tagen übernommen. Offenbug module: qnn partner: qualcomm
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
pytorch/executorch#24434 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement triaged
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 68/100
pytorch/executorch#21640 ·
Maintainer antworten meist innerhalb von 1 Tag
-
quantize_per_channel and dequantize_per_tensor.tensor abort the process on a float32 scaleEvtl. vergeben @AxelNoun hat das heute übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
pytorch/executorch#25873 ·
Maintainer antworten meist innerhalb von 1 Tag
-
XNNPACK INT4 linear returns incorrect per-channel outputs and fails groupwise FP16 on Apple M4 MaxEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenbug module: quantization module: xnnpack
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 43/100
pytorch/executorch#25854 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in pytorch/executorch
Ähnliche Issues
-
Container fails to start when GitHub Releases is unavailable: uv run re-downloads the tvl wheelOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
trezor/trezor-user-env#421 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 91/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
tangentcode/tangentswarm#167 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag