Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Vector field assignment error in taichi v1.7 #8525

Open
Ives0721 opened this issue May 2, 2024 · 0 comments
Open

[BUG] Vector field assignment error in taichi v1.7 #8525

Ives0721 opened this issue May 2, 2024 · 0 comments

Comments

@Ives0721
Copy link

Ives0721 commented May 2, 2024

Description

When do assignment to a VectorField f = ti.Vector.field(2, float, shape=(2, 1)) (i.e. f[i,j][k] = 2.0), f[0,0][0] cannot be assigned right value.

To Reproduce
Here's a sample_code.py to reproduce the bug.

import taichi as ti

ti.init(arch=ti.gpu)

f = ti.Vector.field(2, float, shape=(2, 1))
feq = ti.Vector.field(2, float, shape=(2, 1))

@ti.kernel
def foo():
    f[0, 0][0] = 1.0            # The bug at here
    f[0, 0][1] = 2.0
    f[1, 0][0] = 3.0
    f[1, 0][1] = 4.0

    print('f[0, 0] =', f[0, 0])
    print('f[1, 0] =', f[1, 0])

    feq[0, 0] = f[0, 0]
    feq[1, 0] = f[1, 0]

    print('feq[0, 0] =', feq[0, 0])
    print('feq[1, 0] =', feq[1, 0])

    f[0, 0][1] = 5.0

    print('f[0, 0] =', f[0, 0])
    print('feq[0, 0] =', feq[0, 0])


foo()

Log

When in TaiChi v.1.7, wrong result shows like this.

$ python sample_code.py
[Taichi] version 1.7.1, llvm 15.0.1, commit 0f143b2f, win, python 3.10.14
[Taichi] Starting on arch=cuda
f[0, 0] = [0.000000, 2.000000]  
f[1, 0] = [3.000000, 4.000000]  
feq[0, 0] = [0.000000, 2.000000]
feq[1, 0] = [3.000000, 4.000000]
f[0, 0] = [0.000000, 5.000000]  
feq[0, 0] = [0.000000, 2.000000]

When in TaiChi v.1.6, correct result shows like this:

$ python sample_code.py
[Taichi] version 1.6.0, llvm 15.0.1, commit f1c6fbbd, win, python 3.9.16
[Taichi] Starting on arch=cuda
f[0, 0] = [1.000000, 2.000000]  
f[1, 0] = [3.000000, 4.000000]  
feq[0, 0] = [1.000000, 2.000000]
feq[1, 0] = [3.000000, 4.000000]
f[0, 0] = [1.000000, 5.000000]  
feq[0, 0] = [1.000000, 2.000000]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Untriaged
Development

No branches or pull requests

1 participant