Conversation
yeetypete
added this pull request to stack #181
September 13, 2026 00:23
yeetypete
force-pushed
the
feat/add-tensor-shape-annotations
branch
from
September 13, 2026 10:53
fb53acd to
b2e186d
Compare
yeetypete
force-pushed
the
feat/add-tensor-shape-annotations
branch
from
September 13, 2026 21:30
b2e186d to
74f30d2
Compare
yeetypete
force-pushed
the
feat/add-tensor-shape-annotations
branch
from
September 13, 2026 21:31
74f30d2 to
291695b
Compare
yeetypete
force-pushed
the
feat/add-tensor-shape-annotations
branch
from
September 13, 2026 21:43
291695b to
5b2f0a4
Compare
yeetypete
marked this pull request as draft
September 14, 2026 06:12
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Annotate tensor shapes across vision3d with Pyrefly's shape types, e.g.
points: "Tensor[[N, int]]". Additionally:shape_extensionsnames underTYPE_CHECKING, so Python 3.12 and 3.13 never evaluate a shape type at runtime.Int, e.g.voxelize(..., max_points_per_voxel: "Int[M]" = 32)._BoxData,_MetricData, andCameraCropgeneric over the dimension their fields share, and type the KITTI calibration dict.Tensor.Tand.item()on one-element tensors, with targeted# pyrefly: ignorecomments instead of rewriting the code.Tensorto torch, accept dimension names, and link vision3d names in the gallery examples to our own API pages.CONTRIBUTING.md.Although we introduce quite a few
pyrefly: ignores here our goal should still be getting this number down to 0. We'll need to make some contributions upstream to the pyrefly torch stubs to make this happen.Pyrefly issues encountered (LLM summary)
Stub signatures that lose or misreport shapes:
Tensor.Tis typedSelf, which is wrong for non-square matrices.mT,mH, andHare missing. Cause of the ignores inproject_to_image.Tensor.__iter__yields bareTensor, so iterating orzip-ing shaped tensors loses their shapes (accumulate_sweeps).boxes[order], falls through to the bare__getitem__overload (NMS, mAP, point sampling).new_emptyand the othernew_*constructors take*size: int, dropping symbolic sizes (both fake kernels in_meta_registrations).torch.stackover alist[Tensor[[K]]]hits theSequence[Any] -> Tensorfallback. Only tuples are tracked.torch.wherereturns bareTensorin all overloads, even with a shaped condition.Tensor.argsortis not defined as a method and resolves toUnknown.torch.randpermis intentionally shapeless. Withn: Int[N]it could return[N].torch.linalg.normwithdim=returns bare.Any, so every mask expression andtorch.where(x > 0, ...)is bare.Tensor[[*Bs, 4, 4]] @ Tensor[[4, 4]], returns bare.Tensor.itemrequires rank 0, while PyTorch accepts any one-element tensor. Source of the ignores in the ops tests.Checker and tooling:
intdimension is fully gradual:Tensor[[int, 6]]is accepted whereTensor[[8, 6]]is required. Only the rank and the other slots are checked._BoxData.scorecannot be typed.pyrefly coveragetreats bareTensoras fully typed andpyrefly inferdrops hints with symbolic dimensions. Coverage was measured by post-processing--report-trace.Assisted-by: AI