mcabbott / mcabbott/TensorCast.jl

Unable to infer ranges for indices `i`, in deeply nested `r[k][j][i]`

Open
#76 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
142
Forks
12
PR merge metrics
No merged PRs in 30d

Description

Consider the MWE:

```julia
using TensorCast # 0.4.8

r = fill(fill(ones(3), 5), 7)

function f(r)
@cast _[i, j ⊗ k] := r[k].a[j][i]
end
```

Ideally `f(r)` should give a 3 x 35 matrix, but I get
```julia
ERROR: LoadError: unable to infer ranges for indices i
@cast _[i, j ⊗ k] := ((r[k]).a[j])[i]
@ Main REPL[22]:2
Stacktrace:
[1] sizeinfer(store::@NamedTuple{dict::Dict{Any, Any}, assert::Vector{Any}, mustassert::Vector{Any}, seen::Vector{Any}, need::Vector{Any}, top::Vector{Any}, main::Vector{Any}}, call::TensorCast.CallInfo)
@ TensorCast ~/.julia/packages/TensorCast/fctFg/src/macro.jl:1143
[2] findsizes(store::@NamedTuple{dict::Dict{Any, Any}, assert::Vector{Any}, mustassert::Vector{Any}, seen::Vector{Any}, need::Vector{Any}, top::Vector{Any}, main::Vector{Any}}, call::TensorCast.CallInfo)
@ TensorCast ~/.julia/packages/TensorCast/fctFg/src/macro.jl:1092
[3] _macro(exone::Expr, extwo::Nothing, exthree::Nothing; call::TensorCast.CallInfo, dict::Dict{Any, Any})
@ TensorCast ~/.julia/packages/TensorCast/fctFg/src/macro.jl:211
[4] _macro
@ ~/.julia/packages/TensorCast/fctFg/src/macro.jl:154 [inlined]
[5] var"@cast"(__source__::LineNumberNode, __module__::Module, exs::Vararg{Any})
@ TensorCast ~/.julia/packages/TensorCast/fctFg/src/macro.jl:74
in expression starting at REPL[22]:2
```

Is it possible to make this work somehow?

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 running the MWE from the issue with TensorCast 0.4.8 and inspect src/macro.jl around sizeinfer and findsizes, which appear in the stack trace. Trace how ranges are inferred through the nested r[k].a[j][i] expression. Done means the @cast call works and produces the expected 3 × 35 matrix.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.