Skip to content

Commit 4ae25bf

Browse files
shapovalovfacebook-github-bot
authored andcommitted
Moving ray bundle to float dtype
Summary: We can now move ray bundle to float dtype (e.g. from fp16 like types). Reviewed By: bottler Differential Revision: D57493109 fbshipit-source-id: 4e18a427e968b646fe5feafbff653811cd007981
1 parent bd52f4a commit 4ae25bf

File tree

1 file changed

+13
-0
lines changed
  • pytorch3d/implicitron/models/renderer

1 file changed

+13
-0
lines changed

pytorch3d/implicitron/models/renderer/base.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,19 @@ def lengths(self, value):
121121
else:
122122
self._lengths = value
123123

124+
def float_(self) -> None:
125+
"""Moves the tensors to float dtype in place
126+
(helpful for mixed-precision tensors).
127+
"""
128+
self.origins = self.origins.float()
129+
self.directions = self.directions.float()
130+
self._lengths = self._lengths.float() if self._lengths is not None else None
131+
self.xys = self.xys.float()
132+
self.bins = self.bins.float() if self.bins is not None else None
133+
self.pixel_radii_2d = (
134+
self.pixel_radii_2d.float() if self.pixel_radii_2d is not None else None
135+
)
136+
124137
def is_packed(self) -> bool:
125138
"""
126139
Returns whether the ImplicitronRayBundle carries data in packed state

0 commit comments

Comments
 (0)