vx-lang / vx-lang/Vx

A `tensor_view_2d` with run-time extents accepts any declared shape

Open
#419 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug core-lang
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.