repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/rotary_positional_embedding.py | fairseq/modules/rotary_positional_embedding.py | import torch
class RotaryPositionalEmbedding(torch.nn.Module):
def __init__(self, dim, base=10000, precision=torch.half):
"""Rotary positional embedding
Reference : https://blog.eleuther.ai/rotary-embeddings/
Paper: https://arxiv.org/pdf/2104.09864.pdf
Args:
dim: Dimens... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/transpose_last.py | fairseq/modules/transpose_last.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
transpose last 2 dimensions of the input
"""
import torch.nn as nn
class TransposeLast(nn.Module):
def __init__(self, deconstruct_id... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/sparse_transformer_sentence_encoder_layer.py | fairseq/modules/sparse_transformer_sentence_encoder_layer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from fairseq.modules import TransformerSentenceEncoderLayer
from fairseq.modules.sparse_multihead_attention import SparseMultiheadAttention
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/dynamic_convolution.py | fairseq/modules/dynamic_convolution.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Dict, Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
from fairseq.i... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/conv_tbc.py | fairseq/modules/conv_tbc.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torch import nn
from torch.nn.modules.utils import _single
from torch import Tensor
class ConvTBC(torch.nn.Module):
""... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/transformer_layer_aug.py | fairseq/modules/transformer_layer_aug.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Dict, List, Optional
import torch
from numpy.random import uniform
from torch import Tensor
from fairseq.modules import L... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/gumbel_vector_quantizer.py | fairseq/modules/gumbel_vector_quantizer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
class GumbelVectorQuantizer(nn.Module):
def __init__(
self,
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/positional_encoding.py | fairseq/modules/positional_encoding.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch.nn as nn
import math
import torch
class PositionalEncoding(nn.Module):
"""Positional encoding.
Args:
d_model: ... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/downsampled_multihead_attention.py | fairseq/modules/downsampled_multihead_attention.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq.modules.fairseq_dropout import FairseqDropout
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/same_pad.py | fairseq/modules/same_pad.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from torch import nn
class SamePad(nn.Module):
def __init__(self, kernel_size, causal=False):
super().__init__()
if cau... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/fp32_batch_norm.py | fairseq/modules/fp32_batch_norm.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
batch norm done in fp32 (for fp16 training)
"""
import torch
import torch.nn as nn
class Fp32BatchNorm(nn.Module):
def __init__(self,... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/espnet_multihead_attention.py | fairseq/modules/espnet_multihead_attention.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2019 Shigeki Karita
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Multi-Head Attention layer definition."""
import math
import torch
from torch import nn
from fairseq.modules.rotary_positional_embedding import (
RotaryPositionalEmbeddi... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/layer_norm.py | fairseq/modules/layer_norm.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
try:
from apex.normalization import FusedLayerNorm as _FusedLayerNorm
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/ema_module.py | fairseq/modules/ema_module.py | #!/usr/bin/env python3
"""
Used for EMA tracking a given pytorch module. The user is responsible for calling step()
and setting the appropriate decay
"""
import copy
from dataclasses import dataclass, field
import logging
import torch
from omegaconf import II
from fairseq.dataclass import FairseqDataclass
try:
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/conformer_layer.py | fairseq/modules/conformer_layer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
import torch
from fairseq.modules import (
ESPNETMultiHeadedAttention,
LayerNorm,
MultiheadAttentio... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/checkpoint_activations.py | fairseq/modules/checkpoint_activations.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import functools
from typing import Any, Dict, List, Tuple, Union
import torch
import torch.utils.checkpoint as checkpoint
from fairseq impor... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/multihead_attention.py | fairseq/modules/multihead_attention.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import math
from typing import Dict, List, Optional, Tuple
import torch
import torch.nn.functional as F
from torch import Tensor, nn
from tor... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | true |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/cross_entropy.py | fairseq/modules/cross_entropy.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import torch
import torch.nn.functional as F
logger = logging.getLogger(__name__)
def _cross_entropy_pytorch(logits, target... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/lightweight_convolution.py | fairseq/modules/lightweight_convolution.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
from fairseq.incremental_decoding_utils import wi... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/fairseq_dropout.py | fairseq/modules/fairseq_dropout.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
from typing import List, Optional
import torch.nn as nn
import torch.nn.functional as F
logger = logging.getLogger(__name__)... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/scalar_bias.py | fairseq/modules/scalar_bias.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
import torch
class ScalarBias(torch.autograd.Function):
"""
Adds a vector of scalars, used in self-attention mechanism to allow
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/gelu.py | fairseq/modules/gelu.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
See "Gaussian Error Linear Units (GELUs)" by Dan Hendrycks and Kevin Gimpel with
the corresponding GitHub repo: https://github.com/hendryck... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/__init__.py | fairseq/modules/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""isort:skip_file"""
from .adaptive_input import AdaptiveInput
from .adaptive_softmax import AdaptiveSoftmax
from .base_layer import BaseLaye... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/adaptive_softmax.py | fairseq/modules/adaptive_softmax.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import functools
import operator
import torch
import torch.nn.functional as F
from fairseq.modules.fairseq_dropout import FairseqDropout
from... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/layer_drop.py | fairseq/modules/layer_drop.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
LayerDrop as described in https://arxiv.org/abs/1909.11556.
"""
import torch
import torch.nn as nn
class LayerDropModuleList(nn.ModuleLi... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/adaptive_input.py | fairseq/modules/adaptive_input.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import List
import torch
from torch import nn
from fairseq.modules.quant_noise import quant_noise
class AdaptiveInput(nn.Modu... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/fp32_instance_norm.py | fairseq/modules/fp32_instance_norm.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Layer norm done in fp32 (for fp16 training)
"""
import torch.nn as nn
import torch.nn.functional as F
class Fp32InstanceNorm(nn.Instance... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/sinusoidal_positional_embedding.py | fairseq/modules/sinusoidal_positional_embedding.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import math
from typing import Any, Optional
import torch
import torch.onnx.operators
from fairseq import utils
from torch import nn, Tensor
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/base_layer.py | fairseq/modules/base_layer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch.nn as nn
import torch
import sys
from fairseq import utils
from fairseq.distributed import utils as distributed_utils
from fairse... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/character_token_embedder.py | fairseq/modules/character_token_embedder.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
from typing import List, Tuple
import torch
import torch.nn.functional as F
from fairseq.data import Dictionary
from torch imp... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/kmeans_vector_quantizer.py | fairseq/modules/kmeans_vector_quantizer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from fairseq.modules import Fp32GroupNorm
class KmeansVectorQuantizer(nn.Module):
def __init__(
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/vggblock.py | fairseq/modules/vggblock.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import absolute_import, division, print_function, unicode_literals
from collections.abc import Iterable
from itertools import... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/transformer_sentence_encoder_layer.py | fairseq/modules/transformer_sentence_encoder_layer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Callable, Optional
import torch
import torch.nn as nn
from fairseq import utils
from fairseq.modules import LayerNorm, Mul... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/learned_positional_embedding.py | fairseq/modules/learned_positional_embedding.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Dict, Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
from torch imp... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/dynamic_crf_layer.py | fairseq/modules/dynamic_crf_layer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
This file is to re-implemented the low-rank and beam approximation of CRF layer
Proposed by:
Sun, Zhiqing, et al.
Fast Structured Decodin... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/quantization_options.py | fairseq/modules/quantization/quantization_options.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
def parse_config_yaml(yaml_data):
# Initialize to default options.
quantization_options = {
"n_centroids": {
"Lin... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/__init__.py | fairseq/modules/quantization/__init__.py | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false | |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/scalar/ops.py | fairseq/modules/quantization/scalar/ops.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
try:
import torch.ao.quantization as quantization
except ImportError:
import torch.quantization as quantization
def em... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/scalar/utils.py | fairseq/modules/quantization/scalar/utils.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
from operator import attrgetter
import torch.distributed as dist
import torch.nn as nn
from ..pq.utils import attrsetter, get... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/scalar/__init__.py | fairseq/modules/quantization/scalar/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .utils import quantize_model_ # NOQA
| python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/scalar/modules/qact.py | fairseq/modules/quantization/scalar/modules/qact.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from ..ops import emulate_int
class ActivationQuantizer:
"""
Fake scalar quantization of the activations using a forwa... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/scalar/modules/qemb.py | fairseq/modules/quantization/scalar/modules/qemb.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
from ..ops import emulate_int
class IntEmbedding(nn.Module):
"""
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/scalar/modules/__init__.py | fairseq/modules/quantization/scalar/modules/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .qact import ActivationQuantizer # NOQA
from .qconv import IntConv2d # NOQA
from .qemb import IntEmbedding # NOQA
from .qlinear import... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/scalar/modules/qconv.py | fairseq/modules/quantization/scalar/modules/qconv.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn.functional as F
from torch.nn.modules.conv import _ConvNd
from torch.nn.modules.utils import _pair
from ..ops im... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/scalar/modules/qlinear.py | fairseq/modules/quantization/scalar/modules/qlinear.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
from ..ops import emulate_int
class IntLinear(nn.Module):
"""
Qu... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/pq/pq.py | fairseq/modules/quantization/pq/pq.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .em import EM, EmptyClusterResolveError
class PQ(EM):
"""
Quantizes the layer weights W with the standard Product Quantization
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/pq/utils.py | fairseq/modules/quantization/pq/utils.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import re
from operator import attrgetter, itemgetter
import torch
import numpy as np
import torch.distributed as dist
import t... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/pq/em.py | fairseq/modules/quantization/pq/em.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
import random
from collections import Counter
import torch
class EM:
"""
EM algorithm used to quantize the... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/pq/__init__.py | fairseq/modules/quantization/pq/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .utils import SizeTracker, get_param, attrsetter, quantize_model_ # NOQA
| python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/pq/modules/qemb.py | fairseq/modules/quantization/pq/modules/qemb.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
class PQEmbedding(nn.Module):
"""
Quantized counterpart of nn.Emb... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/pq/modules/__init__.py | fairseq/modules/quantization/pq/modules/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .qconv import PQConv2d # NOQA
from .qemb import PQEmbedding # NOQA
from .qlinear import PQLinear # NOQA
| python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/pq/modules/qconv.py | fairseq/modules/quantization/pq/modules/qconv.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.modules.utils import _pair
class PQConv2... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/quantization/pq/modules/qlinear.py | fairseq/modules/quantization/pq/modules/qlinear.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
class PQLinear(nn.Module):
"""
Quantized counterpart of nn.Linear... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/lightconv_layer/cuda_function_gen.py | fairseq/modules/lightconv_layer/cuda_function_gen.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
def gen_forward():
kernels = [3, 5, 7, 15, 31, 63, 127, 255]
seqs = [32 * x for x in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/lightconv_layer/lightconv_layer.py | fairseq/modules/lightconv_layer/lightconv_layer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import lightconv_cuda
import torch
import torch.nn.functional as F
from fairseq import utils
from fairseq.incremental_decoding_utils import wi... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/lightconv_layer/setup.py | fairseq/modules/lightconv_layer/setup.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name="lig... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/lightconv_layer/__init__.py | fairseq/modules/lightconv_layer/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .lightconv_layer import LightconvLayer # noqa
| python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/dynamicconv_layer/cuda_function_gen.py | fairseq/modules/dynamicconv_layer/cuda_function_gen.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
def gen_forward():
kernels = [3, 5, 7, 15, 31, 63, 127, 255]
blocks = [32, 64, 128, 256]
head = """
/**
* Copyright (c) Facebo... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/dynamicconv_layer/dynamicconv_layer.py | fairseq/modules/dynamicconv_layer/dynamicconv_layer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import dynamicconv_cuda
import torch
import torch.nn.functional as F
from fairseq import utils
from fairseq.incremental_decoding_utils import ... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/dynamicconv_layer/setup.py | fairseq/modules/dynamicconv_layer/setup.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name="dyn... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/modules/dynamicconv_layer/__init__.py | fairseq/modules/dynamicconv_layer/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .dynamicconv_layer import DynamicconvLayer # noqa
| python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/config/__init__.py | fairseq/config/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/strip_token_dataset.py | fairseq/data/strip_token_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from . import BaseWrapperDataset
class StripTokenDataset(BaseWrapperDataset):
def __init__(self, dataset, id_to_strip):
super().... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/data_utils.py | fairseq/data/data_utils.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
import contextlib
import itertools
impo... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | true |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/concat_sentences_dataset.py | fairseq/data/concat_sentences_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from . import FairseqDataset
class ConcatSentencesDataset(FairseqDataset):
def __init__(self, *datasets):
super().... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/span_mask_tokens_dataset.py | fairseq/data/span_mask_tokens_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from . import Dictionary, FairseqDataset, data_utils
def collate(
samples,
pad_idx,
eos_idx,
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/lm_context_window_dataset.py | fairseq/data/lm_context_window_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from typing import Dict
from fairseq.data.monolingual_dataset import MonolingualDataset
from . import Fairse... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/monolingual_dataset.py | fairseq/data/monolingual_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from . import FairseqDataset, data_utils
def collate(samples, pad_idx, eos_idx, fixed_pad_length=None, pad_... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/base_wrapper_dataset.py | fairseq/data/base_wrapper_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from torch.utils.data.dataloader import default_collate
from . import FairseqDataset
class BaseWrapperDataset(FairseqDataset):
def __in... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/plasma_utils.py | fairseq/data/plasma_utils.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import hashlib
import json
import subprocess
import tempfile
from typing import Hashable
try:
import pyarrow.plasma as plasma
PYARR... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/multi_corpus_dataset.py | fairseq/data/multi_corpus_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import asyncio
import logging
import time
from collections import OrderedDict
from typing import Dict, List, Optional
import numpy as np
fro... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/numel_dataset.py | fairseq/data/numel_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from . import BaseWrapperDataset
class NumelDataset(BaseWrapperDataset):
def __init__(self, dataset, re... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/subsample_dataset.py | fairseq/data/subsample_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import contextlib
import logging
import numpy as np
from fairseq.data.data_utils import numpy_seed
from . import BaseWrapperDataset
logger... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/denoising_dataset.py | fairseq/data/denoising_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import math
import numpy as np
import torch
from . import FairseqDataset, data_utils
def collate(
samples,
pad_idx,
eos_idx,
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/colorize_dataset.py | fairseq/data/colorize_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from . import BaseWrapperDataset
class ColorizeDataset(BaseWrapperDataset):
"""Adds 'colors' property to net input that is... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/list_dataset.py | fairseq/data/list_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from . import BaseWrapperDataset
class ListDataset(BaseWrapperDataset):
def __init__(self, dataset, sizes=None):
super().__init_... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/transform_eos_lang_pair_dataset.py | fairseq/data/transform_eos_lang_pair_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
import torch
from . import FairseqDataset
class TransformEosLangPairDataset(FairseqDataset):
"""A :class:... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/append_token_dataset.py | fairseq/data/append_token_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from . import BaseWrapperDataset
class AppendTokenDataset(BaseWrapperDataset):
def __init__(self, datas... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/iterators.py | fairseq/data/iterators.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import itertools
import logging
import math
import operator
import os
import queue
import time
from threading import Thread
from typing import... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/shorten_dataset.py | fairseq/data/shorten_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
from fairseq.data import data_utils
from . import BaseWrapperDataset
class TruncateDataset(BaseWrapperDataset):
"""T... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/token_block_dataset.py | fairseq/data/token_block_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from fairseq.data import FairseqDataset, plasma_utils
from fairseq.data.indexed_dataset import best_fitting_in... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/raw_label_dataset.py | fairseq/data/raw_label_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from . import FairseqDataset
class RawLabelDataset(FairseqDataset):
def __init__(self, labels):
super().__init__()... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/fairseq_dataset.py | fairseq/data/fairseq_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import numpy as np
import torch.utils.data
from fairseq.data import data_utils
logger = logging.getLogger(__name__)
class Ep... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/num_samples_dataset.py | fairseq/data/num_samples_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from . import FairseqDataset
class NumSamplesDataset(FairseqDataset):
def __getitem__(self, index):
return 1
def __len__(se... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/transform_eos_dataset.py | fairseq/data/transform_eos_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from . import FairseqDataset
class TransformEosDataset(FairseqDataset):
"""A :class:`~fairseq.data.FairseqDataset` wrapper... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/speech_dlm_dataset.py | fairseq/data/speech_dlm_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from collections import OrderedDict
import numpy as np
import torch
from fairseq.data import FairseqDataset, MonolingualDataset, data_utils
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/backtranslation_dataset.py | fairseq/data/backtranslation_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from fairseq import utils
from . import FairseqDataset
def backtranslate_samples(samples, collate_fn, generate_fn, cuda=True):... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/lru_cache_dataset.py | fairseq/data/lru_cache_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from functools import lru_cache
from . import BaseWrapperDataset
class LRUCacheDataset(BaseWrapperDataset):
def __init__(self, dataset,... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/language_pair_dataset.py | fairseq/data/language_pair_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import numpy as np
import torch
from fairseq.data import FairseqDataset, data_utils
logger = logging.getLogger(__name__)
d... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/dictionary.py | fairseq/data/dictionary.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
from collections import Counter
from multiprocessing import Pool
import torch
from fairseq import utils
from fairseq.data import da... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/fasta_dataset.py | fairseq/data/fasta_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
import subprocess
import threading
from pathlib import Path
import numpy as np
import torch
def fasta_file_path(prefix_path):
... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/add_class_target_dataset.py | fairseq/data/add_class_target_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from . import BaseWrapperDataset, data_utils
from fairseq.data.text_compressor import TextCompressor, TextCompressionLevel
cla... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/mask_tokens_dataset.py | fairseq/data/mask_tokens_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from functools import lru_cache
import numpy as np
import torch
from fairseq.data import Dictionary, data_utils
from . import BaseWrapperDat... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/codedataset.py | fairseq/data/codedataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import json
import logging
import os
import random
from pathlib import Path
import numpy as np
import torch
import torch.utils.data
from . ... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/prepend_token_dataset.py | fairseq/data/prepend_token_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from . import BaseWrapperDataset
class PrependTokenDataset(BaseWrapperDataset):
def __init__(self, data... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/multi_corpus_sampled_dataset.py | fairseq/data/multi_corpus_sampled_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from collections import OrderedDict
from typing import Callable, Dict, List
import numpy as np
from . import FairseqDataset
def uniform_sa... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/transform_eos_concat_langpair_dataset.py | fairseq/data/transform_eos_concat_langpair_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import torch
from torch.utils.data.dataloader import default_collate
from fairseq.data import ConcatDataset
logger = logging... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/__init__.py | fairseq/data/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""isort:skip_file"""
from .dictionary import Dictionary, TruncatedDictionary
from .fairseq_dataset import FairseqDataset, FairseqIterableDat... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/replace_dataset.py | fairseq/data/replace_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from . import BaseWrapperDataset
class ReplaceDataset(BaseWrapperDataset):
"""Replaces tokens found in the dataset by a specified replac... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
facebookresearch/fairseq | https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/fairseq/data/noising.py | fairseq/data/noising.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from fairseq.data import data_utils
class WordNoising(object):
"""Generate a noisy version of a sentence... | python | MIT | 3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99 | 2026-01-04T14:42:59.188867Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.