运行环境
[Taichi] version 0.8.4, llvm 10.0.0, commit 895881b5, win, python 3.8.10
问题描述
根据第二讲里面的galaxy例子模仿的代码,发现在cpu下可以正常运行,但是把arch换成opengl就会报错,报错如下:
另外,在增加黑洞类时,发现不能在重写父类方法中使用super的情况,比如将planet的initial方法重写如下:
@ti.kernel
def initial(self,centerx:ti.f32,centery:ti.f32,size:ti.f32,init_vel:ti.f32):
super(planet,self).initial(centerx,centery,size,init_vel)
"""
for i in range(self.N):
if self.N == 1:
self.pos[i] = ti.Vector([centerx,centery])
self.vel[i] = ti.Vector([0.0,0.0])
else:
angle, dis = self.pickrandomlocation(i,self.N)
offset = ti.Vector([ti.cos(angle),ti.sin(angle)])
center = ti.Vector([centerx,centery])
self.pos[i] = center + dis*offset*size
self.vel[i] = ti.Vector([-ti.sin(angle),ti.cos(angle)])
self.vel[i] *= init_vel
"""
self.disappearstatus[i] = ti.Vector([0])
会报错如下
Traceback (most recent call last):
File "H:\taichi\galaxy.py", line 11, in <module>
planets.initial(0.5,0.5,0.4,10)
File "D:\python\lib\site-packages\taichi\lang\kernel_impl.py", line 859, in __
call__
return self._primal(self._kernel_owner, *args, **kwargs)
File "D:\python\lib\site-packages\taichi\lang\kernel_impl.py", line 723, in __
call__
key = self.ensure_compiled(*args)
File "D:\python\lib\site-packages\taichi\lang\kernel_impl.py", line 714, in en
sure_compiled
self.materialize(key=key, args=args, arg_features=arg_features)
File "D:\python\lib\site-packages\taichi\lang\kernel_impl.py", line 518, in ma
terialize
taichi_kernel = _ti_core.create_kernel(taichi_ast_generator,
File "D:\python\lib\site-packages\taichi\lang\kernel_impl.py", line 513, in ta
ichi_ast_generator
compiled()
File "H:\taichi\celestial.py", line 88, in initial
super(planet,self).initial(centerx,centery,size,init_vel)
File "D:\python\lib\site-packages\taichi\lang\kernel_impl.py", line 787, in wr
apped
assert not hasattr(clsobj, '_data_oriented')
AssertionError
而使用注释区域的代码重写不用super函数则没有问题,请问这又是什么原因