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

Zero-filling u8 (Vector) fields either gets warning or error #6318

Closed
yuanming-hu opened this issue Oct 13, 2022 · 1 comment
Closed

Zero-filling u8 (Vector) fields either gets warning or error #6318

yuanming-hu opened this issue Oct 13, 2022 · 1 comment
Assignees
Labels
potential bug Something that looks like a bug but not yet confirmed

Comments

@yuanming-hu
Copy link
Member

To Reproduce

Case 1

import taichi as ti

ti.init()

img = ti.field(dtype=ti.u8, shape=())


@ti.kernel
def foo():
    img.fill(0)

foo()

Output:

[Taichi] version 1.1.3, llvm 10.0.0, commit 1262a70a, linux, python 3.8.10
[Taichi] Starting on arch=x64
[W 10/14/22 01:19:36.809 109105] [type_check.cpp:type_check_store@36] [$10] Global store may lose precision: u8 <- i32
File "/home/ubuntu/.local/lib/python3.8/site-packages/taichi/_funcs.py", line 623, in field_fill_taichi_scope:
        F[I] = val
        ^^^^^^^^^^

Case 2

import taichi as ti

ti.init()

img = ti.field(dtype=ti.u8, shape=())


@ti.kernel
def foo():
    img.fill(ti.u8(0))

foo()

This one works fine.

Case 3

import taichi as ti

ti.init()

img = ti.Vector.field(3, dtype=ti.u8, shape=())


@ti.kernel
def foo():
    img.fill(ti.u8(0))


foo()

Output:

[Taichi] version 1.1.3, llvm 10.0.0, commit 1262a70a, linux, python 3.8.10
[Taichi] Starting on arch=x64
Traceback (most recent call last):
  File "test.py", line 13, in <module>
    foo()
  File "/home/ubuntu/.local/lib/python3.8/site-packages/taichi/lang/kernel_impl.py", line 917, in wrapped
    raise type(e)('\n' + str(e)) from None
taichi.lang.exception.TaichiCompilationError: 
File "test.py", line 10, in foo:
    img.fill(ti.u8(0))
    ^^^^^^^^^^^^^^^^^^
Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.8/site-packages/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/taichi/lang/ast/ast_transformer.py", line 521, in build_Call
    node.ptr = func(*args, **keywords)
  File "/home/ubuntu/.local/lib/python3.8/site-packages/taichi/lang/matrix.py", line 1654, in fill
    assert len(val) == self.n
TypeError: object of type 'Expr' has no len()


@yuanming-hu yuanming-hu added the potential bug Something that looks like a bug but not yet confirmed label Oct 13, 2022
@taichi-gardener taichi-gardener moved this to Untriaged in Taichi Lang Oct 13, 2022
@yuanming-hu yuanming-hu changed the title Zero-fill u8 fields either gets warning or error Zero-filling u8 (Vector) fields either gets warning or error Oct 13, 2022
@strongoier strongoier self-assigned this Oct 14, 2022
@FantasyVR FantasyVR moved this from Untriaged to Todo in Taichi Lang Oct 17, 2022
strongoier added a commit that referenced this issue Oct 21, 2022
Issue: #6318

### Brief Summary

The implementation and tests have been refactored by the way to ease
future maintenance efforts.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@strongoier
Copy link
Contributor

Here only case 3 is a bug :-) As it has been fixed in #6391, I'll close this issue.

Repository owner moved this from Todo to Done in Taichi Lang Oct 21, 2022
jim19930609 pushed a commit to jim19930609/taichi that referenced this issue Oct 25, 2022
Issue: taichi-dev#6318

### Brief Summary

The implementation and tests have been refactored by the way to ease
future maintenance efforts.

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

No branches or pull requests

2 participants