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

RuntimeError saying statements.inc.h:visit@19 not supported #7378

Closed
Wilbur-Django opened this issue Feb 16, 2023 · 2 comments
Closed

RuntimeError saying statements.inc.h:visit@19 not supported #7378

Wilbur-Django opened this issue Feb 16, 2023 · 2 comments
Assignees

Comments

@Wilbur-Django
Copy link

Wilbur-Django commented Feb 16, 2023

Describe the bug
Taichi a RuntimeError saying that [statements.inc.h:visit@19] Not supported on a very simple case.

To Reproduce

import taichi as ti

ti.init(default_fp=ti.f32)

@ti.data_oriented
class A:
    @ti.kernel
    def f(self) -> float:
        return 1.0


a = A()
print(a.f())  # This works
loss = ti.field(dtype=ti.f32, shape=(), needs_grad=True)
with ti.ad.Tape(loss):
    # loss[None] = 1.0  # This also works
    loss[None] = a.f() # This would cause a RuntimeError

print(loss[None])

Log/Screenshots

$ python my_sample_code.py
[Taichi] version 1.3.0, llvm 15.0.4, commit 0f25b95e, linux, python 3.9.16
[Taichi] Starting on arch=x64
1.0
[E 02/16/23 15:55:43.467 59153] [statements.inc.h:visit@19] Not supported.


Traceback (most recent call last):
  File "/home/user/my_sample_code.py", line 17, in <module>
    loss[None] = a.f() # This would cause a RuntimeError
  File "/home/user/miniconda3/envs/taichi/lib/python3.9/site-packages/taichi/ad/_ad.py", line 214, in __exit__
    self.grad()
  File "/home/user/miniconda3/envs/taichi/lib/python3.9/site-packages/taichi/ad/_ad.py", line 239, in grad
    func.grad(*args)
  File "/home/user/miniconda3/envs/taichi/lib/python3.9/site-packages/taichi/lang/kernel_impl.py", line 872, in __call__
    return self.runtime.compiled_functions[key](*args)
  File "/home/user/miniconda3/envs/taichi/lib/python3.9/site-packages/taichi/lang/kernel_impl.py", line 797, in func__
    raise e from None
  File "/home/user/miniconda3/envs/taichi/lib/python3.9/site-packages/taichi/lang/kernel_impl.py", line 794, in func__
    t_kernel(launch_ctx)
RuntimeError: [statements.inc.h:visit@19] Not supported.

Additional comments
The RuntimeError message is extremely confusing as it barely provides any information as to why the error happens. The error happens on both taichi 1.4.1 and 1.3.0.

@erizmr
Copy link
Contributor

erizmr commented Feb 17, 2023

Thanks for reporting this. The RuntimeError is raised because the return statement is not properly handled by the autodiff. Have opened a PR for fixing it.

erizmr added a commit that referenced this issue Feb 23, 2023
@Wilbur-Django
Copy link
Author

Thanks for fixing it. Closing it for now.

@github-project-automation github-project-automation bot moved this from Todo to Done in Taichi Lang Apr 16, 2023
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants