[Type] Tensor 4: Add qd.tensor_annotation(backend) helper#524
Draft
hughperkins wants to merge 7 commits intohp/tensor-stork-3from
Draft
[Type] Tensor 4: Add qd.tensor_annotation(backend) helper#524hughperkins wants to merge 7 commits intohp/tensor-stork-3from
hughperkins wants to merge 7 commits intohp/tensor-stork-3from
Conversation
Returns the kernel-argument annotation appropriate for a given backend: qd.template() instance for FIELD, qd.types.ndarray() instance for NDARRAY. Mirrors the Genesis V_ANNOTATION = qd.types.ndarray() if use_ndarray else qd.template pattern as a single first-class call so users can pick a backend in one place and reuse the annotation across kernels. Adds: - tensor_annotation(backend) in _flexible.py. - Re-export through __init__.py. - 6 tests: return type per backend, invalid-backend rejection, IntEnum coercion, end-to-end kernel use on each backend. - "Annotating kernel arguments" section in the user guide. All tests pass; sphinx build clean.
hughperkins
commented
Apr 20, 2026
| @@ -102,6 +102,40 @@ m = qd.tensor_mat(2, 2, qd.f32, shape=(3,)) | |||
| These match the existing `qd.Vector.*` / `qd.Matrix.*` factories one-for-one; | |||
| `qd.tensor_vec` / `qd.tensor_mat` simply add the per-tensor `backend=` knob. | |||
|
|
|||
| Subsequent releases will add a `qd.tensor_annotation(backend)` helper for | |||
| kernel argument typing, and a `layout=` keyword for per-tensor physical-memory | |||
| ## Annotating kernel arguments: `qd.tensor_annotation` | |||
Collaborator
Author
There was a problem hiding this comment.
maybe qd.Tensor?
241b28a to
83a0456
Compare
2743267 to
e1540b7
Compare
Drops the 'flexible' prefix from filenames and identifiers introduced in this branch series so the user-visible names are simply 'tensor'. Also strips PR-N back-references that will be meaningless once these PRs land. Touches only files owned by this series (no changes to external/ or unrelated tests).
…r-stork-4 Made-with: Cursor # Conflicts: # python/quadrants/__init__.py
…ion to API test - Use pylint disable comments on the late imports inside `tensor_annotation`, matching the style used by the sibling dispatchers. - Add `tensor_annotation` to the expected public-API symbol list in `tests/python/test_api.py`. Made-with: Cursor
Use _types.template() (re-exported via quadrants.types) instead of a separate `from quadrants.types.annotations import template` so the line fits within ruff's import line-length and doesn't get auto-wrapped into a form that misplaces the # pylint: disable=import-outside-toplevel comment. Made-with: Cursor
…r-stork-4 # Conflicts: # python/quadrants/_tensor.py # tests/python/test_api.py
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.
Returns the kernel-argument annotation appropriate for a given backend: qd.template() instance for FIELD, qd.types.ndarray() instance for NDARRAY.
Mirrors the Genesis V_ANNOTATION = qd.types.ndarray() if use_ndarray else qd.template pattern as a single first-class call so users can pick a backend in one place and reuse the annotation across kernels.
Adds:
All tests pass; sphinx build clean.
Issue: #
Brief Summary
copilot:summary
Walkthrough
copilot:walkthrough