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

Update this code to the pytorch 2.0 numpy 1.24 #39

Open
louhz opened this issue Nov 1, 2023 · 4 comments
Open

Update this code to the pytorch 2.0 numpy 1.24 #39

louhz opened this issue Nov 1, 2023 · 4 comments

Comments

@louhz
Copy link

louhz commented Nov 1, 2023

Hi, I just update this code to pytorch 2.0 and numpy 1.24 by replace the np.bool to bool, adding device consistency for pytorch and also fix the dtype of inhomogeneous array of vei to object.

I test it and the result looks good so if anyone need help for the latest version of this code I can send a pull request

@cqulyx
Copy link

cqulyx commented Nov 8, 2023

Hi ,can you send the latest version of this code? Thank you very much.

@louhz
Copy link
Author

louhz commented Nov 9, 2023

So the code below are the change I made:

mesh_pool.py: line 35 change to :mask = np.ones(mesh.edges_count, dtype=bool)

mesh.py:line 91-95

  self.vei = torch.from_numpy(np.concatenate(np.array(self.vei, dtype=object)).ravel()).to(self.device).long()
    self.nvsi = torch.Tensor(np.concatenate(np.array(self.nvsi, dtype=object)).ravel()).to(self.device).long()
    self.nvsin = torch.from_numpy(np.concatenate(np.array(self.nvsin, dtype=object)).ravel()).to(self.device).long()
    ve_in = copy.deepcopy(self.ve)
    self.ve_in = torch.from_numpy(np.concatenate(np.array(ve_in, dtype=object)).ravel()).to(self.device).long()

@XuGW-Kevin
Copy link

Now maybe you should also change some other lines in mesh.py to make sure all tensors and their indexes are on the same devices.

@Alexbeast-CN
Copy link

Here is what I do to make sure all tensors and their indexes are on the same device.

add after mesh.py line 27

self.v_mask = np.ones(len(self.vs), dtype=bool)
self.v_mask = torch.from_numpy(self.v_mask).to(self.device)

replace mesh.py line 368 with:

# face = self.sub_mesh_index[i][face].to(face.device).long()
face = face.to(self.sub_mesh_index[i].device).long()
face = self.sub_mesh_index[i][face]

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

No branches or pull requests

4 participants