tachi/example/algorithm/marching_squares报错


请问这是咋回事呢?是taichi版本为1.4.1

我这里没有复现这个问题,看报错信息好像是参数类型有问题,你可以跑一下下面的程序么?同时,希望能吧命令行输出的信息都贴上来。

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

@ti.kernel
def test(a:tm.vec2):
    print(a)


a = tm.vec2([1,2])
test(a)

可以贴一下你运行 taichi 时打印出来的信息不?

C:\Users\86159\AppData\Local\Programs\Python\Python39\python.exe C:\Users\86159\PycharmProjects\data_structure\marching_squres.py
[Taichi] version 1.1.2, llvm 10.0.0, commit f25cf4a2, win, python 3.9.1
[Taichi] Starting on arch=x64
Traceback (most recent call last):
File “C:\Users\86159\PycharmProjects\data_structure\marching_squres.py”, line 75, in
def interp(p1: tm.vec2, p2: tm.vec2, v1: float, v2: float,
File “C:\Users\86159\AppData\Local\Programs\Python\Python39\lib\site-packages\taichi\lang\kernel_impl.py”, line 61, in func
fun = Func(fn, _classfunc=is_classfunc, is_real_function=is_real_function)
File “C:\Users\86159\AppData\Local\Programs\Python\Python39\lib\site-packages\taichi\lang\kernel_impl.py”, line 194, in init
self.extract_arguments()
File “C:\Users\86159\AppData\Local\Programs\Python\Python39\lib\site-packages\taichi\lang\kernel_impl.py”, line 311, in extract_arguments
raise TaichiSyntaxError(
taichi.lang.exception.TaichiSyntaxError: Invalid type annotation (argument 0) of Taichi function: <taichi.lang.matrix.MatrixType object at 0x00000263DE279310>

Process finished with exit code 1

C:\Users\user\AppData\Local\Programs\Python\Python39\python.exe C:\Users\user\PycharmProjects\taichi-TopOpt-main\respond.py
[Taichi] version 1.4.1, llvm 15.0.1, commit e67c674e, win, python 3.9.13
[Taichi] Starting on arch=x64

Process finished with exit code 0

可能是版本原因导致的,在1.4上就没有这个问题

运行情况如下C:\Users\86159\AppData\Local\Programs\Python\Python39\python.exe C:\Users\86159\PycharmProjects\data_structure\tttt.py
[Taichi] version 1.1.2, llvm 10.0.0, commit f25cf4a2, win, python 3.9.1
[Taichi] Starting on arch=x64
Traceback (most recent call last):
File “C:\Users\86159\PycharmProjects\data_structure\tttt.py”, line 11, in
test(a)
File “C:\Users\86159\AppData\Local\Programs\Python\Python39\lib\site-packages\taichi\lang\kernel_impl.py”, line 918, in wrapped
return primal(*args, **kwargs)
File “C:\Users\86159\AppData\Local\Programs\Python\Python39\lib\site-packages\taichi\lang\kernel_impl.py”, line 845, in call
return self.runtime.compiled_functionskey
File “C:\Users\86159\AppData\Local\Programs\Python\Python39\lib\site-packages\taichi\lang\kernel_impl.py”, line 744, in func__
raise ValueError(
ValueError: Matrix dtype f32 is not integer type or real type.

Process finished with exit code 1

1.1.2 的时候 dynamic snode 还不支持除 int32 之外的类型。marching_squares 这个例子也是在 1.4 里面更新,使用了 dynamic snode 的功能。

1 个赞

感谢解答