taichi
taichi copied to clipboard
Controllable precision when printing
Concisely describe the proposed feature
import taichi as ti
ti.init()
@ti.kernel
def foo():
a = 1.23456
print(f"{a:.2f}")
foo()
The user would expect 1.23
.
Describe the solution you'd like (if any) IIRC Taichi stores the numbers in a buffer and format them on the host. Perhaps we should allow a richer syntax?
Also note that we need support for vector/matrix and even structs.
Additional comments Not sure if this feature request was already raised somewhere...
FYI this feature can be added without too much hassel since it's supported on both llvm and spirv based backends. reference:
- https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/master/docs/debug_printf.md
- https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/index.html This issue can be a pretty good get started issue for a new contributor who are interested in taichi codegen part. cc @gingerkidney
Adding this to v1.2.0 milestone so that we can get back to it in the future if no one picks it up before that.
cc: @dream189free