@Rullec @yuanming-hu Continue our discussion in: https://github.com/taichi-dev/taichi/issues/1156#issuecomment-658532635
The new naming mechanism can be formulated in these 3 rules:
ti.field(dtype, ...) to allocate a global scalar field (tensors)ti.Vector.field/ti.Matrix.field to allocate global vector/matrix fields (tensors)ti.Vector and ti.Matrix for local variableIn one word, anything involved in the name field must be a global stuff, and all others must be some local things.
The difference between old and new names are exposed below, in the following working plan.
ti.field, ti.Vector.field, ti.Matrix.fieldSimply renaming ti.var to ti.field should work.
In fact we already have ti.Matrix.var, so please rename that too :)
dt -> dtype as arguement by-the-wayBtw, the argument dt should be renamed to dtype, i.e. ti.field(dtype=ti.f32, shape=()).
ti.var, ti.Vector.var, ti.Matrix.varWe don't want to fully abandon ti.var support yet, so let's only raise a warning before the API-breaking v0.7.0.
Let's make a dummy ti.var with simply redirect to corresponding field function:
def var(...):
return field(...)
And please use the @deprecated decorator, it will raise a warning when the decorated function is being called, see ti.Matrix.transposed for usage example.
ti.Vector, ti.Matrix usage for declaring global matrix fields.We may not use @deprecated since ti.Vector is already for local matrix variables... So please use ti.warning in if-elif's instead.
Simply s/\.var/\.field/g should works. Relative trivial, compare to the next one:
This could be the most heavy-mind task in this issue, note that you can't simply s/tensor/field/g because:
...
We don't want to rename these:
NOTE: "tensor" -> "field" should be put in a separate PR for easy-to-review.
If someone is super familiar with sed and awk on how this can be done, please go ahead :)
So that new students don't get puzzled when looking into old posts on zhihu that using the term "Taichi tensor".
@deprecated functions in v0.7.0Let's use this #1500 and delete my #1501!
I personnaly have 2 advice
so that the statement can be more clear?
HDYT? I will delete #1501 after your response
Please let me begin to explore a proper way for accomplishing part 2.3 and 2.4, when you are doing work on 2.1 - 2.2
HDYT?
Yes, please go ahead with 2.4 first :) 2.3 depends on 2.1 and need to be done later.
Update:
2.4 has been mostly finished. Though I'm still proofreading it till I can personnally confirm that here is not obvious error.
Is it worth to have a PR or draft PR now? Or maybe you have another schedule?
Update:
2.4 has been mostly finished. Though I'm still proofreading it till I can personnally confirm that here is not obvious error.Is it worth to have a PR or draft PR now? Or maybe you have another schedule?
Great! Please open a draft PR now, I have time to review given that @yuanming-hu is still reviewing my stale PRs :)
Hi all!
Is the only left stuff is fully deprecated ti.var, right? Is there anything We need to do on this issue?
Is the only left stuff
Yes, we can close this issue once we finally obsolete ti.var, i.e. calling ti.var() will result in an error after that point.
Now we need to discuss about when to do the obsolete point. v0.7.0? v0.7.5? v0.8.0? @yuanming-hu Thoughts?
@archibate
Hey there. There is no warning about the "ti.var" is going to be deprecated when I call "ti.var".
import taichi as ti
p = ti.var(ti.i32, shape=())
in [Taichi] version 0.6.28, llvm 10.0.0, commit a58a9af7, linux, python 3.7.7, it compiles and says nothing about the ti.var has been sneakily replaced by ti.field. I relized it only when I looked through the documents.
@archibate
Hey there. There is no warning about the "ti.var" is going to be deprecated when I calls "ti.var".import taichi as ti p = ti.var(ti.i32, shape=())in
[Taichi] version 0.6.28, llvm 10.0.0, commit a58a9af7, linux, python 3.7.7, it compiles and says nothing about theti.varhas been sneakily replaced byti.field. I relized it only when I looked through the documents.
Thank for reporting! But I can't reproduce this issue on my end:
[bate@archit ~]$ p a.py
[Taichi] mode=release
[Taichi] preparing sandbox at /tmp/taichi-4vpgcotz
[Taichi] version 0.6.29, llvm 10.0.0, commit b63f6663, linux, python 3.8.3
a.py:5: DeprecationWarning: ti.var is deprecated, please use ti.field instead
ti.var 已被废除,请使用 ti.field 来替换
p = ti.var(ti.i32, shape=())
Does upgrading to 0.6.29 solve the issue?
@archibate oops! Currently the taichi is still 0.6.28 in Douban source. The mirror has yet synced with the upstream. Thanks for you answer.
Most helpful comment
Yes, please go ahead with 2.4 first :) 2.3 depends on 2.1 and need to be done later.