Skip to content

Commit

Permalink
Removing GPU dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
caelan committed Dec 10, 2020
1 parent 7dd40a6 commit cfaf61a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc

3 changes: 2 additions & 1 deletion model/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def get_random_points(self, shape, device="gpu0"):
Return Tensor of Size [x, 3, x ... x]
"""
assert shape[1] == 3, "shape should have 3 in dim 1"
rand_grid = torch.cuda.FloatTensor(shape).to(device).float()
FloatTensor = torch.cuda.FloatTensor if torch.cuda.is_available() else torch.FloatTensor
rand_grid = FloatTensor(shape).to(device).float()
rand_grid.data.normal_(0, 1)
rand_grid = rand_grid / torch.sqrt(torch.sum(rand_grid ** 2, dim=1, keepdim=True))
return Variable(rand_grid)
Expand Down

0 comments on commit cfaf61a

Please sign in to comment.