mcabbott / mcabbott/Tullio.jl

Wrong result when the same array appears in both sides of =

Open
#151 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

parsing
Dominant language
Julia
Stars
668
Forks
30
PR merge metrics
No merged PRs in 30d

Description

When the same array appears in both side of =, the result from Tullio is strange

using Tullio
a = [1,2]
b = [1 2;3 4]
a = b * a
println(a) # [5,11]
a = [1,2]
@tullio a[x] = b[x,y] * a[y]
println(a) # [5,23]

It seems only the first component is right. When calculate the second componet, the first component is already updated to 5, and the second component is calculated by 3*5+4*2=23.
When there are some complicated operations which have to be seprated into several steps, to avoid extra allocation, I prefer to use the same array repeatedly, and sometimes wrong results may occur like above.

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 with the provided Julia reproducer and inspect the expansion generated by @tullio for alias handling. Confirm the behavior with both the regular multiplication and in-place @tullio examples; done means the in-place result matches [5,11] rather than using an already updated element.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.