A `tensor_view_2d` with run-time extents accepts any declared shape
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 14
- Forks
- 2
- Avg merge
- 12h 42m
- Merged PRs (30d)
- 61
Description
Vx#397 made the checker compare a declared tensor shape against the computed one. A view whose extents are literals is compared:
let w = unsafe { tensor_view_2d(pw, 4, 3) };
let bad : Tensor<f32, [9, 9]> = w; // Error: Type mismatch in variable declaration 'bad'
A view whose extents are run-time values is not:
let n = unsafe { vx_env_args_count() };
let w = unsafe { tensor_view_2d(pw, n, 3) };
let bad : Tensor<f32, [9, 9]> = w; // accepted, no diagnostic
The second exits 0. This is the same vacuity Vx#397 closed for matmul: when one side carries no comparable dims, is_assignable skips the comparison rather than refusing it, so the annotation is checked against nothing and every later use that trusts [9, 9] is lied to.
Two shapes it could take: reject the declaration outright when the source's dims are not statically known, or accept it as a claim and emit the run-time extent check the declaration then justifies. The first is what a let annotation means elsewhere; the second is what unsafe already means for this call, whose extents are the caller's claim about the pointer either way.
Related: Vx#397 (the same hole for matmul), and the note in Vx#391 about which destinations can be filled in place.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the is_assignable path described in this issue and compare it with the matmul fix from Vx#397. Reproduce the runtime-extents example and determine whether declarations should reject unknown dimensions or emit a runtime check; done means the annotation no longer silently accepts an unchecked shape.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100