repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
tvm | tvm-main/tests/python/frontend/mxnet/test_qnn_ops_utils.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 7,760 | 33.493333 | 99 | py |
tvm | tvm-main/tests/python/frontend/mxnet/test_forward.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 93,053 | 38.313054 | 104 | py |
tvm | tvm-main/tests/python/frontend/mxnet/test_graph.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 3,841 | 29.983871 | 80 | py |
tvm | tvm-main/tests/python/frontend/mxnet/model_zoo/resnet.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 10,688 | 31.688073 | 100 | py |
tvm | tvm-main/tests/python/frontend/mxnet/model_zoo/squeezenet.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 3,892 | 38.72449 | 96 | py |
tvm | tvm-main/tests/python/frontend/mxnet/model_zoo/vgg.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 4,491 | 40.211009 | 98 | py |
tvm | tvm-main/tests/python/frontend/mxnet/model_zoo/mlp.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 1,950 | 45.452381 | 100 | py |
tvm | tvm-main/tests/python/frontend/mxnet/model_zoo/dqn.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 1,745 | 40.571429 | 93 | py |
tvm | tvm-main/tests/python/frontend/mxnet/model_zoo/dcgan.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 3,190 | 33.684783 | 98 | py |
tvm | tvm-main/tests/python/frontend/mxnet/model_zoo/inception_v3.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 11,306 | 29.642276 | 127 | py |
tvm | tvm-main/tests/python/frontend/tensorflow2/test_sequential_models.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 5,746 | 33.005917 | 108 | py |
tvm | tvm-main/tests/python/frontend/caffe2/test_forward.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 7,906 | 29.647287 | 100 | py |
tvm | tvm-main/tests/python/frontend/caffe2/test_graph.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 1,507 | 34.904762 | 81 | py |
tvm | tvm-main/tests/python/frontend/caffe2/model_zoo/__init__.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 1,497 | 29.571429 | 90 | py |
tvm | tvm-main/tests/python/frontend/tflite/test_forward.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 197,489 | 34.822601 | 100 | py |
tvm | tvm-main/tests/python/frontend/coreml/test_forward.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 29,386 | 33.695396 | 99 | py |
tvm | tvm-main/tests/python/frontend/onnx/test_forward.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 296,438 | 33.732162 | 100 | py |
tvm | tvm-main/tests/python/frontend/keras/test_forward.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 38,227 | 43.399535 | 100 | py |
tvm | tvm-main/tests/python/frontend/caffe/test_forward.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 35,361 | 29.301628 | 99 | py |
tvm | tvm-main/tests/python/frontend/pytorch/test_lstm.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 13,252 | 34.530831 | 111 | py |
tvm | tvm-main/tests/python/frontend/pytorch/test_fx_quant.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 3,436 | 35.956989 | 100 | py |
tvm | tvm-main/tests/python/frontend/pytorch/test_forward.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 181,726 | 32.005267 | 108 | py |
tvm | tvm-main/tests/python/frontend/pytorch/qnn_test.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 28,002 | 33.829602 | 122 | py |
tvm | tvm-main/tests/python/frontend/pytorch/test_object_detection.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 5,488 | 31.672619 | 99 | py |
tvm | tvm-main/tests/python/frontend/pytorch/test_rnns.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 18,137 | 33.747126 | 168 | py |
tvm | tvm-main/tests/python/frontend/tensorflow/test_forward.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 216,228 | 34.435759 | 113 | py |
tvm | tvm-main/tests/python/nightly/quantization/test_quantization_accuracy.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 6,833 | 29.64574 | 99 | py |
tvm | tvm-main/tests/python/contrib/test_dnnl.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 63,695 | 33.806557 | 133 | py |
tvm | tvm-main/tests/python/contrib/test_libtorch_ops.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 3,149 | 32.510638 | 92 | py |
tvm | tvm-main/tests/python/contrib/test_dlpack.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 2,544 | 33.391892 | 82 | py |
tvm | tvm-main/tests/python/contrib/test_tensorrt.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 53,474 | 36.898653 | 133 | py |
tvm | tvm-main/tests/python/contrib/test_mxnet_bridge.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 2,041 | 30.90625 | 75 | py |
tvm | tvm-main/tests/python/contrib/test_tensorrt_int8_exp.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 5,224 | 32.280255 | 96 | py |
tvm | tvm-main/tests/python/contrib/test_clml/test_network.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 6,326 | 34.15 | 99 | py |
tvm | tvm-main/tests/python/contrib/test_arm_compute_lib/test_network.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 6,771 | 28.189655 | 135 | py |
tvm | tvm-main/tests/python/contrib/test_hexagon/metaschedule_e2e/export_models.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 2,593 | 31.425 | 74 | py |
tvm | tvm-main/tests/python/contrib/test_ethosu/test_legalize.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 142,954 | 36.511152 | 117 | py |
tvm | tvm-main/tests/python/contrib/test_ethosu/test_codegen.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 48,728 | 30.03758 | 120 | py |
tvm | tvm-main/tests/python/contrib/test_uma/test_uma_pipeline.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 7,831 | 34.762557 | 100 | py |
tvm | tvm-main/tests/python/topi/python/test_topi_image.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 13,145 | 36.452991 | 99 | py |
tvm | tvm-main/tests/scripts/request_hook/request_hook.py | #!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "Lic... | 29,189 | 117.658537 | 683 | py |
tvm | tvm-main/tests/scripts/release/make_notes.py | #!/usr/bin/env python3
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "L... | 7,805 | 29.138996 | 99 | py |
tvm | tvm-main/vta/tutorials/frontend/deploy_classification.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 12,219 | 38.546926 | 97 | py |
tvm | tvm-main/vta/tutorials/autotvm/tune_alu_vta.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 11,793 | 33.58651 | 95 | py |
tvm | tvm-main/vta/tutorials/autotvm/tune_relay_vta.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 22,597 | 41.397749 | 322 | py |
tvm | tvm-main/vta/scripts/tune_resnet.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 13,325 | 34.631016 | 98 | py |
tvm | tvm-main/docs/legacy_redirect.py | # -*- coding: utf-8 -*-
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# ... | 13,700 | 49.00365 | 100 | py |
tvm | tvm-main/docs/conf.py | # -*- coding: utf-8 -*-
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# ... | 24,952 | 33.323246 | 100 | py |
tvm | tvm-main/rust/tvm/examples/resnet/src/build_resnet.py | #!/usr/bin/env python3
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "L... | 5,428 | 32.720497 | 100 | py |
synthetic-histology | synthetic-histology-main/interpolation_probability.py | """Plot a probability map of classifier predictions during interpolation."""
import os
import re
import click
import torch
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import slideflow as sf
from os.path import join
from typing import List
from slideflow.gan.interpolate... | 5,206 | 35.669014 | 132 | py |
synthetic-histology | synthetic-histology-main/concordance.py | """Determine classifier concordance for some seeds."""
import os
import re
import click
import torch
import slideflow as sf
from typing import List
from slideflow.gan.interpolate import StyleGAN2Interpolator
# Allow GPU memory growth, so Tensorflow & PyTorch can play nice
import tensorflow as tf
gpus = tf.config.exp... | 3,909 | 36.238095 | 132 | py |
synthetic-histology | synthetic-histology-main/interpolate.py | """Generate images using pretrained network pickle."""
import os
import re
from os.path import join
from typing import List, Optional
import click
import torch
from PIL import Image
from slideflow.gan.stylegan3.stylegan3 import embedding, utils
#----------------------------------------------------------------------... | 3,885 | 39.479167 | 132 | py |
mmf | mmf-main/setup.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
import codecs
import os
import platform
import re
from glob import glob
import setuptools
from setuptools import Extension
from setuptools.command.build_ext import build_ext
def clean_html(raw_html):
cleanr = re.compile("<.*?>")
clea... | 5,214 | 30.993865 | 88 | py |
mmf | mmf-main/tools/sweeps/lib/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
# Copied from fairseq. Mostly written by @myleott. Adapted accordingly for mmf
import argparse
import datetime
import json
import os
import socket
# if argv is None, we will read from sys.argv (invoke params)
def get_args(argv=None):
parser = argparse.ArgumentPa... | 9,350 | 33.505535 | 87 | py |
mmf | mmf-main/tools/scripts/features/extract_resnet152_feat.py | # Copyright (c) Facebook, Inc. and its affiliates.
import argparse
import os
from glob import glob
import numpy as np
import torch
import torch.nn as nn
import torchvision.models as models
import torchvision.transforms as transforms
from mmf.common.constants import IMAGE_COLOR_MEAN, IMAGE_COLOR_STD
from PIL import Im... | 4,117 | 29.503704 | 84 | py |
mmf | mmf-main/tools/scripts/features/extract_features_vmb.py | # Copyright (c) Facebook, Inc. and its affiliates.
# Requires vqa-maskrcnn-benchmark (https://gitlab.com/vedanuj/vqa-maskrcnn-benchmark)
# to be built and installed. Category mapping for visual genome can be downloaded from
# https://dl.fbaipublicfiles.com/pythia/data/visual_genome_categories.json
# When the --backgro... | 11,242 | 37.372014 | 88 | py |
mmf | mmf-main/tools/scripts/features/extract_features_vinvl.py | # Copyright (c) Facebook, Inc. and its affiliates.
# This script extracts features for vinvl using their scene-graph-benchmark repo.
# Their AttrRCNN model can not support JIT, so we need clone the repo for
# their pytorch code. This script assumes you followed the vinvl feature
# extraction tutorial! The setup can be... | 11,527 | 36.921053 | 87 | py |
mmf | mmf-main/tools/scripts/features/frcnn/frcnn_utils.py | # Copyright (c) Facebook, Inc. and its affiliates.
"""
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal, Huggingface team :)
Adapted From Facebook Inc, Detectron2
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You... | 10,991 | 30.677233 | 87 | py |
mmf | mmf-main/tools/scripts/features/frcnn/modeling_frcnn.py | # Copyright (c) Facebook, Inc. and its affiliates.
"""
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
Adapted From Facebook Inc, Detectron2 && Huggingface Co.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You ... | 75,257 | 35.53301 | 88 | py |
mmf | mmf-main/tools/scripts/features/frcnn/extract_features_frcnn.py | # Copyright (c) Facebook, Inc. and its affiliates.
"""
Run with for example:
python3 mmf/tools/scripts/features/frcnn/extract_features_frcnn.py \
--model_file model.bin --config_file config.yaml --image_dir \
./example_images --output_folder ./output_features
"""
import argparse
import copy
import logging
imp... | 11,669 | 34.907692 | 88 | py |
mmf | mmf-main/tools/scripts/features/frcnn/processing_image.py | # Copyright (c) Facebook, Inc. and its affiliates.
"""
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
Adapted From Facebook Inc, Detectron2
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of... | 4,313 | 36.513043 | 87 | py |
mmf | mmf-main/tools/scripts/bert/extract_bert_embeddings.py | # Copyright (c) Facebook, Inc. and its affiliates.
import argparse
import numpy as np
import torch
from tqdm import tqdm
try:
from transformers3.modeling_bert import BertModel
from transformers3.tokenization_auto import AutoTokenizer
except ImportError:
from transformers.modeling_bert import BertModel
... | 2,184 | 33.140625 | 77 | py |
mmf | mmf-main/mmf/modules/losses.py | # Copyright (c) Facebook, Inc. and its affiliates.
"""
Losses module contains implementations for various losses used generally
in vision and language space. One can register custom losses to be detected by
MMF using the following example.
.. code::
from mmf.common.registry import registry
from torch import nn
... | 37,373 | 32.191829 | 88 | py |
mmf | mmf-main/mmf/modules/hf_layers.py | # Copyright (c) Facebook, Inc. and its affiliates.
import math
from typing import List, Optional, Tuple
import torch
from mmf.utils.patch import restore_saved_modules, safecopy_modules
from torch import nn, Tensor
try:
from transformers3.modeling_bert import (
BertAttention,
BertEmbeddings,
... | 20,941 | 37.145719 | 99 | py |
mmf | mmf-main/mmf/modules/schedulers.py | # Copyright (c) Facebook, Inc. and its affiliates.
from bisect import bisect_right
from mmf.common.registry import registry
from torch.optim.lr_scheduler import LambdaLR
try:
from transformers3.optimization import (
get_cosine_schedule_with_warmup,
get_linear_schedule_with_warmup,
)
except Im... | 2,333 | 33.323529 | 87 | py |
mmf | mmf-main/mmf/modules/optimizers.py | # Copyright (c) Facebook, Inc. and its affiliates.
import math
from typing import Callable
import torch
from mmf.common.registry import registry
try:
from transformers3.optimization import AdamW
except ImportError:
from transformers.optimization import AdamW
registry.register_optimizer("adam_w")(AdamW)
@r... | 3,567 | 39.089888 | 148 | py |
mmf | mmf-main/mmf/modules/fusions.py | # Copyright (c) Facebook, Inc. and its affiliates.
"""
The fusions module contains various Fusion techniques, some based on BLOCK:
Bilinear Superdiagonal Fusion for VQA and VRD. For e.g. LinearSum, ConcatMLP
etc taken from https://github.com/Cadene/block.bootstrap.pytorch#fusions.
For implementing your own fusion tec... | 25,035 | 32.336884 | 86 | py |
mmf | mmf-main/mmf/modules/embeddings.py | # Copyright (c) Facebook, Inc. and its affiliates.
# TODO: Update kwargs with defaults
import os
import pickle
from copy import deepcopy
from functools import lru_cache
from typing import Optional, Tuple
import numpy as np
import torch
from mmf.modules.attention import AttentionLayer, SelfAttention, SelfGuidedAttenti... | 21,110 | 32.7776 | 87 | py |
mmf | mmf-main/mmf/modules/vit.py | # Copyright (c) Facebook, Inc. and its affiliates.
from collections import namedtuple
from dataclasses import asdict, dataclass
import torch
from mmf.utils.general import retry_n
from omegaconf import OmegaConf
from packaging import version
from torch import nn
try:
from transformers3 import __version__ as trans... | 11,718 | 33.06686 | 88 | py |
mmf | mmf-main/mmf/modules/layers.py | # Copyright (c) Facebook, Inc. and its affiliates.
from typing import Optional
import torch
from mmf.common.registry import registry
from mmf.modules.decoders import LanguageDecoder
from torch import nn
from torch.nn.utils.weight_norm import weight_norm
class ConvNet(nn.Module):
def __init__(
self,
... | 27,005 | 32.136196 | 88 | py |
mmf | mmf-main/mmf/modules/poolers.py | # Copyright (c) Facebook, Inc. and its affiliates.
"""
This module contains implementations for various pooling methods from
transformer encoder layers
.. code::
from mmf.common.registry import registry
from torch import nn
@registry.register_pooler("custom")
class CustomPool(nn.Module):
...
"""
f... | 4,053 | 30.92126 | 86 | py |
mmf | mmf-main/mmf/modules/metrics.py | # Copyright (c) Facebook, Inc. and its affiliates.
"""
The metrics module contains implementations of various metrics used commonly to
understand how well our models are performing. For e.g. accuracy, vqa_accuracy,
r@1 etc.
For implementing your own metric, you need to follow these steps:
1. Create your own metric cl... | 46,027 | 32.137509 | 209 | py |
mmf | mmf-main/mmf/modules/ot.py | # Copyright (c) Facebook, Inc. and its affiliates.
"""
Initial version was taken from https://github.com/ChenRocks/UNITER/
Licensed under the MIT license.
Wasserstein Distance (Optimal Transport)
"""
import torch
from torch import Tensor
from torch.nn import functional as F
def cost_matrix_cosine(x: Tensor, y: Ten... | 3,115 | 29.252427 | 88 | py |
mmf | mmf-main/mmf/modules/bottleneck.py | # Copyright (c) Facebook, Inc. and its affiliates.
from collections import OrderedDict
from typing import Optional, Tuple, Type
import torch
import torch.nn as nn
from torchvision.models.resnet import Bottleneck, conv1x1, conv3x3
from torchvision.ops.misc import FrozenBatchNorm2d
class ChannelPool(nn.Module):
"... | 6,598 | 29.981221 | 88 | py |
mmf | mmf-main/mmf/modules/attention.py | # Copyright (c) Facebook, Inc. and its affiliates.
import math
from typing import Optional, Tuple, Type
import torch
from mmf.modules.layers import GatedTanh, ModalCombineLayer, TransformLayer
from torch import nn
class AttentionLayer(nn.Module):
def __init__(self, image_dim, question_dim, **kwargs):
su... | 10,136 | 36.824627 | 87 | py |
mmf | mmf-main/mmf/modules/decoders.py | # Copyright (c) Facebook, Inc. and its affiliates.
import torch
from mmf.common.registry import registry
from torch import nn
from torch.nn.utils.weight_norm import weight_norm
class VisDialDiscriminator(nn.Module):
def __init__(self, config, embedding):
super().__init__()
self.config = config
... | 2,725 | 31.843373 | 84 | py |
mmf | mmf-main/mmf/modules/encoders.py | # Copyright (c) Facebook, Inc. and its affiliates.
import importlib
import logging
import os
import pickle
import re
from collections import OrderedDict
from copy import deepcopy
from dataclasses import asdict, dataclass
from enum import Enum
from typing import Any
import torch
import torchvision
from mmf.common.regis... | 29,662 | 33.734192 | 88 | py |
mmf | mmf-main/mmf/common/sample.py | # Copyright (c) Facebook, Inc. and its affiliates.
"""
``Sample`` and ``SampleList`` are data structures for arbitrary data returned from a
dataset. To work with MMF, minimum requirement for datasets is to return
an object of ``Sample`` class and for models to accept an object of type `SampleList`
as an argument.
``Sa... | 14,949 | 30.808511 | 87 | py |
mmf | mmf-main/mmf/common/registry.py | # Copyright (c) Facebook, Inc. and its affiliates.
"""
Registry is central source of truth in MMF. Inspired from Redux's
concept of global store, Registry maintains mappings of various information
to unique keys. Special functions in registry can be used as decorators to
register different kind of classes.
Import the ... | 19,436 | 28.14093 | 83 | py |
mmf | mmf-main/mmf/common/report.py | # Copyright (c) Facebook, Inc. and its affiliates.
import collections
import collections.abc
import copy
import warnings
from collections import OrderedDict
from typing import Any, Callable, Dict, List, Optional, Union
import torch
from mmf.common.sample import detach_tensor, SampleList
class Report(OrderedDict):
... | 6,687 | 32.273632 | 87 | py |
mmf | mmf-main/mmf/common/meter.py | # Copyright (c) Facebook, Inc. and its affiliates.
# Inspired from maskrcnn benchmark
from collections import defaultdict, deque
import torch
from mmf.common.registry import registry
from mmf.utils.distributed import reduce_dict
from mmf.utils.general import scalarize_dict_values
class SmoothedValue:
"""Track a ... | 4,934 | 31.467105 | 87 | py |
mmf | mmf-main/mmf/common/test_reporter.py | # Copyright (c) Facebook, Inc. and its affiliates.
import csv
import json
import logging
import os
import warnings
from dataclasses import dataclass, field
from typing import List
import pytorch_lightning as pl
from mmf.common.registry import registry
from mmf.common.sample import convert_batch_to_sample_list
from mmf... | 8,001 | 33.640693 | 87 | py |
mmf | mmf-main/mmf/models/vilt.py | # Copyright (c) Facebook, Inc. and its affiliates.
import collections.abc
import logging
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Tuple
import torch
from mmf.common.registry import registry
from mmf.models.base_model import BaseModel
from mmf.models.transformers.heads.utils impor... | 10,662 | 36.545775 | 88 | py |
mmf | mmf-main/mmf/models/ban.py | # Copyright (c) Facebook, Inc. and its affiliates.
import torch
from mmf.common.registry import registry
from mmf.models.base_model import BaseModel
from mmf.modules.embeddings import BiLSTMTextEmbedding
from mmf.modules.layers import BCNet, BiAttention, FCNet, WeightNormClassifier
from torch import nn
@registry.regi... | 3,256 | 32.57732 | 88 | py |
mmf | mmf-main/mmf/models/lxmert.py | # Copyright 2019 project LXMERT.
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use th... | 28,732 | 35.50953 | 88 | py |
mmf | mmf-main/mmf/models/butd.py | # Copyright (c) Facebook, Inc. and its affiliates.
import torch
from mmf.common.registry import registry
from mmf.models.pythia import Pythia
from mmf.modules.layers import ClassifierLayer
@registry.register_model("butd")
class BUTD(Pythia):
def __init__(self, config):
super().__init__(config)
@clas... | 7,231 | 39.177778 | 87 | py |
mmf | mmf-main/mmf/models/krisp.py | # Copyright (c) Facebook, Inc. and its affiliates.
import logging
import math
import os
import torch
from mmf.common.registry import registry
from mmf.models import BaseModel
from mmf.modules.embeddings import BertVisioLinguisticEmbeddings
from mmf.utils.configuration import get_mmf_cache_dir
from mmf.utils.file_io i... | 31,675 | 39.454662 | 88 | py |
mmf | mmf-main/mmf/models/base_model.py | # Copyright (c) Facebook, Inc. and its affiliates.
"""
Models built in MMF need to inherit ``BaseModel`` class and adhere to
a fixed format. To create a model for MMF, follow this quick cheatsheet.
1. Inherit ``BaseModel`` class, make sure to call ``super().__init__()`` in your
class's ``__init__`` function.
2. Im... | 14,978 | 35.356796 | 87 | py |
mmf | mmf-main/mmf/models/visual_bert.py | # Copyright (c) Facebook, Inc. and its affiliates.
# Initial version was taken from https://github.com/uclanlp/visualbert
# which was cleaned up and adapted for MMF.
import os
from copy import deepcopy
from typing import Dict, List, Optional, Tuple
import torch
from mmf.common.registry import registry
from mmf.model... | 24,547 | 39.777409 | 88 | py |
mmf | mmf-main/mmf/models/unimodal.py | # Copyright (c) Facebook, Inc. and its affiliates.
import collections
from copy import deepcopy
import torch
from mmf.common.registry import registry
from mmf.models.base_model import BaseModel
from mmf.modules.encoders import MultiModalEncoderBase
from mmf.utils.build import build_classifier_layer
class UnimodalBa... | 3,574 | 31.207207 | 86 | py |
mmf | mmf-main/mmf/models/vilbert.py | # Copyright (c) Facebook, Inc. and its affiliates.
import math
import os
from copy import deepcopy
from typing import Dict, List, Optional, Tuple
import numpy as np
import torch
import torch.nn.functional as F
from mmf.common.registry import registry
from mmf.models import BaseModel
from mmf.modules.hf_layers import ... | 58,792 | 38.913781 | 88 | py |
mmf | mmf-main/mmf/models/frcnn.py | # Copyright (c) Facebook, Inc. and its affiliates.
"""
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
Adapted From Facebook Inc, Detectron2 && Huggingface Co.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You ... | 9,373 | 34.507576 | 88 | py |
mmf | mmf-main/mmf/models/mmf_bert.py | # Copyright (c) Facebook, Inc. and its affiliates.
import torch
from mmf.common.registry import registry
from mmf.models.pythia import Pythia
from mmf.modules.embeddings import ProjectionEmbedding
from mmf.utils.transform import transform_to_batch_sequence
from torch import nn
try:
from transformers3.modeling_ber... | 16,653 | 38.747017 | 88 | py |
mmf | mmf-main/mmf/models/uniter.py | # Copyright (c) Facebook, Inc. and its affiliates.
# Initial version was taken from https://github.com/ChenRocks/UNITER/
# and adapted for MMF.
import copy
import logging
import random
from collections import namedtuple
from collections.abc import MutableMapping
from dataclasses import asdict, dataclass, field
from t... | 28,405 | 35.700258 | 88 | py |
mmf | mmf-main/mmf/models/fusions.py | # Copyright (c) Facebook, Inc. and its affiliates.
import collections
from copy import deepcopy
import torch
from mmf.common.registry import registry
from mmf.models.base_model import BaseModel
from mmf.modules.encoders import MultiModalEncoderBase
from mmf.utils.build import build_classifier_layer
from mmf.utils.mode... | 7,348 | 36.687179 | 86 | py |
mmf | mmf-main/mmf/models/pythia.py | # Copyright (c) Facebook, Inc. and its affiliates.
import copy
import omegaconf
import torch
from mmf.common.registry import registry
from mmf.models.base_model import BaseModel
from mmf.modules.embeddings import (
ImageFeatureEmbedding,
MultiHeadImageFeatureEmbedding,
PreExtractedEmbedding,
TextEmbedd... | 19,032 | 36.914343 | 88 | py |
mmf | mmf-main/mmf/models/top_down_bottom_up.py | # Copyright (c) Facebook, Inc. and its affiliates.
import torch
from mmf.common.registry import registry
from mmf.models.base_model import BaseModel
from mmf.modules.layers import ReLUWithWeightNormFC
# Note: Doesn't work currently. Needs to be migrated to new API
@registry.register_model("top_down_bottom_up")
class ... | 2,528 | 39.142857 | 87 | py |
mmf | mmf-main/mmf/models/alignment.py | # Copyright (c) Facebook, Inc. and its affiliates.
import math
from copy import deepcopy
from dataclasses import dataclass
from typing import Any, Tuple
import torch
from mmf.common.registry import registry
from mmf.models.base_model import BaseModel
from mmf.modules.encoders import IdentityEncoder
from mmf.modules.l... | 9,446 | 36.192913 | 87 | py |
mmf | mmf-main/mmf/models/cnn_lstm.py | # Copyright (c) Facebook, Inc. and its affiliates.
from copy import deepcopy
import torch
from mmf.common.registry import registry
from mmf.models.base_model import BaseModel
from mmf.modules.layers import ClassifierLayer, ConvNet, Flatten
from torch import nn
_TEMPLATES = {
"question_vocab_size": "{}_text_voca... | 3,616 | 34.116505 | 86 | py |
mmf | mmf-main/mmf/models/mmf_transformer.py | # Copyright (c) Facebook, Inc. and its affiliates.
import logging
from dataclasses import dataclass, field
from typing import Dict, List, Optional
import torch
from mmf.common.registry import registry
from mmf.models.transformers.base import (
BaseTransformer,
BaseTransformerBackendConfig,
BaseTransformer... | 18,052 | 39.477578 | 88 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.