taichi-dev/taichi

Reverse NDRange support

Open

#4.379 aberto em 24 de fev. de 2022

Ver no GitHub
 (9 comments) (4 reactions) (1 assignee)C++ (2.384 forks)batch import
feature requestgood first issuewelcome contribution

Métricas do repositório

Stars
 (28.195 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

There comes one special case which requires a reverse loop, so I used “ti.ndrange(8,0)” instead. However, the reverse loop just didn’t work with zero warnings or errors (I have no idea whether ti.ndrange can be used to loop in reverse order at that time) Perhaps a warning message can be given when n1 > n2 in ti.ndrange((n1,n2))

import taichi as ti
ti.init(arch=ti.gpu, debug=True, default_fp=ti.f64)

x = ti.field(ti.f64, shape=(10))

@ti.kernel
def main():
    x[9] = 1.0
    for i in ti.ndrange((8,0)):
        x[i] = 2.0 * x[i+1]
        print(x[i])    #print nothing

main()

Guia do colaborador