code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def forward( self, s: torch.Tensor, z: Optional[torch.Tensor], r: Rigid, mask: torch.Tensor, _offload_inference: bool = False, _z_reference_list: Optional[Sequence[torch.Tensor]] = None, ) -> torch.Tensor: """ Args: s: ...
Args: s: [*, N_res, C_s] single representation z: [*, N_res, N_res, C_z] pair representation r: [*, N_res] transformation object mask: [*, N_res] mask Returns: [*, N_res, C_s] sin...
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
Apache-2.0
def forward(self, s: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]: """ Args: [*, N_res, C_s] single representation Returns: [*, N_res, 6] update vector """ # [*, 6] update = self.linear(s) return update
Args: [*, N_res, C_s] single representation Returns: [*, N_res, 6] update vector
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
Apache-2.0
def forward( self, evoformer_output_dict, aatype, mask=None, _offload_inference=False, ): """ Args: evoformer_output_dict: Dictionary containing: "single": [*, N_res, C_s] single represent...
Args: evoformer_output_dict: Dictionary containing: "single": [*, N_res, C_s] single representation "pair": [*, N_res, N_res, C_z] pair representation aatype: [*, N_re...
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
Apache-2.0
def forward(self, seq_feats, pair_feats, true_aa, residx, mask, no_recycles): """ Inputs: seq_feats: B x L x C tensor of sequence features pair_feats: B x L x L x C tensor of pair features residx: B x L long tensor giving the position in the sequence mask: B x L boolean tensor indica...
Inputs: seq_feats: B x L x C tensor of sequence features pair_feats: B x L x L x C tensor of pair features residx: B x L long tensor giving the position in the sequence mask: B x L boolean tensor indicating valid residues Output: predicted_structure: B x L x (num_atoms_pe...
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
Apache-2.0
def forward( self, input_ids: torch.Tensor, attention_mask: torch.Tensor = None, position_ids: Optional[torch.Tensor] = None, masking_pattern: Optional[torch.Tensor] = None, num_recycles: Optional[int] = None, ): r""" Returns: Example: ...
Returns: Example: ```python >>> from transformers import AutoTokenizer, EsmForProteinFolding >>> model = EsmForProteinFolding.from_pretrained("facebook/esmfold_v1") >>> tokenizer = AutoTokenizer.from_pretrained("facebook/esmfold_v1") >>> inputs = tokenizer(["M...
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
Apache-2.0
def output_to_pdb(output: Dict) -> List[str]: """Returns the pbd (file) string from the model given the model output.""" output = {k: v.to("cpu").numpy() for k, v in output.items()} pdbs = [] final_atom_positions = atom14_to_atom37(output["positions"][-1], output) final_atom_mask...
Returns the pbd (file) string from the model given the model output.
output_to_pdb
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
Apache-2.0
def infer_pdb(self, seqs, *args, **kwargs) -> str: """Returns the pdb (file) string from the model given an input sequence.""" assert type(seqs) is str output = self.infer(seqs, *args, **kwargs) return self.output_to_pdb(output)[0]
Returns the pdb (file) string from the model given an input sequence.
infer_pdb
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/modeling_esmfold.py
Apache-2.0
def create_position_ids_from_inputs_embeds(self, inputs_embeds): """ We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids. Args: inputs_embeds: tf.Tensor Returns: tf.Tensor """ input_shape = shape_lis...
We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids. Args: inputs_embeds: tf.Tensor Returns: tf.Tensor
create_position_ids_from_inputs_embeds
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/modeling_tf_esm.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/modeling_tf_esm.py
Apache-2.0
def call( self, input_ids: Optional[TFModelInputType] = None, attention_mask: Optional[Union[np.ndarray, tf.Tensor]] = None, position_ids: Optional[Union[np.ndarray, tf.Tensor]] = None, head_mask: Optional[Union[np.ndarray, tf.Tensor]] = None, inputs_embeds: Optional[Unio...
labels (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*): Labels for computing the masked language modeling loss. Indices should be in `[-100, 0, ..., config.vocab_size]` (see `input_ids` docstring) Tokens with indices set to `-100` are ignored (masked), the ...
call
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/modeling_tf_esm.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/modeling_tf_esm.py
Apache-2.0
def create_position_ids_from_input_ids(input_ids, padding_idx, past_key_values_length=0): """ Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols are ignored. This is modified from fairseq's `utils.make_positions`. Args: x: tf.Tensor...
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols are ignored. This is modified from fairseq's `utils.make_positions`. Args: x: tf.Tensor x: Returns: tf.Tensor
create_position_ids_from_input_ids
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/modeling_tf_esm.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/modeling_tf_esm.py
Apache-2.0
def _get_minimal_slice_set( start: Sequence[int], end: Sequence[int], dims: int, start_edges: Optional[Sequence[bool]] = None, end_edges: Optional[Sequence[bool]] = None, ) -> Sequence[Tuple[int]]: """ Produces an ordered sequence of tensor slices that, when used in sequence on a tensor with...
Produces an ordered sequence of tensor slices that, when used in sequence on a tensor with shape dims, yields tensors that contain every leaf in the contiguous range [start, end]. Care is taken to yield a short sequence of slices, and perhaps even the shortest possible (I'm pretty sure it's the latter). ...
_get_minimal_slice_set
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/chunk_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/chunk_utils.py
Apache-2.0
def _chunk_slice( t: torch.Tensor, flat_start: int, flat_end: int, no_batch_dims: int, ) -> torch.Tensor: """ Equivalent to t.reshape((-1,) + t.shape[no_batch_dims:])[flat_start:flat_end] but without the need for the initial reshape call, which can be memory-intensive in certain si...
Equivalent to t.reshape((-1,) + t.shape[no_batch_dims:])[flat_start:flat_end] but without the need for the initial reshape call, which can be memory-intensive in certain situations. The only reshape operations in this function are performed on sub-tensors that scale with (flat_end - flat_start), ...
_chunk_slice
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/chunk_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/chunk_utils.py
Apache-2.0
def chunk_layer( layer: Callable, inputs: Dict[str, Any], chunk_size: int, no_batch_dims: int, low_mem: bool = False, _out: Any = None, _add_into_out: bool = False, ) -> Any: """ Implements the "chunking" procedure described in section 1.11.8. Layer outputs and inputs are assume...
Implements the "chunking" procedure described in section 1.11.8. Layer outputs and inputs are assumed to be simple "pytrees," consisting only of (arbitrarily nested) lists, tuples, and dicts with torch.Tensor leaves. Args: layer: The layer to be applied chunk-wise inputs: ...
chunk_layer
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/chunk_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/chunk_utils.py
Apache-2.0
def make_atom14_masks(protein): """Construct denser atom positions (14 dimensions instead of 37).""" restype_atom14_to_atom37 = [] restype_atom37_to_atom14 = [] restype_atom14_mask = [] for rt in rc.restypes: atom_names = rc.restype_name_to_atom14_names[rc.restype_1to3[rt]] restype_...
Construct denser atom positions (14 dimensions instead of 37).
make_atom14_masks
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/data_transforms.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/data_transforms.py
Apache-2.0
def compute_predicted_aligned_error( logits: torch.Tensor, max_bin: int = 31, no_bins: int = 64, **kwargs, ) -> Dict[str, torch.Tensor]: """Computes aligned confidence metrics from logits. Args: logits: [*, num_res, num_res, num_bins] the logits output from PredictedAlignedErrorHe...
Computes aligned confidence metrics from logits. Args: logits: [*, num_res, num_res, num_bins] the logits output from PredictedAlignedErrorHead. max_bin: Maximum bin value no_bins: Number of bins Returns: aligned_confidence_probs: [*, num_res, num_res, num_bins] the predicted ...
compute_predicted_aligned_error
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/loss.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/loss.py
Apache-2.0
def add_pdb_headers(prot: Protein, pdb_str: str) -> str: """Add pdb headers to an existing PDB string. Useful during multi-chain recycling """ out_pdb_lines = [] lines = pdb_str.split("\n") remark = prot.remark if remark is not None: out_pdb_lines.append(f"REMARK {remark}") par...
Add pdb headers to an existing PDB string. Useful during multi-chain recycling
add_pdb_headers
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/protein.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/protein.py
Apache-2.0
def to_pdb(prot: Protein) -> str: """Converts a `Protein` instance to a PDB string. Args: prot: The protein to convert to PDB. Returns: PDB string. """ restypes = residue_constants.restypes + ["X"] def res_1to3(r): return residue_constants.restype_1to3.get(restypes[r], "UN...
Converts a `Protein` instance to a PDB string. Args: prot: The protein to convert to PDB. Returns: PDB string.
to_pdb
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/protein.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/protein.py
Apache-2.0
def from_prediction( features: FeatureDict, result: ModelOutput, b_factors: Optional[np.ndarray] = None, chain_index: Optional[np.ndarray] = None, remark: Optional[str] = None, parents: Optional[Sequence[str]] = None, parents_chain_index: Optional[Sequence[int]] = None, ) -> Protein: """...
Assembles a protein from a prediction. Args: features: Dictionary holding model inputs. result: Dictionary holding model outputs. b_factors: (Optional) B-factors to use for the protein. chain_index: (Optional) Chain indices for multi-chain predictions remark: (Optional) Remark about t...
from_prediction
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/protein.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/protein.py
Apache-2.0
def load_stereo_chemical_props() -> Tuple[ Mapping[str, List[Bond]], Mapping[str, List[Bond]], Mapping[str, List[BondAngle]], ]: """Load stereo_chemical_props.txt into a nice structure. Load literature values for bond lengths and bond angles and translate bond angles into the length of the opposite...
Load stereo_chemical_props.txt into a nice structure. Load literature values for bond lengths and bond angles and translate bond angles into the length of the opposite edge of the triangle ("residue_virtual_bonds"). Returns: residue_bonds: dict that maps resname --> list of Bond tuples residue_virtu...
load_stereo_chemical_props
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/residue_constants.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/residue_constants.py
Apache-2.0
def sequence_to_onehot(sequence: str, mapping: Mapping[str, int], map_unknown_to_x: bool = False) -> np.ndarray: """Maps the given sequence into a one-hot encoded matrix. Args: sequence: An amino acid sequence. mapping: A dictionary mapping amino acids to integers. map_unknown_to_x: If True, ...
Maps the given sequence into a one-hot encoded matrix. Args: sequence: An amino acid sequence. mapping: A dictionary mapping amino acids to integers. map_unknown_to_x: If True, any amino acid that is not in the mapping will be mapped to the unknown amino acid 'X'. If the mapping doesn't c...
sequence_to_onehot
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/residue_constants.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/residue_constants.py
Apache-2.0
def chi_angle_atom(atom_index: int) -> np.ndarray: """Define chi-angle rigid groups via one-hot representations.""" chi_angles_index = {} one_hots = [] for k, v in chi_angles_atoms.items(): indices = [atom_types.index(s[atom_index]) for s in v] indices.extend([-1] * (4 - len(indices))) ...
Define chi-angle rigid groups via one-hot representations.
chi_angle_atom
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/residue_constants.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/residue_constants.py
Apache-2.0
def _make_rigid_transformation_4x4(ex, ey, translation): """Create a rigid 4x4 transformation matrix from two axes and transl.""" # Normalize ex. ex_normalized = ex / np.linalg.norm(ex) # make ey perpendicular to ex ey_normalized = ey - np.dot(ey, ex_normalized) * ex_normalized ey_normalized /=...
Create a rigid 4x4 transformation matrix from two axes and transl.
_make_rigid_transformation_4x4
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/residue_constants.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/residue_constants.py
Apache-2.0
def make_atom14_dists_bounds(overlap_tolerance=1.5, bond_length_tolerance_factor=15): """compute upper and lower bounds for bonds to assess violations.""" restype_atom14_bond_lower_bound = np.zeros([21, 14, 14], np.float32) restype_atom14_bond_upper_bound = np.zeros([21, 14, 14], np.float32) restype_ato...
compute upper and lower bounds for bonds to assess violations.
make_atom14_dists_bounds
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/residue_constants.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/residue_constants.py
Apache-2.0
def rot_matmul(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor: """ Performs matrix multiplication of two rotation matrix tensors. Written out by hand to avoid AMP downcasting. Args: a: [*, 3, 3] left multiplicand b: [*, 3, 3] right multiplicand Returns: The product ab """...
Performs matrix multiplication of two rotation matrix tensors. Written out by hand to avoid AMP downcasting. Args: a: [*, 3, 3] left multiplicand b: [*, 3, 3] right multiplicand Returns: The product ab
rot_matmul
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def rot_vec_mul(r: torch.Tensor, t: torch.Tensor) -> torch.Tensor: """ Applies a rotation to a vector. Written out by hand to avoid transfer to avoid AMP downcasting. Args: r: [*, 3, 3] rotation matrices t: [*, 3] coordinate tensors Returns: [*, 3] rotated coordinates """ ...
Applies a rotation to a vector. Written out by hand to avoid transfer to avoid AMP downcasting. Args: r: [*, 3, 3] rotation matrices t: [*, 3] coordinate tensors Returns: [*, 3] rotated coordinates
rot_vec_mul
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def quat_to_rot(quat: torch.Tensor) -> torch.Tensor: """ Converts a quaternion to a rotation matrix. Args: quat: [*, 4] quaternions Returns: [*, 3, 3] rotation matrices """ # [*, 4, 4] quat = quat[..., None] * quat[..., None, :] # [4, 4, 3, 3] mat = _get_quat("_QTR_...
Converts a quaternion to a rotation matrix. Args: quat: [*, 4] quaternions Returns: [*, 3, 3] rotation matrices
quat_to_rot
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def quat_multiply_by_vec(quat, vec): """Multiply a quaternion by a pure-vector quaternion.""" mat = _get_quat("_QUAT_MULTIPLY_BY_VEC", dtype=quat.dtype, device=quat.device) reshaped_mat = mat.view((1,) * len(quat.shape[:-1]) + mat.shape) return torch.sum(reshaped_mat * quat[..., :, None, None] * vec[......
Multiply a quaternion by a pure-vector quaternion.
quat_multiply_by_vec
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def __init__( self, rot_mats: Optional[torch.Tensor] = None, quats: Optional[torch.Tensor] = None, normalize_quats: bool = True, ): """ Args: rot_mats: A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats quats: ...
Args: rot_mats: A [*, 3, 3] rotation matrix tensor. Mutually exclusive with quats quats: A [*, 4] quaternion. Mutually exclusive with rot_mats. If normalize_quats is not True, must be a unit quaternion normalize_quats: ...
__init__
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def identity( shape, dtype: Optional[torch.dtype] = None, device: Optional[torch.device] = None, requires_grad: bool = True, fmt: str = "quat", ) -> Rotation: """ Returns an identity Rotation. Args: shape: The "shape" of th...
Returns an identity Rotation. Args: shape: The "shape" of the resulting Rotation object. See documentation for the shape property dtype: The torch dtype for the rotation device: The torch device for the new rotation ...
identity
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def __getitem__(self, index: Any) -> Rotation: """ Allows torch-style indexing over the virtual shape of the rotation object. See documentation for the shape property. Args: index: A torch index. E.g. (1, 3, 2), or (slice(None,)) Returns: ...
Allows torch-style indexing over the virtual shape of the rotation object. See documentation for the shape property. Args: index: A torch index. E.g. (1, 3, 2), or (slice(None,)) Returns: The indexed rotation
__getitem__
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def __mul__( self, right: torch.Tensor, ) -> Rotation: """ Pointwise left multiplication of the rotation with a tensor. Can be used to e.g. mask the Rotation. Args: right: The tensor multiplicand Returns: The product ""...
Pointwise left multiplication of the rotation with a tensor. Can be used to e.g. mask the Rotation. Args: right: The tensor multiplicand Returns: The product
__mul__
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def __rmul__( self, left: torch.Tensor, ) -> Rotation: """ Reverse pointwise multiplication of the rotation with a tensor. Args: left: The left multiplicand Returns: The product """ return self.__mul__(left)
Reverse pointwise multiplication of the rotation with a tensor. Args: left: The left multiplicand Returns: The product
__rmul__
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def shape(self) -> torch.Size: """ Returns the virtual shape of the rotation object. This shape is defined as the batch dimensions of the underlying rotation matrix or quaternion. If the Rotation was initialized with a [10, 3, 3] rotation matrix tensor, for example, the resulting shape w...
Returns the virtual shape of the rotation object. This shape is defined as the batch dimensions of the underlying rotation matrix or quaternion. If the Rotation was initialized with a [10, 3, 3] rotation matrix tensor, for example, the resulting shape would be [10]. Returns: ...
shape
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def dtype(self) -> torch.dtype: """ Returns the dtype of the underlying rotation. Returns: The dtype of the underlying rotation """ if self._rot_mats is not None: return self._rot_mats.dtype elif self._quats is not None: return self._q...
Returns the dtype of the underlying rotation. Returns: The dtype of the underlying rotation
dtype
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def device(self) -> torch.device: """ The device of the underlying rotation Returns: The device of the underlying rotation """ if self._rot_mats is not None: return self._rot_mats.device elif self._quats is not None: return self._quats...
The device of the underlying rotation Returns: The device of the underlying rotation
device
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def requires_grad(self) -> bool: """ Returns the requires_grad property of the underlying rotation Returns: The requires_grad property of the underlying tensor """ if self._rot_mats is not None: return self._rot_mats.requires_grad elif self._quats...
Returns the requires_grad property of the underlying rotation Returns: The requires_grad property of the underlying tensor
requires_grad
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def get_rot_mats(self) -> torch.Tensor: """ Returns the underlying rotation as a rotation matrix tensor. Returns: The rotation as a rotation matrix tensor """ rot_mats = self._rot_mats if rot_mats is None: if self._quats is None: r...
Returns the underlying rotation as a rotation matrix tensor. Returns: The rotation as a rotation matrix tensor
get_rot_mats
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def get_quats(self) -> torch.Tensor: """ Returns the underlying rotation as a quaternion tensor. Depending on whether the Rotation was initialized with a quaternion, this function may call torch.linalg.eigh. Returns: The rotation as a quaternion tensor. """ ...
Returns the underlying rotation as a quaternion tensor. Depending on whether the Rotation was initialized with a quaternion, this function may call torch.linalg.eigh. Returns: The rotation as a quaternion tensor.
get_quats
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def get_cur_rot(self) -> torch.Tensor: """ Return the underlying rotation in its current form Returns: The stored rotation """ if self._rot_mats is not None: return self._rot_mats elif self._quats is not None: return self._quats ...
Return the underlying rotation in its current form Returns: The stored rotation
get_cur_rot
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def compose_q_update_vec(self, q_update_vec: torch.Tensor, normalize_quats: bool = True) -> Rotation: """ Returns a new quaternion Rotation after updating the current object's underlying rotation with a quaternion update, formatted as a [*, 3] tensor whose final three columns represent x, y, z s...
Returns a new quaternion Rotation after updating the current object's underlying rotation with a quaternion update, formatted as a [*, 3] tensor whose final three columns represent x, y, z such that (1, x, y, z) is the desired (not necessarily unit) quaternion update. Args: ...
compose_q_update_vec
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def compose_r(self, r: Rotation) -> Rotation: """ Compose the rotation matrices of the current Rotation object with those of another. Args: r: An update rotation object Returns: An updated rotation object """ r1 = self.get_rot_mats...
Compose the rotation matrices of the current Rotation object with those of another. Args: r: An update rotation object Returns: An updated rotation object
compose_r
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def compose_q(self, r: Rotation, normalize_quats: bool = True) -> Rotation: """ Compose the quaternions of the current Rotation object with those of another. Depending on whether either Rotation was initialized with quaternions, this function may call torch.linalg.eigh. Args: ...
Compose the quaternions of the current Rotation object with those of another. Depending on whether either Rotation was initialized with quaternions, this function may call torch.linalg.eigh. Args: r: An update rotation object Returns: An...
compose_q
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def apply(self, pts: torch.Tensor) -> torch.Tensor: """ Apply the current Rotation as a rotation matrix to a set of 3D coordinates. Args: pts: A [*, 3] set of points Returns: [*, 3] rotated points """ rot_mats = self.get_rot_mats()...
Apply the current Rotation as a rotation matrix to a set of 3D coordinates. Args: pts: A [*, 3] set of points Returns: [*, 3] rotated points
apply
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def invert_apply(self, pts: torch.Tensor) -> torch.Tensor: """ The inverse of the apply() method. Args: pts: A [*, 3] set of points Returns: [*, 3] inverse-rotated points """ rot_mats = self.get_rot_mats() inv_rot_mats = in...
The inverse of the apply() method. Args: pts: A [*, 3] set of points Returns: [*, 3] inverse-rotated points
invert_apply
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def invert(self) -> Rotation: """ Returns the inverse of the current Rotation. Returns: The inverse of the current Rotation """ if self._rot_mats is not None: return Rotation(rot_mats=invert_rot_mat(self._rot_mats), quats=None) elif self._quats is...
Returns the inverse of the current Rotation. Returns: The inverse of the current Rotation
invert
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def unsqueeze( self, dim: int, ) -> Rigid: """ Analogous to torch.unsqueeze. The dimension is relative to the shape of the Rotation object. Args: dim: A positive or negative dimension index. Returns: The unsqueezed Rotation. """ ...
Analogous to torch.unsqueeze. The dimension is relative to the shape of the Rotation object. Args: dim: A positive or negative dimension index. Returns: The unsqueezed Rotation.
unsqueeze
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def cat( rs: Sequence[Rotation], dim: int, ) -> Rigid: """ Concatenates rotations along one of the batch dimensions. Analogous to torch.cat(). Note that the output of this operation is always a rotation matrix, regardless of the format of input rotations. Ar...
Concatenates rotations along one of the batch dimensions. Analogous to torch.cat(). Note that the output of this operation is always a rotation matrix, regardless of the format of input rotations. Args: rs: A list of rotation objects dim: ...
cat
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def map_tensor_fn(self, fn: Callable[torch.Tensor, torch.Tensor]) -> Rotation: """ Apply a Tensor -> Tensor function to underlying rotation tensors, mapping over the rotation dimension(s). Can be used e.g. to sum out a one-hot batch dimension. Args: fn: A Ten...
Apply a Tensor -> Tensor function to underlying rotation tensors, mapping over the rotation dimension(s). Can be used e.g. to sum out a one-hot batch dimension. Args: fn: A Tensor -> Tensor function to be mapped over the Rotation Returns: The tra...
map_tensor_fn
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def cuda(self) -> Rotation: """ Analogous to the cuda() method of torch Tensors Returns: A copy of the Rotation in CUDA memory """ if self._rot_mats is not None: return Rotation(rot_mats=self._rot_mats.cuda(), quats=None) elif self._quats is not N...
Analogous to the cuda() method of torch Tensors Returns: A copy of the Rotation in CUDA memory
cuda
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def to(self, device: Optional[torch.device], dtype: Optional[torch.dtype]) -> Rotation: """ Analogous to the to() method of torch Tensors Args: device: A torch device dtype: A torch dtype Returns: A copy of the Rotation...
Analogous to the to() method of torch Tensors Args: device: A torch device dtype: A torch dtype Returns: A copy of the Rotation using the new device and dtype
to
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def detach(self) -> Rotation: """ Returns a copy of the Rotation whose underlying Tensor has been detached from its torch graph. Returns: A copy of the Rotation whose underlying Tensor has been detached from its torch graph """ if self._rot_mats is not None: ...
Returns a copy of the Rotation whose underlying Tensor has been detached from its torch graph. Returns: A copy of the Rotation whose underlying Tensor has been detached from its torch graph
detach
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def __init__( self, rots: Optional[Rotation], trans: Optional[torch.Tensor], ): """ Args: rots: A [*, 3, 3] rotation tensor trans: A corresponding [*, 3] translation tensor """ # (we need device, dtype, etc. from at least one input) ...
Args: rots: A [*, 3, 3] rotation tensor trans: A corresponding [*, 3] translation tensor
__init__
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def identity( shape: Tuple[int], dtype: Optional[torch.dtype] = None, device: Optional[torch.device] = None, requires_grad: bool = True, fmt: str = "quat", ) -> Rigid: """ Constructs an identity transformation. Args: shape: ...
Constructs an identity transformation. Args: shape: The desired shape dtype: The dtype of both internal tensors device: The device of both internal tensors requires_grad: Whether grad should...
identity
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def __getitem__( self, index: Any, ) -> Rigid: """ Indexes the affine transformation with PyTorch-style indices. The index is applied to the shared dimensions of both the rotation and the translation. E.g.:: r = Rotation(rot_mats=torch.rand(10, 10, 3, 3)...
Indexes the affine transformation with PyTorch-style indices. The index is applied to the shared dimensions of both the rotation and the translation. E.g.:: r = Rotation(rot_mats=torch.rand(10, 10, 3, 3), quats=None) t = Rigid(r, torch.rand(10, 10, 3)) indexed = t[3, 4...
__getitem__
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def __mul__( self, right: torch.Tensor, ) -> Rigid: """ Pointwise left multiplication of the transformation with a tensor. Can be used to e.g. mask the Rigid. Args: right: The tensor multiplicand Returns: The product ""...
Pointwise left multiplication of the transformation with a tensor. Can be used to e.g. mask the Rigid. Args: right: The tensor multiplicand Returns: The product
__mul__
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def __rmul__( self, left: torch.Tensor, ) -> Rigid: """ Reverse pointwise multiplication of the transformation with a tensor. Args: left: The left multiplicand Returns: The product """ return self.__mul__(left)
Reverse pointwise multiplication of the transformation with a tensor. Args: left: The left multiplicand Returns: The product
__rmul__
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def compose_q_update_vec( self, q_update_vec: torch.Tensor, ) -> Rigid: """ Composes the transformation with a quaternion update vector of shape [*, 6], where the final 6 columns represent the x, y, and z values of a quaternion of form (1, x, y, z) followed by a 3D translatio...
Composes the transformation with a quaternion update vector of shape [*, 6], where the final 6 columns represent the x, y, and z values of a quaternion of form (1, x, y, z) followed by a 3D translation. Args: q_vec: The quaternion update vector. Returns: The com...
compose_q_update_vec
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def compose( self, r: Rigid, ) -> Rigid: """ Composes the current rigid object with another. Args: r: Another Rigid object Returns: The composition of the two transformations """ new_rot = self._rots.compose_r(r...
Composes the current rigid object with another. Args: r: Another Rigid object Returns: The composition of the two transformations
compose
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def apply( self, pts: torch.Tensor, ) -> torch.Tensor: """ Applies the transformation to a coordinate tensor. Args: pts: A [*, 3] coordinate tensor. Returns: The transformed points. """ rotated = self._rots.apply(pts) r...
Applies the transformation to a coordinate tensor. Args: pts: A [*, 3] coordinate tensor. Returns: The transformed points.
apply
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def invert(self) -> Rigid: """ Inverts the transformation. Returns: The inverse transformation. """ rot_inv = self._rots.invert() trn_inv = rot_inv.apply(self._trans) return Rigid(rot_inv, -1 * trn_inv)
Inverts the transformation. Returns: The inverse transformation.
invert
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def map_tensor_fn(self, fn: Callable[torch.Tensor, torch.Tensor]) -> Rigid: """ Apply a Tensor -> Tensor function to underlying translation and rotation tensors, mapping over the translation/rotation dimensions respectively. Args: fn: A Tensor -> Tensor funct...
Apply a Tensor -> Tensor function to underlying translation and rotation tensors, mapping over the translation/rotation dimensions respectively. Args: fn: A Tensor -> Tensor function to be mapped over the Rigid Returns: The transformed Rigid obje...
map_tensor_fn
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def to_tensor_4x4(self) -> torch.Tensor: """ Converts a transformation to a homogenous transformation tensor. Returns: A [*, 4, 4] homogenous transformation tensor """ tensor = self._trans.new_zeros((*self.shape, 4, 4)) tensor[..., :3, :3] = self._rots.get_ro...
Converts a transformation to a homogenous transformation tensor. Returns: A [*, 4, 4] homogenous transformation tensor
to_tensor_4x4
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def from_tensor_4x4(t: torch.Tensor) -> Rigid: """ Constructs a transformation from a homogenous transformation tensor. Args: t: [*, 4, 4] homogenous transformation tensor Returns: T object with shape [*] """ if t.shape[-2:] != (4, 4): ...
Constructs a transformation from a homogenous transformation tensor. Args: t: [*, 4, 4] homogenous transformation tensor Returns: T object with shape [*]
from_tensor_4x4
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def to_tensor_7(self) -> torch.Tensor: """ Converts a transformation to a tensor with 7 final columns, four for the quaternion followed by three for the translation. Returns: A [*, 7] tensor representation of the transformation """ tensor = self._trans.new_ze...
Converts a transformation to a tensor with 7 final columns, four for the quaternion followed by three for the translation. Returns: A [*, 7] tensor representation of the transformation
to_tensor_7
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def from_3_points( p_neg_x_axis: torch.Tensor, origin: torch.Tensor, p_xy_plane: torch.Tensor, eps: float = 1e-8 ) -> Rigid: """ Implements algorithm 21. Constructs transformations from sets of 3 points using the Gram-Schmidt algorithm. Args: p_neg_x_axis: [*, 3] coordin...
Implements algorithm 21. Constructs transformations from sets of 3 points using the Gram-Schmidt algorithm. Args: p_neg_x_axis: [*, 3] coordinates origin: [*, 3] coordinates used as frame origins p_xy_plane: [*, 3] coordinates eps: Small epsilon value ...
from_3_points
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def unsqueeze( self, dim: int, ) -> Rigid: """ Analogous to torch.unsqueeze. The dimension is relative to the shared dimensions of the rotation/translation. Args: dim: A positive or negative dimension index. Returns: The unsqueezed transformat...
Analogous to torch.unsqueeze. The dimension is relative to the shared dimensions of the rotation/translation. Args: dim: A positive or negative dimension index. Returns: The unsqueezed transformation.
unsqueeze
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def cat( ts: Sequence[Rigid], dim: int, ) -> Rigid: """ Concatenates transformations along a new dimension. Args: ts: A list of T objects dim: The dimension along which the transformations should be concatenated ...
Concatenates transformations along a new dimension. Args: ts: A list of T objects dim: The dimension along which the transformations should be concatenated Returns: A concatenated transformation object
cat
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def make_transform_from_reference(n_xyz, ca_xyz, c_xyz, eps=1e-20): """ Returns a transformation object from reference coordinates. Note that this method does not take care of symmetries. If you provide the atom positions in the non-standard way, the N atom will end up not at [-0.527250...
Returns a transformation object from reference coordinates. Note that this method does not take care of symmetries. If you provide the atom positions in the non-standard way, the N atom will end up not at [-0.527250, 1.359329, 0.0] but instead at [-0.527250, -1.359329, 0.0]. You need t...
make_transform_from_reference
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/esm/openfold_utils/rigid_utils.py
Apache-2.0
def get_masks(slen, lengths, causal, padding_mask=None): """ Generate hidden states mask, and optionally an attention mask. """ alen = torch.arange(slen, dtype=torch.long, device=lengths.device) if padding_mask is not None: mask = padding_mask else: assert lengths.max().item() <=...
Generate hidden states mask, and optionally an attention mask.
get_masks
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flaubert/modeling_flaubert.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flaubert/modeling_flaubert.py
Apache-2.0
def forward(self, input, mask, kv=None, cache=None, head_mask=None, output_attentions=False): """ Self-attention (if kv is None) or attention over source sentence (provided by kv). """ # Input is (bs, qlen, dim) # Mask is (bs, klen) (non-causal) or (bs, klen, klen) bs, ql...
Self-attention (if kv is None) or attention over source sentence (provided by kv).
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flaubert/modeling_flaubert.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flaubert/modeling_flaubert.py
Apache-2.0
def forward(self, x, y=None): """Compute the loss, and optionally the scores.""" outputs = () if self.asm is False: scores = self.proj(x) outputs = (scores,) + outputs if y is not None: loss = nn.functional.cross_entropy(scores.view(-1, self.n_...
Compute the loss, and optionally the scores.
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flaubert/modeling_flaubert.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flaubert/modeling_flaubert.py
Apache-2.0
def forward( self, input_ids: Optional[torch.Tensor] = None, attention_mask: Optional[torch.Tensor] = None, langs: Optional[torch.Tensor] = None, token_type_ids: Optional[torch.Tensor] = None, position_ids: Optional[torch.Tensor] = None, lengths: Optional[torch.Te...
start_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*): Labels for position (index) of the start of the labelled span for computing the token classification loss. Positions are clamped to the length of the sequence (`sequence_length`). Position outside of the sequence...
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flaubert/modeling_flaubert.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flaubert/modeling_flaubert.py
Apache-2.0
def dummy_inputs(self): """ Dummy inputs to build the network. Returns: tf.Tensor with dummy inputs """ # Sometimes Flaubert has language embeddings so don't forget to build them as well if needed if self.config.use_lang_emb and self.config.n_langs > 1: ...
Dummy inputs to build the network. Returns: tf.Tensor with dummy inputs
dummy_inputs
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flaubert/modeling_tf_flaubert.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flaubert/modeling_tf_flaubert.py
Apache-2.0
def convert_to_unicode(text): """ Converts `text` to Unicode (if it's not already), assuming UTF-8 input. """ def ensure_text(s, encoding="utf-8", errors="strict"): if isinstance(s, bytes): return s.decode(encoding, errors) elif isinstance(s, str): return s ...
Converts `text` to Unicode (if it's not already), assuming UTF-8 input.
convert_to_unicode
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flaubert/tokenization_flaubert.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flaubert/tokenization_flaubert.py
Apache-2.0
def get_pairs(word): """ Return set of symbol pairs in a word. word is represented as tuple of symbols (symbols being variable-length strings) """ pairs = set() prev_char = word[0] for char in word[1:]: pairs.add((prev_char, char)) prev_char = char return pairs
Return set of symbol pairs in a word. word is represented as tuple of symbols (symbols being variable-length strings)
get_pairs
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flaubert/tokenization_flaubert.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flaubert/tokenization_flaubert.py
Apache-2.0
def remove_non_printing_char(text): """ Port of https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/remove-non-printing-char.perl """ output = [] for char in text: cat = unicodedata.category(char) if cat.startswith("C"): continue output.append(...
Port of https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/remove-non-printing-char.perl
remove_non_printing_char
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flaubert/tokenization_flaubert.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flaubert/tokenization_flaubert.py
Apache-2.0
def _tokenize(self, text, bypass_tokenizer=False): """ Tokenize a string given language code using Moses. Details of tokenization: - [sacremoses](https://github.com/alvations/sacremoses): port of Moses - Install with `pip install sacremoses` Args: -...
Tokenize a string given language code using Moses. Details of tokenization: - [sacremoses](https://github.com/alvations/sacremoses): port of Moses - Install with `pip install sacremoses` Args: - bypass_tokenizer: Allow users to preprocess and tokenize the ...
_tokenize
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flaubert/tokenization_flaubert.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flaubert/tokenization_flaubert.py
Apache-2.0
def build_inputs_with_special_tokens( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An XLM sequence has t...
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An XLM sequence has the following format: - single sequence: `<s> X </s>` - pair of sequences: `<s> A </s> B </s>` Args: token_ids...
build_inputs_with_special_tokens
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flaubert/tokenization_flaubert.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flaubert/tokenization_flaubert.py
Apache-2.0
def create_token_type_ids_from_sequences( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLM sequence pair mask has the following format: ...
Create a mask from the two sequences passed to be used in a sequence-pair classification task. An XLM sequence pair mask has the following format: ``` 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 | first sequence | second sequence | ``` If `token_ids_1` is `None`...
create_token_type_ids_from_sequences
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flaubert/tokenization_flaubert.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flaubert/tokenization_flaubert.py
Apache-2.0
def from_configs( cls, image_config: FlavaImageConfig, text_config: FlavaTextConfig, multimodal_config: FlavaMultimodalConfig, image_codebook_config: FlavaImageCodebookConfig, **kwargs ): r""" Instantiate a [`FlavaConfig`] (or a derived class) from fla...
Instantiate a [`FlavaConfig`] (or a derived class) from flava text model configuration, flava image model configuration, flava multimodal model and flava codebook model configuration. Returns: [`FlavaConfig`]: An instance of a configuration object
from_configs
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flava/configuration_flava.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flava/configuration_flava.py
Apache-2.0
def __call__( self, images: Union[ Image.Image, np.ndarray, "torch.Tensor", List[Image.Image], List[np.ndarray], List["torch.Tensor"] # noqa ], return_image_mask: Optional[bool] = None, return_codebook_pixels: Optional[bool] = None, return_tensors: Optional[U...
Main method to prepare for the model one or several image(s). <Tip warning={true}> NumPy arrays and PyTorch tensors are converted to PIL images when resizing, so the most efficient is to pass PIL images. </Tip> Args: images (`PIL.Image.Image`, `np.ndarray...
__call__
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flava/feature_extraction_flava.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flava/feature_extraction_flava.py
Apache-2.0
def interpolate_pos_encoding(self, embeddings: torch.Tensor, height: int, width: int) -> torch.Tensor: """ This method allows to interpolate the pre-trained position encodings, to be able to use the model on higher resolution images. Source: https://github.com/facebookresearch/d...
This method allows to interpolate the pre-trained position encodings, to be able to use the model on higher resolution images. Source: https://github.com/facebookresearch/dino/blob/de9ee3df6cf39fac952ab558447af1fa1365362a/image_transformer.py#L174
interpolate_pos_encoding
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flava/modeling_flava.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flava/modeling_flava.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, pixel_values: Optional[torch.FloatTensor] = None, attention_mask: Optional[torch.Tensor] = None, token_type_ids: Optional[torch.Tensor] = None, bool_masked_pos: Optional[torch.Tensor] = None, positio...
Returns: Examples: ```python >>> from PIL import Image >>> import requests >>> from transformers import FlavaProcessor, FlavaModel >>> model = FlavaModel.from_pretrained("facebook/flava-full") >>> processor = FlavaProcessor.from_pretrained("facebook/fl...
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flava/modeling_flava.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flava/modeling_flava.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, input_ids_masked: Optional[torch.LongTensor] = None, pixel_values: Optional[torch.FloatTensor] = None, codebook_pixel_values: Optional[torch.FloatTensor] = None, attention_mask: Optional[torch.Tensor] = None...
Examples: ```python >>> from PIL import Image >>> import requests >>> from transformers import FlavaForPreTraining, FlavaProcessor >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg" >>> image = Image.open(requests.get(url, stream=True).raw) ...
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flava/modeling_flava.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flava/modeling_flava.py
Apache-2.0
def __call__( self, images: Optional[ImageInput] = None, text: Optional[Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]]] = None, add_special_tokens: bool = True, padding: Union[bool, str, PaddingStrategy] = False, truncation: Union[bool, str,...
This method uses [`FLAVAFeatureExtractor.__call__`] method to prepare image(s) for the model, and [`BertTokenizerFast.__call__`] to prepare text for the model. Please refer to the docstring of the above two methods for more information.
__call__
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/flava/processing_flava.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/flava/processing_flava.py
Apache-2.0
def _two_dim_matmul(x, matrix_dim_one, matrix_dim_two): """Applies 2D matrix multiplication to 3D input arrays.""" seq_length = x.shape[1] matrix_dim_one = matrix_dim_one[:seq_length, :seq_length] x = x.type(torch.complex64) return torch.einsum("bij,jk,ni->bnk", x, matrix_dim_two, matrix_dim_one)
Applies 2D matrix multiplication to 3D input arrays.
_two_dim_matmul
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fnet/modeling_fnet.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fnet/modeling_fnet.py
Apache-2.0
def fftn(x): """ Applies n-dimensional Fast Fourier Transform (FFT) to input array. Args: x: Input n-dimensional array. Returns: n-dimensional Fourier transform of input n-dimensional array. """ out = x for axis in reversed(range(x.ndim)[1:]): # We don't need to apply FFT ...
Applies n-dimensional Fast Fourier Transform (FFT) to input array. Args: x: Input n-dimensional array. Returns: n-dimensional Fourier transform of input n-dimensional array.
fftn
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fnet/modeling_fnet.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fnet/modeling_fnet.py
Apache-2.0
def forward( self, input_ids: Optional[torch.Tensor] = None, token_type_ids: Optional[torch.Tensor] = None, position_ids: Optional[torch.Tensor] = None, inputs_embeds: Optional[torch.Tensor] = None, labels: Optional[torch.Tensor] = None, next_sentence_label: Optio...
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*): Labels for computing the masked language modeling loss. Indices should be in `[-100, 0, ..., config.vocab_size]` (see `input_ids` docstring) Tokens with indices set to `-100` are ignored (masked), the ...
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fnet/modeling_fnet.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fnet/modeling_fnet.py
Apache-2.0
def forward( self, input_ids: Optional[torch.Tensor] = None, token_type_ids: Optional[torch.Tensor] = None, position_ids: Optional[torch.Tensor] = None, inputs_embeds: Optional[torch.Tensor] = None, labels: Optional[torch.Tensor] = None, output_hidden_states: Opti...
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*): Labels for computing the next sequence prediction (classification) loss. Input should be a sequence pair (see `input_ids` docstring). Indices should be in `[0, 1]`: - 0 indicates sequence B is a continuation ...
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fnet/modeling_fnet.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fnet/modeling_fnet.py
Apache-2.0
def build_inputs_with_special_tokens( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An FNet sequence has ...
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An FNet sequence has the following format: - single sequence: `[CLS] X [SEP]` - pair of sequences: `[CLS] A [SEP] B [SEP]` Args: t...
build_inputs_with_special_tokens
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fnet/tokenization_fnet.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fnet/tokenization_fnet.py
Apache-2.0
def create_token_type_ids_from_sequences( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Create a mask from the two sequences passed to be used in a sequence-pair classification task. An FNet sequence pair mask has the following format: : ...
Create a mask from the two sequences passed to be used in a sequence-pair classification task. An FNet sequence pair mask has the following format: : ``` 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 | first sequence | second sequence | ``` If `token_ids_1` is `None`, this m...
create_token_type_ids_from_sequences
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fnet/tokenization_fnet.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fnet/tokenization_fnet.py
Apache-2.0
def build_inputs_with_special_tokens( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An FNet sequence has ...
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An FNet sequence has the following format: - single sequence: `[CLS] X [SEP]` - pair of sequences: `[CLS] A [SEP] B [SEP]` Args: t...
build_inputs_with_special_tokens
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fnet/tokenization_fnet_fast.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fnet/tokenization_fnet_fast.py
Apache-2.0
def create_token_type_ids_from_sequences( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Creates a mask from the two sequences passed to be used in a sequence-pair classification task. An FNet sequence pair mask has the following format: ...
Creates a mask from the two sequences passed to be used in a sequence-pair classification task. An FNet sequence pair mask has the following format: ``` 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 | first sequence | second sequence | ``` if token_ids_1 is None, ...
create_token_type_ids_from_sequences
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fnet/tokenization_fnet_fast.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fnet/tokenization_fnet_fast.py
Apache-2.0
def _prepare_fsmt_decoder_inputs( config, input_ids, decoder_input_ids=None, decoder_padding_mask=None, causal_mask_dtype=torch.float32, ): """ Prepare masks that ignore padding tokens in the decoder and a causal mask for the decoder if none are provided. This mimics the default behavior...
Prepare masks that ignore padding tokens in the decoder and a causal mask for the decoder if none are provided. This mimics the default behavior in fairseq. To override it pass in masks. Note: this is not called during generation
_prepare_fsmt_decoder_inputs
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
Apache-2.0
def shift_tokens_right(input_ids, pad_token_id): """Shift input ids one token to the right, and wrap the last non pad token (usually <eos>).""" # replace possible -100 values in labels by `pad_token_id` input_ids.masked_fill_(input_ids == -100, pad_token_id) prev_output_tokens = input_ids.clone() ...
Shift input ids one token to the right, and wrap the last non pad token (usually <eos>).
shift_tokens_right
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
Apache-2.0
def forward(self, x, encoder_padding_mask, layer_head_mask, output_attentions=False): """ Args: x (`torch.Tensor`): input to the layer of shape *(seq_len, batch, embed_dim)* encoder_padding_mask (`torch.ByteTensor`): binary ByteTensor of shape *(batch, src_len)* w...
Args: x (`torch.Tensor`): input to the layer of shape *(seq_len, batch, embed_dim)* encoder_padding_mask (`torch.ByteTensor`): binary ByteTensor of shape *(batch, src_len)* where padding elements are indicated by `1`. for t_tgt, t_src is excluded (or masked o...
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
Apache-2.0
def forward( self, input_ids: torch.Tensor, attention_mask: Optional[torch.Tensor] = None, head_mask: Optional[torch.Tensor] = None, output_attentions: bool = False, output_hidden_states: bool = False, return_dict: bool = True, ): """ Args: ...
Args: input_ids (`torch.LongTensor`): tokens in the source language of shape *(batch, src_len)* attention_mask (`torch.LongTensor`): indicating which indices are padding tokens head_mask (`torch.Tensor` of shape `(num_layers, num_heads)`, *optional*): ...
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
Apache-2.0
def forward( self, input_ids: torch.Tensor, encoder_hidden_states: torch.Tensor, encoder_padding_mask: torch.Tensor, decoder_padding_mask: torch.Tensor, decoder_causal_mask: torch.Tensor, head_mask: Optional[torch.Tensor] = None, cross_attn_head_mask: Opti...
Includes several features from "Jointly Learning to Align and Translate with Transformer Models" (Garg et al., EMNLP 2019). Args: input_ids (`torch.LongTensor` of shape `(batch, tgt_len)`): previous decoder outputs for teacher forcing encoder_hidden_stat...
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
Apache-2.0
def forward( self, query, key: Optional[Tensor], key_padding_mask: Optional[Tensor] = None, layer_state: Optional[Dict[str, Optional[Tensor]]] = None, attn_mask: Optional[Tensor] = None, layer_head_mask: Optional[Tensor] = None, output_attentions=False, ...
Input shape: Time(SeqLen) x Batch x Channel
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
Apache-2.0
def forward( self, input_ids: torch.LongTensor, attention_mask: Optional[torch.Tensor] = None, decoder_input_ids: Optional[torch.LongTensor] = None, decoder_attention_mask: Optional[torch.BoolTensor] = None, head_mask: Optional[torch.Tensor] = None, decoder_head_m...
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*): Labels for computing the masked language modeling loss. Indices should either be in `[0, ..., config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored ...
forward
python
FMInference/FlexLLMGen
benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
https://github.com/FMInference/FlexLLMGen/blob/master/benchmark/third_party/transformers/src/transformers/models/fsmt/modeling_fsmt.py
Apache-2.0