srayuth Claude Opus 4.6 commited on
Commit
b92f94d
·
1 Parent(s): bf075e9

[fix] move PyMCubes output tensors to input device

Browse files

PyMCubes returns numpy arrays (CPU). Need to move the resulting
torch tensors back to the original device (cuda:0) to match
the rest of the model's tensors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. tsr/models/isosurface.py +3 -2
tsr/models/isosurface.py CHANGED
@@ -41,10 +41,11 @@ class MarchingCubeHelper(IsosurfaceHelper):
41
  self,
42
  level: torch.FloatTensor,
43
  ) -> Tuple[torch.FloatTensor, torch.LongTensor]:
 
44
  level = -level.view(self.resolution, self.resolution, self.resolution)
45
  v_pos, t_pos_idx = self.mc_func(level.detach().cpu().numpy(), 0.0)
46
- v_pos = torch.from_numpy(v_pos.astype(np.float32))
47
- t_pos_idx = torch.from_numpy(t_pos_idx.astype(np.int64))
48
  v_pos = v_pos[..., [2, 1, 0]]
49
  v_pos = v_pos / (self.resolution - 1.0)
50
  return v_pos, t_pos_idx
 
41
  self,
42
  level: torch.FloatTensor,
43
  ) -> Tuple[torch.FloatTensor, torch.LongTensor]:
44
+ device = level.device
45
  level = -level.view(self.resolution, self.resolution, self.resolution)
46
  v_pos, t_pos_idx = self.mc_func(level.detach().cpu().numpy(), 0.0)
47
+ v_pos = torch.from_numpy(v_pos.astype(np.float32)).to(device)
48
+ t_pos_idx = torch.from_numpy(t_pos_idx.astype(np.int64)).to(device)
49
  v_pos = v_pos[..., [2, 1, 0]]
50
  v_pos = v_pos / (self.resolution - 1.0)
51
  return v_pos, t_pos_idx