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

Printing ti.f64 ndarray in Python scope is not correct #6650

Closed
FantasyVR opened this issue Nov 17, 2022 · 0 comments · Fixed by #6836
Closed

Printing ti.f64 ndarray in Python scope is not correct #6650

FantasyVR opened this issue Nov 17, 2022 · 0 comments · Fixed by #6836
Assignees
Labels
potential bug Something that looks like a bug but not yet confirmed
Milestone

Comments

@FantasyVR
Copy link
Collaborator

FantasyVR commented Nov 17, 2022

Describe the bug
When printing ndarray with ti.f64 datatype in Python scope, the results are not correct.

To Reproduce
Please post a minimal sample code to reproduce the bug.
The developer team will put a higher priority on bugs that can be reproduced within 20 lines of code. If you want a prompt reply, please keep the sample code short and representative.

import taichi as ti 
ti.init(arch=ti.cpu)

n = 3
dtype = ti.f64  # when dtype is ti.f32, the output is correct
x = ti.ndarray(dtype, n)
@ti.kernel
def init(x: ti.types.ndarray(dtype=dtype)):
    for i in x:
        x[i] = i + 1.0
        
@ti.kernel 
def print_n(x: ti.types.ndarray(dtype=dtype)):
    for i in x:
        print(x[i])
        
init(x)
print("print ndarray in Taichi scope")
print_n(x)

print("print ndarray in Python scope")
for i in range(n):
    print(x[i])

Log/Screenshots

[Taichi] version 1.3.0, llvm 10.0.0, commit ede76d22, linux, python 3.8.13
[Taichi] Starting on arch=x64
print ndarray in Taichi scope
1.000000000000
2.000000000000
3.000000000000
print ndarray in Python scope
0.0
1.875
0.0
@FantasyVR FantasyVR added the potential bug Something that looks like a bug but not yet confirmed label Nov 17, 2022
@taichi-gardener taichi-gardener moved this to Untriaged in Taichi Lang Nov 17, 2022
@PENGUINLIONG PENGUINLIONG moved this from Untriaged to Todo in Taichi Lang Nov 18, 2022
@PENGUINLIONG PENGUINLIONG modified the milestone: v1.3.0 Nov 18, 2022
FantasyVR added a commit to FantasyVR/taichi that referenced this issue Nov 22, 2022
@PENGUINLIONG PENGUINLIONG modified the milestones: v1.3.0, v1.4.0 Nov 25, 2022
strongoier added a commit that referenced this issue Dec 9, 2022
Issue: fix #6650

### Brief Summary

The original implementation hardcodes `int`, `uint` and `float`, which
only allows reading 32-bit data out. This PR fixes the behavior by
leveraging `TypedConstant`.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Repository owner moved this from Todo to Done in Taichi Lang Dec 9, 2022
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
…v#6836)

Issue: fix taichi-dev#6650

### Brief Summary

The original implementation hardcodes `int`, `uint` and `float`, which
only allows reading 32-bit data out. This PR fixes the behavior by
leveraging `TypedConstant`.

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
potential bug Something that looks like a bug but not yet confirmed
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants