lzhengning / SubdivNet

Subdivision-based Mesh Convolutional Networks.
MIT License
251 stars 34 forks source link

Max Supported Vert Num or Face Num? #16

Closed Yannnnnnnnnnnn closed 3 years ago

Yannnnnnnnnnnn commented 3 years ago

Does SubdivNet have any restrictions on the number of vertices or faces?

Yannnnnnnnnnnn commented 3 years ago

PS, I found out this comment in https://github.com/lzhengning/SubdivNet/blob/dc751b69c557c5e8b7c3159a71c26f9c752a2d05/subdivnet/mesh_tensor.py#L294

            # TODO: maybe overflow if max_V > 2^15 = 32768
            E_hash = E.min(dim=1) * E.max() + E.max(dim=1)

. It seems that you think the type of E_hash is int16. However, the type of E_hash is int32 in my test.

lzhengning commented 3 years ago

Hi @Yannnnnnnnnnnn ,

Theoretically, there are no restrictions on the maximum numbers of faces and vertices. However, the input mesh should holds subdivision connectivity so that the numbers of faces are always b * 4^d, where b is base size and d is the depth of subdivision.

In the above implementation, the type of E and E_hash are both int32. But E.min(dim=1) * E.max() may overflow when E.max() > 2^15. So I added an comment there in case I forget the potential overflow. Change the type from int32 to int64 can address the problem.

I am planning to improving the implementation, but now I am too busy and it will take some time.

Yannnnnnnnnnnn commented 3 years ago

Thanks for your reply. I tried to replace int32 with int64, but an error occurred which is 'no instance of overloaded function atomicMax matches the argument list argument types are(jittor::int64, jittor::int64)'.

Since I am not very familiar with jittor, can you give me some suggestions for improvement? I will try to upgrade the code.

lzhengning commented 3 years ago

Seems like jittor does not support int64 in argsort.

An alternative approach is to convert jittor var to numpy and apply numpy's argsort.

E_hash = E.min(dim=1).data * E.max().data + E.max(dim=1).data
do numpy argsort
S = jt.array(S)
Yannnnnnnnnnnn commented 3 years ago

18