ti.field初始化时shape单维超过2147483647无法初始化

初始化时shape=2147483647不报错

ti.field(float,shape=2147483647)

shape超过2147483647就报错

ti.field(float,shape=2147483648)

报错信息:

File d:\Programs\Python\Python38\lib\site-packages\taichi\lang\util.py:297, in python_scope..wrapped(*args, **kwargs)
293 @functools.wraps(func)
294 def wrapped(*args, **kwargs):
295 assert in_python_scope(),
296 f’{func.name} cannot be called in Taichi-scope’
→ 297 return func(*args, **kwargs)

File d:\Programs\Python\Python38\lib\site-packages\taichi\lang\impl.py:674, in field(dtype, shape, order, name, offset, needs_grad, needs_dual)
672 shape_seq = list(shape)
673 same_level = order is None
→ 674 _create_snode(axis_seq, shape_seq, same_level).place(x, offset=offset)
675 if needs_grad:
676 _create_snode(axis_seq, shape_seq, same_level).place(x_grad,
677 offset=offset)

File d:\Programs\Python\Python38\lib\site-packages\taichi\lang\impl.py:536, in _create_snode(axis_seq, shape_seq, same_level)
534 snode = root
535 if same_level:
→ 536 snode = snode.dense(axes(*axis_seq), shape_seq)
537 else:
538 for i in range(dim):

File d:\Programs\Python\Python38\lib\site-packages\taichi_snode\fields_builder.py:72, in FieldsBuilder.dense(self, indices, dimensions)
70 self._check_not_finalized()
71 self.empty = False
—> 72 return self.root.dense(indices, dimensions)

File d:\Programs\Python\Python38\lib\site-packages\taichi\lang\snode.py:36, in SNode.dense(self, axes, dimensions)
33 if isinstance(dimensions, int):
34 dimensions = [dimensions] * len(axes)
35 return SNode(
—> 36 self.ptr.dense(axes, dimensions,
37 impl.current_cfg().packed))

TypeError: dense(): incompatible function arguments. The following argument types are supported:
1. (self: taichi._lib.core.taichi_python.SNode, arg0: List[taichi._lib.core.taichi_python.Axis], arg1: List[int], arg2: bool) → taichi._lib.core.taichi_python.SNode

Invoked with: <taichi._lib.core.taichi_python.SNode object at 0x0000015ECDFA26B0>, [<taichi._lib.core.taichi_python.Axis object at 0x0000015F40F60BF0>], [2147483648], False

但是多维就不报错:

ti.field(float,shape=[2147483647, 2147483647])

请问该问题如何解决?

我感觉多维的这个内存可能不够?
主要是你这个维度超过int32的最大值了,目前shape都还是i32的data type,一般也很少用超了。

方便分享一下你的use case吗?

场景是使用一行数据记录一些粒子间的距离,粒子数多了之后就初始化失败了

这个我们后续会尝试解掉这个限制,目前的建议你先拆成多个维度用着