{"categories":[{"label":"Artificial Intelligence","url":"https://skillfed.io/packages/category/scientific-engineering-artificial-intelligence/8"},{"label":"Information Analysis","url":"https://skillfed.io/packages/category/scientific-engineering-information-analysis/3"},{"label":"Mathematics","url":"https://skillfed.io/packages/category/scientific-engineering-mathematics/3"}],"enrichment":{"capability":"Adds type annotations for PyTorch tensor shape, dtype, layout, and dimension names with optional runtime checking via typeguard.","skillfed_tags":["pytorch","type-hints","tensor-validation"],"use_cases":["Document tensor shapes in neural network functions to prevent shape mismatch bugs during model development.","Validate batch dimensions and channel sizes at runtime during training to catch data pipeline errors early.","Enforce consistent dimension naming across a codebase to improve code clarity and reduce shape-related debugging.","Test tensor contracts in pytest with automatic typeguard patching to catch shape violations in unit tests.","Combine with typeguard's import hook to automatically check all tensor operations in a module without manual decorators."],"what_it_does":"torchtyping lets you annotate PyTorch tensors with their expected shape, dtype, layout, and dimension names directly in function signatures. Instead of writing comments like `# x has shape (batch, hidden_state)`, you write `x: TensorType[\"batch\", \"hidden_state\"]`, making tensor contracts explicit and machine-readable. When typeguard is installed and enabled, these annotations are checked at runtime to catch shape mismatches and dtype errors early.\n\nThe package integrates with typeguard for optional runtime validation and pytest for test-time checking, so you can enforce tensor contracts without runtime overhead in production. It supports flexible shape specifications (exact sizes, named dimensions, variable batch dimensions with `...`), multiple dtype checks, and extensible custom validation rules. However, the author now recommends jaxtyping for new projects, citing better static type checker compatibility.","worth_installing":"Yes, if you are actively developing PyTorch models and want runtime shape validation. The low install friction and permissive license make adoption straightforward. However, be aware that the package is aging and the author recommends jaxtyping for new projects due to better static type checker support. If you need static type checking or are starting a new project, consider jaxtyping instead; if you have an existing codebase using torchtyping or prefer runtime-only validation, it remains functional."},"id":"torchtyping","links":{"html":"https://skillfed.io/packages/torchtyping","md":"https://skillfed.io/packages/torchtyping.md","pypi":"https://pypi.org/project/torchtyping/"},"maintenance":{"status":"aging"},"meta":{"latest_release":"2024-08-01","license_spdx":null,"license_treatment":"permissive","name":"torchtyping","python_support":"supports_current","summary":"Runtime type annotations for the shape, dtype etc. of PyTorch Tensors."},"popularity":{"monthly_downloads":186194,"position":9992,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"0.1.5"}
