python_code
stringlengths
0
992k
repo_name
stringlengths
8
46
file_path
stringlengths
5
162
# 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: # inspired by # https://github.com/nateraw/lightning-vision-transformer # which in turn references https://gi...
EXA-1-master
exa/libraries/xformers/examples/cifar_ViT.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. # A MinGPT + Lightning + xFormers example Code from Sean Naren (@seannaren) # This is an hommage to https://github.com/ka...
EXA-1-master
exa/libraries/xformers/examples/microGPT.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 hydra from omegaconf import DictConfig from xformers.factory.hydra_helper import import_xformer_config_schema @...
EXA-1-master
exa/libraries/xformers/examples/build_model/my_model.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 glob import os import shlex import subprocess import sys import torch import xformers # Build failed - return e...
EXA-1-master
exa/libraries/xformers/.github/run_benchmark_wrapper.py
#!/usr/bin/env python """ MIT License Copyright (c) 2017 Guillaume Papin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, m...
EXA-1-master
exa/libraries/xformers/.github/run-clang-format.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 glob import os import subprocess import xformers.benchmarks.utils as utils class NamedObject: def __init__(...
EXA-1-master
exa/libraries/xformers/.github/gpu_benchmark_diff.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 os import torch from . import _cpp_lib try: from .version import __version__ # noqa: F401 e...
EXA-1-master
exa/libraries/xformers/xformers/__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.
EXA-1-master
exa/libraries/xformers/xformers/test.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 importlib import os import sys from collections import namedtuple from dataclasses import fields from typing impo...
EXA-1-master
exa/libraries/xformers/xformers/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 dataclasses import json import logging import os import platform from typing import Any, Dict, Optional import to...
EXA-1-master
exa/libraries/xformers/xformers/_cpp_lib.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 Dict import torch from . import ( __version__, _cpp_lib, _is_functorch_available, _...
EXA-1-master
exa/libraries/xformers/xformers/info.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. # Generates combination of kernels - implementations and registry # Kernels are ordered (see `sort_index`), and when dis...
EXA-1-master
exa/libraries/xformers/xformers/csrc/attention/cuda/fmha/generate_kernels.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 Any, Optional import torch import torch.nn as nn from torch.cuda.amp import custom_bwd, c...
EXA-1-master
exa/libraries/xformers/xformers/triton/fused_linear_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. import torch import triton from xformers.triton.k_sum import k_sum_0 def sum_2d_dim_0(x: torch.Tensor): """ S...
EXA-1-master
exa/libraries/xformers/xformers/triton/sum_strided.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 Optional import triton import triton.language as tl from xformers.components import Acti...
EXA-1-master
exa/libraries/xformers/xformers/triton/k_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. import torch _triton_available = torch.cuda.is_available() if _triton_available: try: from .dropout import ...
EXA-1-master
exa/libraries/xformers/xformers/triton/__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. # CREDITS: This comes almost as-is from the Triton layer norm tutorial # https://github.com/openai/triton/blob/master/py...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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 logger = logging.getLogger("xformers") _gpu_is_old: Optional[...
EXA-1-master
exa/libraries/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. from typing import Optional import torch import triton import triton.language as tl from xformers.triton.k_activations ...
EXA-1-master
exa/libraries/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 is heavily inspired by the Triton dropout tutorial # https://raw.githubusercontent.com/openai/triton/mas...
EXA-1-master
exa/libraries/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 is heavily inspired by the Triton dropout tutorial # https://raw.githubusercontent.com/openai/triton/mas...
EXA-1-master
exa/libraries/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 typing import Optional import torch import triton from torch.cuda.amp import custom_bwd, custom_fwd...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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.k_activations...
EXA-1-master
exa/libraries/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 triton import triton.language as tl # CREDITS: This is adapted from the vanilla Triton example. See https://open...
EXA-1-master
exa/libraries/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 asdict, dataclass from typing import Optional, Type, TypeVar import torch from xformers import ...
EXA-1-master
exa/libraries/xformers/xformers/components/simplicial_embedding.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, Optional, Tuple, Union import torch import torch.nn as nn from xformers...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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): ...
EXA-1-master
exa/libraries/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. import logging from dataclasses import asdict, dataclass from typing import Optional, Tuple import torch import torch.n...
EXA-1-master
exa/libraries/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 ...
EXA-1-master
exa/libraries/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. # CREDITS: Inspired by https://github.com/pytorch/text/blob/master/torchtext/nn/modules/multiheadattention.py # and the M...
EXA-1-master
exa/libraries/xformers/xformers/components/input_projection.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 enum import Enum import torch class PoolType(str, Enum): Conv2D...
EXA-1-master
exa/libraries/xformers/xformers/components/patch_embedding.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, Union import torch import torch.nn as nn from xformers....
EXA-1-master
exa/libraries/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, Union import torch ...
EXA-1-master
exa/libraries/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 import torch from xformers import _is_triton_available fr...
EXA-1-master
exa/libraries/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, Union import torch import torch.nn as nn from xformers....
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/xformers/xformers/components/attention/compositional.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 import torch import torch.nn as nn from xfor...
EXA-1-master
exa/libraries/xformers/xformers/components/attention/pooling.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...
EXA-1-master
exa/libraries/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. import torch from xformers.ops import masked_matmul from xformers.sparse import SparseCSRTensor # TODO: this is here f...
EXA-1-master
exa/libraries/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 logging import math from contextlib import nullcontext from functools import lru_cache from typing import Optiona...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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, Union import torch import torch.nn as nn from xformers....
EXA-1-master
exa/libraries/xformers/xformers/components/attention/random.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 torch.cuda.amp import autocast from xformers.components.attention import Attention, AttentionConfig, r...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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_...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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. from dataclasses import dataclass from typing import Optional import torch import torch.nn as nn from xformers.compone...
EXA-1-master
exa/libraries/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 from xformers.components.attention.sparsity_config...
EXA-1-master
exa/libraries/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 math from dataclasses import dataclass import torch import torch.nn as nn from xformers.components.attention im...
EXA-1-master
exa/libraries/xformers/xformers/components/attention/visual.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. """ The code has been adopted from DeepSpeed (https://github.com/microsoft/DeepSpeed/blob/master/deepspeed/ops/sparse_atte...
EXA-1-master
exa/libraries/xformers/xformers/components/attention/sparsity_config.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...
EXA-1-master
exa/libraries/xformers/xformers/components/attention/nystrom.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...
EXA-1-master
exa/libraries/xformers/xformers/components/attention/favor.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...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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 import xformers from xformers.components import A...
EXA-1-master
exa/libraries/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. # CREDITS: Largely reusing the code from the reference VAN implementation # see https://github.com/Visual-Attention-Netw...
EXA-1-master
exa/libraries/xformers/xformers/components/feedforward/conv_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...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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. from dataclasses import dataclass import torch from xformers.components.positional_embedding import ( PositionEmbe...
EXA-1-master
exa/libraries/xformers/xformers/components/positional_embedding/param.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 import math import torch from xformers.components.positional_embed...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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...
EXA-1-master
exa/libraries/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 functools from typing import Optional import torch import torch.nn as nn from functorch.compile import memory_ef...
EXA-1-master
exa/libraries/xformers/xformers/components/nvfuser/bias_dropout_res_layernorm.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 functools from typing import Optional import torch import torch.nn as nn from functorch.compile import memory_ef...
EXA-1-master
exa/libraries/xformers/xformers/components/nvfuser/bias_act_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. from xformers import _is_functorch_available if _is_functorch_available: # noqa try: from .bias_act_dropou...
EXA-1-master
exa/libraries/xformers/xformers/components/nvfuser/__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 typing import Any, Dict, List, Optional import torch.nn as nn from xformers.components import Activation, Residual...
EXA-1-master
exa/libraries/xformers/xformers/components/nvfuser/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 functools from typing import Optional import torch import torch.nn as nn from functorch.compile import memory_ef...
EXA-1-master
exa/libraries/xformers/xformers/components/nvfuser/bias_dropout_res.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 itertools import random from functools import partial import torch from torch.utils import benchmark from utils ...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_mem_eff_attention.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 functools import partial from typing import Any, Dict, List, Optional import torch import torch.nn as nn import tri...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_nvfuser.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 itertools import random import torch from torch.utils import benchmark from utils import benchmark_main_helper ...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_indexing.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 argparse from typing import Any, Dict import torch import triton from xformers.benchmarks.utils import TestCase...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_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 typing import Any, Dict, List import torch import triton from xformers.benchmarks.utils import TestCase, pretty_pl...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_triton_stride_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 gc import math from collections import namedtuple from dataclasses import dataclass import matplotlib.pyplot as ...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_blocksparse_transformers.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 itertools from functools import partial, reduce import timm import torch import torch.nn as nn from timm.models....
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_transformer.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 Any, Dict import torch import triton from xformers.benchmarks.utils import TestCase, pretty_plot, p...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_revnet.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 itertools from contextlib import nullcontext from functools import partial from typing import Any import torch f...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_swiglu.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 Any, Dict import torch import triton from xformers.benchmarks.utils import TestCase, pretty_plot, p...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_triton_layernorm.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 os from typing import Any, Dict import torch import triton from xformers.benchmarks.utils import TestCase, pret...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_causal_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 typing import Any, Dict, List, Optional import torch import triton from xformers.benchmarks.utils import TestCase...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_triton_fused_linear.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.
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/__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. # Benchmark the blocksparse operations: # matrix multiply and softmax # Matmul can be of three types: # - Dense x Dense...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_triton_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. import torch from xformers.benchmarks.utils import TestCase, bench_functions from xformers.triton.softmax import log_sof...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_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. import argparse import contextlib import copy import csv import glob import logging import math import os import tempfile...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/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 argparse import json import time from contextlib import suppress from typing import Any, Dict, List, Optional imp...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_encoder.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 Any, Dict, Optional import torch import triton from xformers.benchmarks.utils import TestCase, pret...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_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. import random import time from typing import Any, Dict, List, Tuple import torch import triton from torch.cuda.amp impor...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_pytorch_transformer.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 Callable import torch from torch.utils import benchmark from xformers.components.attention.utils imp...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_nystrom_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 Any, Dict import torch import torch.nn as nn import triton from xformers.benchmarks.utils import Te...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_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. import itertools import torch from torch.utils import benchmark from xformers.components.attention._sputnik_sparse impo...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_sddmm.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 itertools import torch from torch.utils import benchmark from xformers.components.attention.core import ( Sp...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/benchmark_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. import argparse import os from pathlib import Path from xformers.benchmarks.LRA.run_tasks import Task from xformers.com...
EXA-1-master
exa/libraries/xformers/xformers/benchmarks/LRA/batch_submit.py