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

Invalid type annotation exception #6144

Open
gcesars opened this issue Sep 22, 2022 · 1 comment
Open

Invalid type annotation exception #6144

gcesars opened this issue Sep 22, 2022 · 1 comment
Assignees
Labels
potential bug Something that looks like a bug but not yet confirmed

Comments

@gcesars
Copy link

gcesars commented Sep 22, 2022

Describe the bug
I am getting invalid type annotation no matter how I write my kernel.

To Reproduce
I got the example in the FAQ section (https://docs.taichi-lang.org/docs/faq), and it gives me:

taichi.lang.exception.TaichiSyntaxError: Invalid type annotation (argument 0) of Taichi kernel: ti.types.ndarray()

I even changed from python 3.10 to 3.9 and the exactly same exception persists.

import taichi as ti
import numpy as np
ti.init(arch=ti.cpu)
x = ti.field(ti.i32, shape=3)
array = np.array([10, 20, 30])
@ti.kernel
def test(arr: ti.types.ndarray()):
    for i in range(3):
        x[i] = arr[i]
test(array)
@gcesars gcesars added the potential bug Something that looks like a bug but not yet confirmed label Sep 22, 2022
@taichi-gardener taichi-gardener moved this to Untriaged in Taichi Lang Sep 22, 2022
@gcesars
Copy link
Author

gcesars commented Sep 22, 2022

Lucky!
While testing again, I by mistake, removed the first line of the code:

from __future__ import annotations

it now works!
looks like there is a conflict in how taichi interprets type hints with annotations enabled.

@turbo0628 turbo0628 moved this from Untriaged to Backlog in Taichi Lang Sep 23, 2022
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: Backlog
Development

No branches or pull requests

2 participants