python_code stringlengths 0 4.04M | repo_name stringlengths 8 58 | file_path stringlengths 5 147 |
|---|---|---|
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# CREDITS: This comes almost as-is from the Triton layer norm tutorial
# https://github.com/openai/triton/blob/master/py... | bart_ls-main | xformers/xformers/triton/k_layer_norm.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import triton
import triton.language as tl
# fmt: off
@triton.jit
def k_sum_0(
Y, X,
stride_xm,
M, N,
i... | bart_ls-main | xformers/xformers/triton/k_sum.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
from typing import Optional
import torch
_gpu_is_old: Optional[bool] = None
def gpu_capabilities_older... | bart_ls-main | xformers/xformers/triton/utils.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
import triton
from xformers.triton.utils import get_current_cuda_device
# CREDITS: Optimized defaults as s... | bart_ls-main | xformers/xformers/triton/configs_matmul.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
import torch
import triton
import triton.language as tl
# CREDITS: Initially inspired by th... | bart_ls-main | xformers/xformers/triton/k_fused_matmul_fw.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# CREDITS: This comes almost as-is from the Triton dropout tutorial
# https://raw.githubusercontent.com/openai/triton/ma... | bart_ls-main | xformers/xformers/triton/dropout.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# CREDITS: This comes almost as-is from the Triton dropout tutorial
# https://raw.githubusercontent.com/openai/triton/ma... | bart_ls-main | xformers/xformers/triton/k_dropout.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
from enum import Enum
from typing import Optional
import torch
import triton
from torch.cuda.amp import ... | bart_ls-main | xformers/xformers/triton/softmax.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# CREDITS: the underlying kernel comes straight from the Triton tutorials
# see https://github.com/openai/triton/blob/mas... | bart_ls-main | xformers/xformers/triton/layer_norm.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
import torch
import triton
import triton.language as tl
from xformers.triton.sum_strided i... | bart_ls-main | xformers/xformers/triton/k_fused_matmul_bw.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
import triton
import triton.language as tl
# CREDITS: This is adapted from the vanilla Triton example. See... | bart_ls-main | xformers/xformers/triton/k_softmax.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from typing import Optional
import torch
import torch.nn as nn
from xformers.compone... | bart_ls-main | xformers/xformers/models/linformer.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from typing import Optional
from xformers.components import Activation
@dataclass
c... | bart_ls-main | xformers/xformers/models/base.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import math
from dataclasses import dataclass
from typing import Optional, Tuple
import torch
from torch import nn
from... | bart_ls-main | xformers/xformers/components/in_proj_container.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from enum import Enum
from typing import List, Union
import torch
import torch.nn as nn
from xformers import _is_trito... | bart_ls-main | xformers/xformers/components/residual.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from typing import List
import torch
import torch.nn as nn
from torch.autograd.function import Function
from torch.util... | bart_ls-main | xformers/xformers/components/reversible.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from enum import Enum
from typing import Optional
import torch
from torch import nn
class Activation(str, Enum):
... | bart_ls-main | xformers/xformers/components/activations.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import asdict, dataclass
from typing import Optional
import torch
import torch.nn as nn
from torch.n... | bart_ls-main | xformers/xformers/components/multi_head_dispatch.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import fields
from pathlib import Path
from typing import Any, Dict, Union
from xformers.utils import ... | bart_ls-main | xformers/xformers/components/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from typing import Optional
import torch
import torch.nn as nn
from xformers.compone... | bart_ls-main | xformers/xformers/components/attention/global_tokens.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
from dataclasses import dataclass
from enum import Enum
from typing import Optional
import torch
import ... | bart_ls-main | xformers/xformers/components/attention/ortho.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
import math
from dataclasses import dataclass
from typing import Optional
import torch
from xformers im... | bart_ls-main | xformers/xformers/components/attention/blocksparse.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from typing import Optional
import torch
import torch.nn as nn
from xformers.compone... | bart_ls-main | xformers/xformers/components/attention/local.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# Credits: this is heavily inspired by the official implementation, present in
# https://github.com/sarthmit/Composition... | bart_ls-main | xformers/xformers/components/attention/compositional.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 dataclasses import dataclass
from typing import Optional
from typing import Union
from functools import lru_cache
import math
import to... | bart_ls-main | xformers/xformers/components/attention/longformer.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
from pathlib import Path
from typing import Any, Callable, Dict, Set, Union
import torch
from xformers.u... | bart_ls-main | xformers/xformers/components/attention/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from typing import Optional
import torch
import torch.nn as nn
from functools import ... | bart_ls-main | xformers/xformers/components/attention/simple_block.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
from xformers.ops import masked_matmul
from xformers.sparse import SparseCSRTensor
# TODO: this is here f... | bart_ls-main | xformers/xformers/components/attention/_sputnik_sparse.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import math
from contextlib import nullcontext
from typing import Optional, Union
import torch
from xformers import _i... | bart_ls-main | xformers/xformers/components/attention/core.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
import torch
from xformers.components.attention import Attention, AttentionConfig, r... | bart_ls-main | xformers/xformers/components/attention/lambda_layer.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from typing import Optional
import torch
import torch.nn as nn
from xformers.compone... | bart_ls-main | xformers/xformers/components/attention/random.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 dataclasses import dataclass
from typing import Optional
from functools import partial, reduce
from inspect import isfunction
from opera... | bart_ls-main | xformers/xformers/components/attention/lsh_global.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 dataclasses import dataclass
from typing import Optional
import math
import torch
from torch import Tensor
import torch.nn as nn
import... | bart_ls-main | xformers/xformers/components/attention/longshort.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
from xformers.components.attention import Attention, AttentionConfig, register_attention
@register_attent... | bart_ls-main | xformers/xformers/components/attention/fourier_mix.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
from dataclasses import dataclass
from typing import Optional, Union
import torch
from torch import nn
f... | bart_ls-main | xformers/xformers/components/attention/scaled_dot_product.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
import torch
# Reshapes key padding mask from (batch_size, src_len) -> (batch_size * num_... | bart_ls-main | xformers/xformers/components/attention/utils.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional, Type, TypeVar
import torch
Self = TypeVar("Self", bound="AttentionMask")
class Attentio... | bart_ls-main | xformers/xformers/components/attention/attention_mask.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
import math
from dataclasses import dataclass
from typing import Optional
from functools import partial
... | bart_ls-main | xformers/xformers/components/attention/blocksparse_local.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
"""
Simple non-ovelapping local block attention. To test how strong are the locality inductive bias in these tasks
"""
... | bart_ls-main | xformers/xformers/components/attention/block_noglobal.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from typing import Optional
from torch import Tensor
import torch.nn.functional as F
... | bart_ls-main | xformers/xformers/components/attention/linformer.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import math
from typing import List
import numpy as np
import torch
# generic nd cases
def _generate_nd_grid(*sizes):... | bart_ls-main | xformers/xformers/components/attention/attention_patterns.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
from dataclasses import dataclass
from typing import Optional
import torch
import torch.nn as nn
from x... | bart_ls-main | xformers/xformers/components/attention/nystrom.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 dataclasses import dataclass
from typing import Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch ... | bart_ls-main | xformers/xformers/components/attention/lsh_reformer.py |
"""
Simple non-ovelapping local block attention. To test how strong are the locality inductive bias in these tasks
"""
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree... | bart_ls-main | xformers/xformers/components/attention/block.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
import math
from dataclasses import dataclass
from typing import Optional, Tuple
import torch
import torc... | bart_ls-main | xformers/xformers/components/attention/favor.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 dataclasses import dataclass
from typing import Optional
from functools import partial, reduce
from inspect import isfunction
from opera... | bart_ls-main | xformers/xformers/components/attention/sinkhorn.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from abc import ABCMeta, abstractmethod
from dataclasses import asdict, dataclass
from typing import Optional, Type, Typ... | bart_ls-main | xformers/xformers/components/attention/base.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from enum import Enum
from .base import FeatureMap, FeatureMapConfig
from .softmax import NormDistribution, SMHyperboli... | bart_ls-main | xformers/xformers/components/attention/feature_maps/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import math
from enum import Enum, auto
from typing import Optional
import torch
from torch.autograd.profiler import re... | bart_ls-main | xformers/xformers/components/attention/feature_maps/softmax.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from abc import abstractmethod
from dataclasses import asdict, dataclass
from typing import Optional, Type, TypeVar
imp... | bart_ls-main | xformers/xformers/components/attention/feature_maps/base.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from pathlib import Path
from typing import Any, Callable, Dict, Set, Union
from xformers.utils import (
generate_m... | bart_ls-main | xformers/xformers/components/feedforward/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
from dataclasses import dataclass
from enum import Enum
from typing import Any, Callable, Optional, Union... | bart_ls-main | xformers/xformers/components/feedforward/mixture_of_experts.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
import torch
import torch.nn as nn
from xformers.components import Activation, build... | bart_ls-main | xformers/xformers/components/feedforward/mlp.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
from dataclasses import dataclass
import torch
import torch.nn as nn
from xformers.components import Ac... | bart_ls-main | xformers/xformers/components/feedforward/fused_mlp.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from abc import ABCMeta, abstractmethod
from dataclasses import asdict, dataclass
from typing import Optional, Type, Typ... | bart_ls-main | xformers/xformers/components/feedforward/base.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from typing import Optional
import torch
import torch.nn as nn
from xformers.compone... | bart_ls-main | xformers/xformers/components/positional_embedding/vocab.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from pathlib import Path
from typing import Any, Callable, Dict, Set, Union
from xformers.utils import (
generate_m... | bart_ls-main | xformers/xformers/components/positional_embedding/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# Silence Mypy errors in this file.
# type: ignore
from __future__ import annotations
import math
from typing import T... | bart_ls-main | xformers/xformers/components/positional_embedding/sine.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# CREDITS: This implementation is inspired by GPT-NeoX https://github.com/EleutherAI/gpt-neox
# NOTE: Almost the same ri... | bart_ls-main | xformers/xformers/components/positional_embedding/rotary.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from abc import ABCMeta, abstractmethod
from dataclasses import asdict, dataclass
from typing import Type, TypeVar
impo... | bart_ls-main | xformers/xformers/components/positional_embedding/base.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
from .utils import _csr_to_coo, _transpose_with_info
def _should_use_coo(a, sparsity):
if not a.is_c... | bart_ls-main | xformers/xformers/sparse/_csr_ops.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from .csr_tensor import SparseCSRTensor # noqa: F401
| bart_ls-main | xformers/xformers/sparse/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
def _coo_to_csr(m, n, row_indices, column_indices):
# assumes coalesced coo
row_offsets = row_ind... | bart_ls-main | xformers/xformers/sparse/utils.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
from xformers.ops import masked_matmul
from xformers.sparse import _csr_ops
from xformers.sparse.utils imp... | bart_ls-main | xformers/xformers/sparse/csr_tensor.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import tempfile
import torch
def init_torch_distributed_local():
if torch.distributed.is_initialized():
r... | bart_ls-main | xformers/xformers/helpers/test_utils.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from .timm_sparse_attention import TimmSparseAttention # noqa
| bart_ls-main | xformers/xformers/helpers/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import torch
from xformers.components.attention.core import scaled_dot_product_attention
class TimmSparseAttention(to... | bart_ls-main | xformers/xformers/helpers/timm_sparse_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.
from xformers.components import MultiHeadDispatchConfig # noqa
from xformers.components.attention import AttentionConfig # noqa
from xforme... | bart_ls-main | xformers/xformers/factory/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
# register components configs into Hydra ConfigStore
# component config classes could be used to validate configs
import ... | bart_ls-main | xformers/xformers/factory/hydra_helper.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import asdict, dataclass
from enum import Enum
from typing import Any, Dict, Optional, Tuple, Union
im... | bart_ls-main | xformers/xformers/factory/block_factory.py |
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
#
# This source code is licensed under the BSD license found in the
# LICENSE file in the root directory of this source tree.
import logging
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Union
import torch
from... | bart_ls-main | xformers/xformers/factory/model_factory.py |
#!/usr/bin/env python3
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import sys
import os
import argparse
import json
import random
import shutil
import torch
torch.backends.cu... | clevr-iep-main | scripts/train_model.py |
#!/usr/bin/env python3
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import sys
import os
sys.path.insert(0, os.path.abspath('.'))
import argparse
import json
import os
import... | clevr-iep-main | scripts/preprocess_questions.py |
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse, os, json
import h5py
import numpy as np
from scipy.misc import imread, imresize
import torch
import torchvision
p... | clevr-iep-main | scripts/extract_features.py |
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import json
import random
import shutil
import sys
import os
import torch
from torch.autograd import Variable
import... | clevr-iep-main | scripts/run_model.py |
#!/usr/bin/env python3
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
"""
Utilities for preprocessing sequence data.
Special tokens that are in all dictionaries:
<NULL>: Extra p... | clevr-iep-main | iep/preprocess.py |
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
"""
Utilities for dealing with embeddings.
"""
def convert_pretrained_wordvecs(vocab, word2vec):
N = len(vocab['question_idx_to_t... | clevr-iep-main | iep/embedding.py |
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
| clevr-iep-main | iep/__init__.py |
#!/usr/bin/env python3
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
"""
Utilities for working with and converting between the various data structures
used to represent programs.... | clevr-iep-main | iep/programs.py |
#!/usr/bin/env python3
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import json
import torch
from iep.models import ModuleNet, Seq2Seq, LstmModel, CnnLstmModel, CnnLstmSaModel
... | clevr-iep-main | iep/utils.py |
#!/usr/bin/env python3
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import h5py
import torch
from torch.utils.data import Dataset, DataLoader
from torch.utils... | clevr-iep-main | iep/data.py |
#!/usr/bin/env python3
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the 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 torch.autograd import Variable
from ... | clevr-iep-main | iep/models/baselines.py |
#!/usr/bin/env python3
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the 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 torch.autograd import Var... | clevr-iep-main | iep/models/module_net.py |
#!/usr/bin/env python3
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from iep.models.module_net import ModuleNet
from iep.models.seq2seq import Seq2Seq
from iep.models.baselines ... | clevr-iep-main | iep/models/__init__.py |
#!/usr/bin/env python3
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the 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 ResidualBlock(nn.Module):
def __... | clevr-iep-main | iep/models/layers.py |
#!/usr/bin/env python3
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.cuda
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd impo... | clevr-iep-main | iep/models/seq2seq.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# This source code is licensed under the CC-BY-NC license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
class Battery:
capacity = 0 # Max MWh storage capacity
current_load = 0 # Current load in the battery, in MWh... | CarbonExplorer-main | src/battery.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# This source code is licensed under the CC-BY-NC license found in the
# LICENSE file in the root directory of this source tree.
# Function that calculates pareto frontier given a set of points
def pareto_frontier(Xs, Ys, maxX=True, maxY= True):
# Sort the list ... | CarbonExplorer-main | src/utils.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# This source code is licensed under the CC-BY-NC license found in the
# LICENSE file in the root directory of this source tree.
import pandas as pd
# Carbon Aware Scheduling Algorithm, to optimize for 24/7
# takes a dataframe that contains renewable and dc power, ... | CarbonExplorer-main | src/cas.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# This source code is licensed under the CC-BY-NC license found in the
# LICENSE file in the root directory of this source tree.
import wget
import zipfile
import pandas as pd
import math
import re
import numpy as np
# Download EIA's U.S. Electric System Operating ... | CarbonExplorer-main | src/download_and_process.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import setuptools
setuptools.setup(
name="co3d",
version="2.1.0",
author="FAIR",
author_email... | co3d-main | setup.py |
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
| co3d-main | tests/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import os
import unittest
import torch
import torchvision
from visdom import Visdom
_CO3DV2_DATASET_ROOT: str = os.getenv... | co3d-main | tests/test_dataset_visualize.py |
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import dataclasses
from typing import Dict, List, NamedTuple, Tuple
import unittest
from co3d.dataset import data_types as... | co3d-main | tests/test_types.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import os
import unittest
import numpy as np
import tempfile
import torch
from pytorch3d.renderer.cameras imp... | co3d-main | tests/test_challenge_evaluate.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import os
import json
from joblib import Parallel, delayed
from collections import defaultdict
from tabulate i... | co3d-main | examples/print_co3d_stats.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
import torch
import math
import sys
import json
import random
from tqdm import tqdm
... | co3d-main | examples/show_co3d_dataset.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
import torch
import warnings
from tqdm import tqdm
from omegaconf import DictConfig
... | co3d-main | examples/example_co3d_challenge_submission.py |
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import os
from dataset.download_dataset_impl import build_arg_parser, download_dataset
DEFAULT_LINK_LIST_FILE = os.path.... | co3d-main | co3d/download_dataset.py |
co3d-main | co3d/__init__.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.