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

[aot] A ti::Kernel should support inputs of different data types. #6456

Open
YuCrazing opened this issue Oct 27, 2022 · 0 comments
Open

[aot] A ti::Kernel should support inputs of different data types. #6456

YuCrazing opened this issue Oct 27, 2022 · 0 comments
Assignees
Labels
feature request Suggest an idea on this project

Comments

@YuCrazing
Copy link
Contributor

YuCrazing commented Oct 27, 2022

Concisely describe the proposed feature

As mentioned in #6432 , when exporting a kernel with multiple data types, the behaviour of ti::Kernel on the C++ side is unexpected. The reason is that the ti::Kernel does not support inputs of different data types.

Since a kernel on the python side is able to take different data types, the ti::Kernel on the C++ side should have the same behaviour.

Thus, an expected behaviour should be:

python

import taichi as ti

ti.init(arch=ti.vulkan)

@ti.kernel
def k_test(arr: ti.types.ndarray(field_dim=1)):
    arr[2] = arr[0] + arr[1]


a = ti.ndarray(ti.f32, 10)
b = ti.ndarray(ti.i32, 10)

mod = ti.aot.Module(ti.vulkan)

# Serialize a function instance: `k_test_f32`
mod.add_kernel(k_test,
                template_args={
                    "arr": a,
                })

# Serialize a function instance: `k_test_i32`
mod.add_kernel(k_test,
                template_args={
                    "arr": b,
                })

mod.save("aot_files/", "")

c++

// ...

auto a = allocate_ndarray<float>(...);
auto b = allocate_ndarray<int>(...);

ti::Kernel k_test = load_kernel("k_test");

k_test[0] = a;
k_test.launch(); // This should call function `k_test_f32`.

k_test[0] = b;
k_test.launch(); // This should call function `k_test_i32`.

cc @ailzhang

@YuCrazing YuCrazing added the feature request Suggest an idea on this project label Oct 27, 2022
@taichi-gardener taichi-gardener moved this to Untriaged in Taichi Lang Oct 27, 2022
@YuCrazing YuCrazing added this to the v1.3.0 milestone Oct 27, 2022
@jim19930609 jim19930609 self-assigned this Oct 27, 2022
@neozhaoliang neozhaoliang moved this from Untriaged to Todo in Taichi Lang Oct 28, 2022
@jim19930609 jim19930609 modified the milestones: v1.3.0, v1.4.0 Nov 25, 2022
@ailzhang ailzhang modified the milestones: v1.4.0, v1.5.0 Jan 4, 2023
@ailzhang ailzhang modified the milestones: v1.5.0, v1.6.0 Feb 17, 2023
@feisuzhu feisuzhu modified the milestones: v1.6.0, v1.7.0 May 11, 2023
@jim19930609 jim19930609 modified the milestone: v1.7.0 Oct 25, 2023
@jim19930609 jim19930609 removed this from the v1.7.0 milestone Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Suggest an idea on this project
Projects
Status: Todo
Development

No branches or pull requests

4 participants