MCPcopy Create free account
hub / github.com/modelscope/modelscope / Frame

Class Frame

modelscope/models/science/unifold/modules/frame.py:183–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181
182
183class Frame:
184
185 def __init__(
186 self,
187 rotation: Optional[Rotation],
188 translation: Optional[torch.Tensor],
189 ):
190 if rotation is None and translation is None:
191 rotation = Rotation.identity((0, ))
192 translation = zero_translation((0, ))
193 elif translation is None:
194 translation = zero_translation(rotation.shape, rotation.dtype,
195 rotation.device,
196 rotation.requires_grad)
197
198 elif rotation is None:
199 rotation = Rotation.identity(
200 translation.shape[:-1],
201 translation.dtype,
202 translation.device,
203 translation.requires_grad,
204 )
205
206 if (rotation.shape != translation.shape[:-1]) or (rotation.device
207 != # noqa W504
208 translation.device):
209 raise ValueError('RotationMatrix and translation incompatible')
210
211 self._r = rotation
212 self._t = translation
213
214 @staticmethod
215 def identity(
216 shape: Iterable[int],
217 dtype: Optional[torch.dtype] = torch.float,
218 device: Optional[torch.device] = torch.device('cpu'),
219 requires_grad: bool = False,
220 ) -> Frame:
221 return Frame(
222 Rotation.identity(shape, dtype, device, requires_grad),
223 zero_translation(shape, dtype, device, requires_grad),
224 )
225
226 def __getitem__(
227 self,
228 index: Any,
229 ) -> Frame:
230 if type(index) != tuple:
231 index = (index, )
232
233 return Frame(
234 self._r[index],
235 self._t[index + (slice(None), )],
236 )
237
238 def __mul__(
239 self,
240 right: torch.Tensor,

Callers 15

atom37_to_framesFunction · 0.90
torsion_angles_to_framesFunction · 0.85
forwardMethod · 0.85
identityMethod · 0.85
__getitem__Method · 0.85
__mul__Method · 0.85
composeMethod · 0.85
invertMethod · 0.85
map_tensor_fnMethod · 0.85
from_tensor_4x4Method · 0.85
from_3_pointsMethod · 0.85
unsqueezeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…