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

The usage example of 1-bit Quantized Arrays on the official website might be incorrect. #8488

Open
Kakitan-saikou opened this issue Mar 15, 2024 · 0 comments

Comments

@Kakitan-saikou
Copy link

Describe the bug
The usage example of 1-bit Quantized Arrays on the official website(https://docs.taichi-lang.org/docs/quant) might be incorrect.

To Reproduce
Here's the usage example of 1-bit Quantized Arrays on the official website(https://docs.taichi-lang.org/docs/quant).
The quant arrays x and y should have been fields with 2 dims as shown in the official website, but actually it is 1 dim field.

import taichi as ti
ti.init(arch=ti.cpu)
u1 = ti.types.quant.int(1, False)
N = 512
M = 32
x = ti.field(dtype=u1)
y = ti.field(dtype=u1)
ti.root.dense(ti.i, N // M).quant_array(ti.i, M, max_num_bits=M).place(x)
ti.root.dense(ti.i, N // M).quant_array(ti.i, M, max_num_bits=M).place(y)

@ti.kernel
def assign_vectorized():
    ti.loop_config(bit_vectorize=True)
    for i, j in x:
        y[i, j] = x[i, j]  # 32 bits are handled at a time

assign_vectorized()

Log/Screenshots
[Taichi] mode=release
[Taichi] version 1.6.0, llvm 15.0.1, commit f1c6fbb, win, python 3.11.4
taichi.lang.exception.TaichiCompilationError:
File "D:--.py", line --, in assign_vectorized:
for i, j in x:
^^^^^^^^^^^^^^
Traceback (most recent call last):
File "C:\Users--\AppData\Roaming\Python\Python311\site-packages\taichi\lang\ast\ast_transformer_utils.py", line 27, in call
return method(ctx, node)
^^^^^^^^^^^^^^^^^
File "C:\Users--\AppData\Roaming\Python\Python311\site-packages\taichi\lang\ast\ast_transformer.py", line 1336, in build_For
return ASTTransformer.build_struct_for(ctx, node, is_grouped=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users--\AppData\Roaming\Python\Python311\site-packages\taichi\lang\ast\ast_transformer.py", line 1237, in build_struct_for
impl.begin_frontend_struct_for(ctx.ast_builder, expr_group, loop_var)
File "C:\Users--\AppData\Roaming\Python\Python311\site-packages\taichi\lang\impl.py", line 117, in begin_frontend_struct_for
raise IndexError(
IndexError: Number of struct-for indices does not match loop variable dimensionality (2 != 1). Maybe you wanted to use "for I in ti.grouped(x)" to group all indices into a single vector I?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Untriaged
Development

No branches or pull requests

1 participant