taichi-dev / taichi

Productive, portable, and performant GPU programming in Python.
https://taichi-lang.org
Apache License 2.0
25.37k stars 2.27k forks source link

Support type specification and polymorphism in internal functions #4035

Open re-xyr opened 2 years ago

re-xyr commented 2 years ago

It will be better if we are able to implement more operations (unary/binary ops) as internal functions instead of hard-coded operations. Because these operations are polymorphic on argument types (size & int/float) and perform implicit casts, we need to extend the functionalities of internal functions to allow type specification and polymorphism.

(cc @strongoier)

re-xyr commented 2 years ago

Some points I gathered till now:

In all the current taichi typechecking is a quite atypical one. Some expressions (especially, non-primitive ones) don't even have types and maybe we should fix that first.

re-xyr commented 2 years ago

Hot take: If we're unable to give an Expr a type, it probably should not be an Expr at all, but some separate construct