Skip to content

Incorrect running result #8745

@xiaobo-lab

Description

@xiaobo-lab

Describe the bug

a little field size changed make a function incorrect. These behaviors are really strange.

Code

import taichi as ti

ti.init(ti.metal)

input_ = ti.field(ti.f32, shape=(3, 2, 2))
index = ti.field(ti.u16, shape=(3, 2, 2, 3))

# if the shape of shape_field is (4,),result is [0 0 6].but if the shape is (3,),result is [0 0 0]
shape_field = ti.field(ti.u16, shape=(3,))

# initial element
shape_field[2] = 6

@ti.kernel
def test():
    # If the following two lines of code are not executed,result alway is [0 0 6].
    for input_i in ti.grouped(input_):
        input_[input_i] = 3

    for input_i in ti.grouped(input_):
        for shape_i in ti.ndrange(3):
            index[*input_i, shape_i] = shape_field[shape_i]

test()
# print result
print(index.to_numpy()[0, 1, 1])

environment

App M2 Pro 16GB
Python3.12
taichi version: 1.7.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Untriaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions