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

[bug] Allow StructType as type hint to ti.func #6964

Merged
merged 1 commit into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions python/taichi/lang/kernel_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ def extract_arguments(self):
pass
elif isinstance(annotation, MatrixType):
pass
elif isinstance(annotation, StructType):
pass
elif id(annotation) in primitive_types.type_ids:
pass
elif isinstance(annotation, template):
Expand Down
18 changes: 18 additions & 0 deletions tests/python/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,24 @@ def test_error():
test_error()


@test_utils.test(debug=True)
def test_func_struct_arg():
@ti.dataclass
class C:
i: int

@ti.func
def f(c: C):
return c.i

@ti.kernel
def k():
c = C(i=2)
assert f(c) == 2

k()


@test_utils.test(arch=[ti.cpu, ti.cuda])
def test_real_func_matrix_arg():
@ti.experimental.real_func
Expand Down