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

Can not print to debug in the first field -> 'NoneType' object has no attribute 'data_type' #2973

Closed
yihong0618 opened this issue Sep 23, 2021 · 5 comments · Fixed by #2979
Closed
Labels
potential bug Something that looks like a bug but not yet confirmed

Comments

@yihong0618
Copy link
Contributor

yihong0618 commented Sep 23, 2021

Describe the bug
Can not print to debug in the first field

To Reproduce

not work

import math

import taichi as ti

ti.init(arch=[ti.cuda, ti.metal])

dim = 3
N = 1024 * 8
dt = 2e-4
steps = 7
sun = ti.Vector([0.5, 0.5] if dim == 2 else [0.5, 0.5, 0.0])
gravity = 0.5
pressure = 0.3
tail_paticle_scale = 0.4
color_init = 0.3
color_decay = 1.6
vel_init = 0.07
res = 640

inv_m = ti.field(ti.f32)
color = ti.field(ti.f32)
x = ti.Vector.field(dim, ti.f32)
v = ti.Vector.field(dim, ti.f32)
print(v)
ti.root.bitmasked(ti.i, N).place(x, v, inv_m, color)
count = ti.field(ti.i32, ())
img = ti.field(ti.f32, (res, res))

work

import math

import taichi as ti

ti.init(arch=[ti.cuda, ti.metal])

dim = 3
N = 1024 * 8
dt = 2e-4
steps = 7
sun = ti.Vector([0.5, 0.5] if dim == 2 else [0.5, 0.5, 0.0])
gravity = 0.5
pressure = 0.3
tail_paticle_scale = 0.4
color_init = 0.3
color_decay = 1.6
vel_init = 0.07
res = 640

inv_m = ti.field(ti.f32)
color = ti.field(ti.f32)
x = ti.Vector.field(dim, ti.f32)
v = ti.Vector.field(dim, ti.f32)
ti.root.bitmasked(ti.i, N).place(x, v, inv_m, color)
count = ti.field(ti.i32, ())
img = ti.field(ti.f32, (res, res))
print(v)

Log/Screenshots
image


env

win10 python3.8.5

[Taichi] version 0.7.32, llvm 10.0.0, commit 6652f94f, win, python 3.8.5
@yihong0618 yihong0618 added the potential bug Something that looks like a bug but not yet confirmed label Sep 23, 2021
@strongoier
Copy link
Contributor

Nice catch! The fields are fully constructed during place() so we could only print after it. But we indeed need to provide better error message. Thanks for telling us about this.

@yihong0618
Copy link
Contributor Author

@strongoier

I think so~Maybe give a default initialisation value or type?

@strongoier
Copy link
Contributor

A field needs a shape to become meaningful. Shape info is only contained in ti.root.bitmasked(ti.i, N).place(x, v, inv_m, color). So if printed, it should show something like The definition of the field is incomplete.

@yihong0618
Copy link
Contributor Author

Cool.

Got it.

@yihong0618
Copy link
Contributor Author

Cool

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
None yet
Development

Successfully merging a pull request may close this issue.

2 participants