Replies: 2 comments
-
Same for the ndarray |
Beta Was this translation helpful? Give feedback.
0 replies
-
I much prefer the 2nd option, i.e., we don't add IMO it doesn't make that much sense to have |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm sure this has been discussed previously, but I'd like to throw this out again and track it in a single place.
Currently we are defining a tensor (e.g.
ti.Vector
) field using the following syntax:There are several issues I can see with this approach:
.field
method.ti.Vector
. i.e.,3
andti.f32
defines a vec3 of typefloat32
. Ideally, we can write something liketi.Vector(dtype=ti.f32, n=3)
. This is actually already the case when defining a composite struct type, see https://docs.taichi.graphics/lang/articles/basic/type#compound-typesAn alternative solution is to just adopt what we are doing in step 2, and push it further during the field definition. For example:
This provides a consistent approach to define Taichi fields.
The downside is that we sort of lose the opportunity to control the APIs different kinds of fields can support. Concretely, we can return different field impls for
ti.field
andti.Vector.field
, namelyScalarField
andVectorField
, respectively. It only makes sense forVectorField
to provide a method for indexing into each individual component of the vector. If these are all unified into a singleField
type, thenField
need to provide the superset of all the APIs different field type should support.Beta Was this translation helpful? Give feedback.
All reactions