-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[bug] [refactor] Fix error when ti.init() not called by deprecating Expr.layout_materialized #1347
Changes from 4 commits
2652c70
6af59fc
b8134a0
f9d9deb
244b591
766c6c8
c52bb1a
db5db90
32be4e5
6681a4a
01b0fa2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import taichi as ti | ||
|
||
|
||
# The first test to run, ever: | ||
def test_000_without_init(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting - maybe we should simply let There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I want to test if non of Btw, we may add a |
||
assert ti.cfg.arch == ti.cpu | ||
|
||
x = ti.var(ti.i32, (2, 3)) | ||
assert x.shape == (2, 3) | ||
|
||
x[1, 2] = 4 | ||
assert x[1, 2] == 4 | ||
|
||
|
||
@ti.all_archs | ||
@ti.all_archs | ||
@ti.must_throw(RuntimeError) | ||
def test_materialization_after_kernel(): | ||
x = ti.var(ti.f32, (3, 4)) | ||
|
||
@ti.kernel | ||
def func(): | ||
print(x[2, 3]) | ||
|
||
func() | ||
|
||
y = ti.var(ti.f32, (2, 3)) | ||
# ERROR: No new variable should be declared after kernel invocation! | ||
|
||
|
||
@ti.all_archs | ||
@ti.must_throw(RuntimeError) | ||
def test_materialization_after_access(): | ||
x = ti.var(ti.f32, (3, 4)) | ||
|
||
print(x[2, 3]) | ||
|
||
y = ti.var(ti.f32, (2, 3)) | ||
# ERROR: No new variable should be declared after Python-scope tensor access! | ||
|
||
|
||
@ti.all_archs | ||
@ti.must_throw(RuntimeError) | ||
def test_materialization_after_get_shape(): | ||
x = ti.var(ti.f32, (3, 4)) | ||
|
||
print(x.shape) | ||
|
||
y = ti.var(ti.f32, (2, 3)) | ||
# ERROR: No new variable should be declared after Python-scope tensor access! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we no longer deprecate this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, since
tensor.parent()
returns atensor
whiletensor.snode().parent()
return a snode, it seems this is irreplaceable and many test is using this..