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

Controllable precision when printing #5949

Closed
yuanming-hu opened this issue Sep 1, 2022 · 2 comments
Closed

Controllable precision when printing #5949

yuanming-hu opened this issue Sep 1, 2022 · 2 comments
Assignees
Labels
feature request Suggest an idea on this project welcome contribution
Milestone

Comments

@yuanming-hu
Copy link
Member

yuanming-hu commented Sep 1, 2022

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...

@ailzhang
Copy link
Contributor

FYI this feature can be added without too much hassel since it's supported on both llvm and spirv based backends.
reference:

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.

@jim19930609 jim19930609 modified the milestones: v1.2.0, v1.3.0 Oct 18, 2022
@PENGUINLIONG PENGUINLIONG modified the milestones: v1.3.0, v1.4.0 Nov 25, 2022
@lin-hitonami lin-hitonami modified the milestones: v1.4.0, v1.5.0 Jan 4, 2023
@ailzhang
Copy link
Contributor

cc: @dream189free

@turbo0628 turbo0628 modified the milestones: v1.5.0, v1.6.0 Mar 9, 2023
dream189free added a commit that referenced this issue Mar 31, 2023
Issue: #5949

### Brief Summary
This PR enables formatted printing in Taichi scope using `str.format()`
and f-strings.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this from Todo to Done in Taichi Lang May 7, 2023
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
…hi-dev#7686)

Issue: taichi-dev#5949

### Brief Summary
This PR enables formatted printing in Taichi scope using `str.format()`
and f-strings.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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 welcome contribution
Projects
Status: Done
Development

No branches or pull requests

7 participants