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

Texture structured-for doesn't work with AOT #6518

Closed
PENGUINLIONG opened this issue Nov 4, 2022 · 0 comments · Fixed by #6536
Closed

Texture structured-for doesn't work with AOT #6518

PENGUINLIONG opened this issue Nov 4, 2022 · 0 comments · Fixed by #6536
Assignees
Labels
potential bug Something that looks like a bug but not yet confirmed

Comments

@PENGUINLIONG
Copy link
Member

Describe the bug
Writing to pixels iterating in the outermost loop doesn't results in any effective writes.

To Reproduce
Please post a minimal sample code to reproduce the bug.
The developer team will put a higher priority on bugs that can be reproduced within 20 lines of code. If you want a prompt reply, please keep the sample code short and representative.

import argparse
import os

import taichi as ti

parser = argparse.ArgumentParser()
parser.add_argument("--arch", default="vulkan", type=str)
args = parser.parse_args()

curr_dir = os.path.dirname(os.path.realpath(__file__))

if args.arch == "vulkan":
    arch = ti.vulkan
else:
    assert False
ti.init(arch=arch)

n = 320
canvas = ti.ndarray(dtype=ti.f32, shape=(n * 2, n))


@ti.func
def complex_sqr(z):
    return ti.Vector([z[0]**2 - z[1]**2, z[1] * z[0] * 2])


@ti.kernel
def fractal(t: ti.f32, canvas: ti.types.rw_texture(num_dimensions=2,
                                                   num_channels=1,
                                                   channel_format=ti.f32,
                                                   lod=0)):
-    for i, j in canvas: # doesn't work
+    for i, j in ti.ndrange(640, 320): # works
        c = ti.Vector([-0.8, ti.cos(t) * 0.2])
        z = ti.Vector([i / n - 1, j / n - 0.5]) * 2
        iterations = 0
        while z.norm() < 20 and iterations < 50:
            z = complex_sqr(z) + c
            iterations += 1

        color = 1 - iterations * 0.02
        canvas.store(ti.Vector([i, j]), ti.Vector([color, color, color, 1.0]))


sym_t = ti.graph.Arg(ti.graph.ArgKind.SCALAR,
                     "t",
                     ti.f32,
                     element_shape=())
sym_canvas = ti.graph.Arg(ti.graph.ArgKind.RWTEXTURE,
                          'canvas',
                          channel_format=ti.f32,
                          shape=(n * 2, n),
                          num_channels=1)

gb = ti.graph.GraphBuilder()
gb.dispatch(fractal, sym_t, sym_canvas)
graph = gb.compile()

mod = ti.aot.Module(ti.vulkan)
mod.add_graph('fractal', graph)

save_dir = os.path.join(curr_dir, "fractal")
os.makedirs(save_dir, exist_ok=True)
mod.save(save_dir, "fractal")
print('AOT done')
@PENGUINLIONG PENGUINLIONG added the potential bug Something that looks like a bug but not yet confirmed label Nov 4, 2022
@taichi-gardener taichi-gardener moved this to Untriaged in Taichi Lang Nov 4, 2022
@lin-hitonami lin-hitonami moved this from Untriaged to In Progress in Taichi Lang Nov 4, 2022
@ailzhang ailzhang assigned ailzhang and unassigned jim19930609 Nov 7, 2022
ailzhang pushed a commit to ailzhang/taichi that referenced this issue Nov 7, 2022
Fixes taichi-dev#6518

We should handle graph args based on their symbolic_arg type instead of
runtime type.
ailzhang pushed a commit to ailzhang/taichi that referenced this issue Nov 7, 2022
Fixes taichi-dev#6518

We should handle graph args based on their symbolic_arg type instead of
runtime type.
ailzhang pushed a commit to ailzhang/taichi that referenced this issue Nov 7, 2022
Fixes taichi-dev#6518

We should handle graph args based on their symbolic_arg type instead of
runtime type.
ailzhang added a commit that referenced this issue Nov 9, 2022
Fixes #6518

We should handle graph args based on their symbolic_arg type instead of
runtime type.

Issue: #

### Brief Summary
Repository owner moved this from In Progress to Done in Taichi Lang Nov 9, 2022
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
Fixes taichi-dev#6518

We should handle graph args based on their symbolic_arg type instead of
runtime type.

Issue: #

### Brief Summary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential bug Something that looks like a bug but not yet confirmed
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants