Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[tensor-shapes] torch.lerp rejects tensor weights and omits their broadcast shape

Chiusa Adatta ai principianti
#5,360 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

  • #5371 di @mangeshraut712 — chiusa senza merge

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, rust

Direzione di ricerca

L’issue rimanda a tensor-shapes/pyrefly-torch-stubs/torch-stubs/__init__.pyi vicino alla riga 3689. Leggi la firma di torch.lerp e la sua espressione di shape, poi esegui il repro.py fornito con pyrefly check. Il lavoro è completato quando il peso Tensor viene accettato e la shape inferita del risultato include la sua shape di broadcast, così che l’esempio venga verificato con shape (3, 2).

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

pytorch tensor-shapes
Describe the Bug

torch.lerp accepts a Tensor as its weight argument. The weight can also expand the result shape through broadcasting.

The shape stub only accepts float and computes the result shape from input and end.

Minimal reproduction

Save this code as repro.py. Create an empty pyrefly.toml next to it.

import torch

start = torch.zeros(2)
end = torch.ones(2)
weight = torch.full((3, 1), 0.5)
result = torch.lerp(start, end, weight)
assert result.shape == (3, 2)
assert torch.equal(result, torch.full((3, 2), 0.5))

Run:

python repro.py
pyrefly check repro.py

The runtime assertions pass and the process exits with code 0. The type check reports the errors below.

Expected behavior

Accept Tensor weights. Include the weight shape when computing the broadcast result. In this example, the result shape is (3, 2).

Actual behavior
repro.py:6:33: Argument `Tensor[[3, 1]]` is not assignable to parameter `weight` with type `float` in function `torch.lerp` [bad-argument-type]
Environment and current source
  • Python 3.13.13 on Linux.
  • Pyrefly 1.4.0.
  • pyrefly-torch-stubs==1.4.0.
  • PyTorch 2.13.0+cu126.

I also reproduced this with the stub sources from main at e5f077bcb2897dad3d168c45b9b64271fca94db6. The local Pyrefly binary reports pyrefly 1.4.0. I selected the checkout stub package directories with --site-packages-path. The diagnostics above use those current source files.

Current stub source. The current signature declares weight: float and returns Tensor[broadcast(Shape, OtherShape)]. The Tensor-weight case needs a third shape.

Lingua principale
Rust
Stelle
7.2k
Fork
578
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di facebook/pyrefly

Tutte le issue di facebook/pyrefly

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.