repo stringlengths 2 91 | file stringlengths 14 211 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 1.36M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
OCDetector | OCDetector-master/EBDetector/TimeDomainFeatures/Conditional-Entropy-master/old_multi_CE.py | ################################################################################
# #
# Program to calculate the Conditional Entropy for all the files in a
# directory #
# This program calculates and saves a file with file name and its period ... | 3,259 | 33.680851 | 100 | py |
OCDetector | OCDetector-master/EBDetector/TimeDomainFeatures/Conditional-Entropy-master/old_CE.py | ################################################################################
# #
# Program to calculate the Conditional Entropy for a single pulsating star #
# This program calculates and saves a file with periods and entropies #
# To run: type in terminal -> python3 CE.py #
# ... | 2,699 | 35.486486 | 81 | py |
HaRT | HaRT-main/run_hulm_hart.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team. All rights reserved.
#
# 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 the License at
#
# http://www.apache.org/licenses/LI... | 14,575 | 44.55 | 192 | py |
HaRT | HaRT-main/run_ft_hart.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team. All rights reserved.
#
# 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 the License at
#
# http://www.apache.org/licenses/LI... | 21,480 | 46.419426 | 158 | py |
HaRT | HaRT-main/run_clm_gpt2.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team. All rights reserved.
#
# 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 the License at
#
# http://www.apache.org/licenses/LI... | 12,138 | 42.823105 | 210 | py |
HaRT | HaRT-main/run_ft_gpt2hlc.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team. All rights reserved.
#
# 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 the License at
#
# http://www.apache.org/licenses/LI... | 21,952 | 44.926778 | 158 | py |
HaRT | HaRT-main/extra_utils/save_user_states.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team. All rights reserved.
#
# 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 the License at
#
# http://www.apache.org/licenses/LI... | 9,356 | 43.557143 | 143 | py |
HaRT | HaRT-main/extra_utils/finetune_user_gpt2_save_states.py | from more_itertools import split_at
import pandas as pd
import torch
import torch.nn as nn
from torch.nn import MSELoss
from transformers.utils import logging
from transformers import GPT2PreTrainedModel, GPT2Model
from transformers.modeling_outputs import SequenceClassifierOutputWithPast
logger = logging.get_logg... | 7,761 | 39.217617 | 119 | py |
HaRT | HaRT-main/extra_utils/save_user_states_gpt2.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team. All rights reserved.
#
# 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 the License at
#
# http://www.apache.org/licenses/LI... | 8,810 | 42.835821 | 143 | py |
HaRT | HaRT-main/extra_utils/finetune_to_save_states.py | import pandas as pd
import torch
import torch.nn as nn
from transformers.modeling_outputs import SequenceClassifierOutputWithPast
from ..src.model.hart import HaRTPreTrainedModel
class ArHulmForSequenceClassification(HaRTPreTrainedModel):
# _keys_to_ignore_on_load_missing = [r"h\.\d+\.attn\.masked_bias", r"lm_he... | 5,303 | 42.834711 | 119 | py |
HaRT | HaRT-main/src/modeling_outputs.py | from dataclasses import dataclass
from typing import Optional, Tuple
import torch
from transformers.file_utils import ModelOutput
@dataclass
class HaRTOutput(ModelOutput):
"""
Superset of ArHulmCausalLMOutput with history in the output additionally.
The description of ArHuLMOutput is as follows which a... | 14,216 | 70.80303 | 215 | py |
HaRT | HaRT-main/src/user_ft_trainer.py | import collections
import numpy as np
import torch
import torch.nn as nn
from packaging import version
from typing import NamedTuple, Any, Dict, List, Optional, Tuple, Union
from torch.utils.data.dataloader import DataLoader
from transformers import Trainer
from transformers.trainer_pt_utils import (
DistributedT... | 11,401 | 44.608 | 124 | py |
HaRT | HaRT-main/src/model_gpt2hlc/finetune_gpt2hlc.py | import torch
import torch.nn as nn
from torch.nn import CrossEntropyLoss, MSELoss
from transformers.utils import logging
from transformers import GPT2PreTrainedModel, GPT2Model
from transformers.modeling_outputs import SequenceClassifierOutputWithPast
logger = logging.get_logger(__name__)
class GPT2hlcForSequenceC... | 4,886 | 37.785714 | 119 | py |
HaRT | HaRT-main/src/model_gpt2hlc/gpt2hlcLMhead.py | import torch
import torch.nn as nn
from torch.nn import CrossEntropyLoss
from transformers.utils import logging
from transformers import GPT2PreTrainedModel, GPT2Model
from transformers.modeling_outputs import CausalLMOutputWithCrossAttentions
logger = logging.get_logger(__name__)
class GPT2hlcLMHeadModel(GPT2PreT... | 4,241 | 37.563636 | 118 | py |
HaRT | HaRT-main/src/model/hart.py | import torch
import torch.nn as nn
from src.model.modeling_hart import HaRTBasePreTrainedModel, HaRTBaseLMHeadModel
from src.modeling_outputs import HaRTOutput
from transformers.activations import ACT2FN
""" HaRT model pre-trained for the HuLM task """,
class HistoryMLP(nn.Module):
def __init__(self, n_state, co... | 7,289 | 41.138728 | 140 | py |
HaRT | HaRT-main/src/model/finetune_hart.py | import torch
import torch.nn as nn
from torch.nn import CrossEntropyLoss, MSELoss
from transformers.modeling_outputs import SequenceClassifierOutputWithPast
from .modeling_hart import HaRTBasePreTrainedModel
from .hart import HaRTPreTrainedModel
class HaRTForSequenceClassification(HaRTBasePreTrainedModel):
# _ke... | 7,350 | 43.283133 | 169 | py |
HaRT | HaRT-main/src/model/configuration_hart.py | # coding=utf-8
# Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# 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 the License... | 9,982 | 46.312796 | 119 | py |
HaRT | HaRT-main/src/model/modeling_hart.py | # coding=utf-8
# Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# 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 the License... | 32,108 | 40.538163 | 180 | py |
HaRT | HaRT-main/optuna_trials/run_hulm_hart_trials.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team. All rights reserved.
#
# 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 the License at
#
# http://www.apache.org/licenses/LI... | 15,867 | 44.994203 | 195 | py |
HaRT | HaRT-main/optuna_trials/run_ft_gpt2hlc_trials.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team. All rights reserved.
#
# 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 the License at
#
# http://www.apache.org/licenses/LI... | 28,278 | 46.688027 | 168 | py |
HaRT | HaRT-main/optuna_trials/run_ft_hart_trials.py | #!/usr/bin/env python
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team. All rights reserved.
#
# 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 the License at
#
# http://www.apache.org/licenses/LI... | 31,029 | 47.408736 | 168 | py |
HaRT | HaRT-main/HFtrainer_v451_for_reference/trainer.py | # coding=utf-8
# Copyright 2020-present the HuggingFace Inc. team.
#
# 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 the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ap... | 93,217 | 46.415056 | 190 | py |
HaRT | HaRT-main/data/data_collator.py | import torch
from typing import Dict, List
from dataclasses import dataclass
from transformers import BatchEncoding
from transformers.tokenization_utils_base import PreTrainedTokenizerBase
@dataclass
class DataCollatorWithPaddingForHaRT:
"""
Data collator that simply collates batches of lists of dict-like... | 7,177 | 48.847222 | 133 | py |
HaRT | HaRT-main/data/utils_gpt2hlc/clm_data_utils.py | import time
import copy
import pandas as pd
from more_itertools import split_at
from sqlalchemy import create_engine
from sqlalchemy.engine.url import URL
from transformers import BatchEncoding
def add_insep_token(tokenizer):
special_tokens_dict = {'sep_token': str('<|insep|>')}
tokenizer.add_special_tokens(s... | 5,982 | 39.154362 | 104 | py |
HaRT | HaRT-main/data/utils_gpt2hlc/ft_user_data_utils_gpt2hlc.py | import time
import copy
import pandas as pd
from more_itertools import split_at
from sqlalchemy import create_engine
from sqlalchemy.engine.url import URL
from transformers import BatchEncoding
def add_insep_token(tokenizer):
special_tokens_dict = {'sep_token': str('<|insep|>')}
num_added_toks = tokenizer.add... | 8,585 | 40.278846 | 117 | py |
HaRT | HaRT-main/data/utils_optuna_trials/hulm_sample_data_utils.py | import os
import pandas as pd
from sqlalchemy import create_engine
from sqlalchemy.engine.url import URL
from data.utils_hart.hulm_data_utils import transform_data, group_data
def get_conn(data_args):
myDB = URL(drivername='mysql', host=data_args.hostname,
database=data_args.db, query={'read_defaul... | 5,851 | 49.017094 | 230 | py |
HaRT | HaRT-main/data/utils_hart/ft_user_data_utils.py | import time
import pandas as pd
from sqlalchemy import create_engine
from sqlalchemy.engine.url import URL
from transformers import BatchEncoding
user_id_column = 'user_id'
message_column = 'message'
order_by_fields = [user_id_column, 'updated_time']
label_column = 'label'
def get_fields(data_args):
if data_args.... | 9,929 | 41.076271 | 117 | py |
HaRT | HaRT-main/data/utils_hart/hulm_data_utils.py | import time
import pandas as pd
from sqlalchemy import create_engine
from sqlalchemy.engine.url import URL
from transformers import BatchEncoding
user_id_column = 'user_id'
message_column = 'message'
order_by_fields = [user_id_column, 'updated_time']
def get_fields():
return {
'order_by_fields': order... | 7,382 | 44.018293 | 170 | py |
HaRT | HaRT-main/data/utils_hart/ft_doc_disable_hulm_batching_data_utils.py | import time
import math
import pandas as pd
from sqlalchemy import create_engine
from sqlalchemy.engine.url import URL
from transformers import BatchEncoding
user_id_column = 'user_id'
message_column = 'message'
label_column = 'label'
def get_fields(data_args):
if data_args.task_name is not None:
if data_... | 7,206 | 39.717514 | 121 | py |
HaRT | HaRT-main/data/utils_hart/ft_doc_data_utils.py | import time
import math
import pandas as pd
from sqlalchemy import create_engine
from sqlalchemy.engine.url import URL
from transformers import BatchEncoding
user_id_column = 'user_id'
message_column = 'message'
order_by_fields = [user_id_column, 'updated_time']
label_column = 'label'
def get_fields(data_args):
i... | 8,031 | 42.652174 | 121 | py |
HaRT | HaRT-main/args/clm_args.py | from dataclasses import dataclass, field
from typing import Optional
from transformers import MODEL_FOR_CAUSAL_LM_MAPPING
MODEL_CONFIG_CLASSES = list(MODEL_FOR_CAUSAL_LM_MAPPING.keys())
MODEL_TYPES = tuple(conf.model_type for conf in MODEL_CONFIG_CLASSES)
@dataclass
class ModelArguments:
"""
Arguments perta... | 9,140 | 43.808824 | 185 | py |
HaRT | HaRT-main/args/ft_args.py | from dataclasses import dataclass, field
from typing import Optional
@dataclass
class DataTrainingArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
Using `HfArgumentParser` we can turn this class
into argparse arguments to be able to specify them o... | 10,704 | 41.82 | 185 | py |
covid-19_timeSeriesAnalysis | covid-19_timeSeriesAnalysis-master/diagnosticPlotsForLinearRegression_likeR.py | # Functions for the 4 diagnostic plots (like R)
# Code adapted from https://towardsdatascience.com/going-from-r-to-python-linear-regression-diagnostic-plots-144d1c4aa5a
from statsmodels.nonparametric.smoothers_lowess import lowess
import scipy.stats as stats
import pandas as pd
import matplotlib.pyplot as plt
import nu... | 8,774 | 45.184211 | 120 | py |
FJLT | FJLT-master/src/fjlt.py | import numpy as np
import fht #Fast hadamard transform. https://github.com/nbarbey/fht
from scipy import sparse
import numpy.random as npr
import math
def approx_bound(eps, n):
return int(2 / eps ** 2 * math.log(n) + 1.0)
def fast_sample(n, sample_size):
swap_records = {}
sample_wor = np.empty(sample_si... | 2,319 | 25.666667 | 71 | py |
exatn | exatn-master/src/exatn/tests/hubbard.py | import numpy as np
from openfermion import *
import openfermion.ops as ops
import openfermion.hamiltonians as hams
import openfermion.transforms as trans
import openfermion.linalg as linalg
hubb = hams.fermi_hubbard(2,2,1,1)
hubb_jw = trans.jordan_wigner(hubb)
print(hubb_jw)
hubb_matrix = linalg.get_sparse_operator(h... | 475 | 25.444444 | 72 | py |
exatn | exatn-master/python/exatn.py | from _pyexatn import *
import argparse
def parse_args(args):
parser = argparse.ArgumentParser(description="ExaTN Python Framework.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
fromfile_prefix_chars='@')
parser.add_argument("... | 836 | 26.9 | 93 | py |
exatn | exatn-master/python/examples/large_circuit.py | import sys
from pathlib import Path
sys.path.insert(1, str(Path.home()) + '/.exatn')
import exatn, numpy as np
qzero = np.array([1.0, 0.0], dtype=complex)
hadamard = np.array([[1., 1.],[1., -1.]], dtype=complex)
nQubits = 10
[exatn.createTensor('Q'+str(i), qzero) for i in range(nQubits)]
exatn.createTensor('H', hada... | 1,309 | 25.2 | 110 | py |
exatn | exatn-master/python/examples/test_exatn_interface_data_from_numpy_dot_product.py | import exatn, numpy as np
# Create some numpy arrays
s = np.random.rand(2)
r = np.random.rand(2)
# Create the ExaTN tensors
exatn.createTensor("Z0", 0.0)
exatn.createTensor("S", s)
exatn.createTensor("R", r)
# Print S, R
exatn.print("S")
exatn.print("R")
# Demonstrate transformTensor interface by
# negating the ten... | 833 | 20.384615 | 57 | py |
exatn | exatn-master/python/examples/benchmark.py | import sys, os, re, time
from pathlib import Path
sys.path.insert(1, str(Path.home()) + '/.exatn')
import exatn
import numpy as np
dir_path = os.path.dirname(os.path.realpath(__file__))
inputFile = open(dir_path + '/resources/test-cases.txt', 'r')
count = 0
# Returns an array of tensor dimension from its string expr... | 3,245 | 32.463918 | 133 | py |
exatn | exatn-master/python/examples/contraction.py | import sys
from pathlib import Path
sys.path.insert(1, str(Path.home()) + '/.exatn')
import exatn, numpy as np
def test_exatn():
a1 = np.array([
[1., 0., 0.],
[0., 1., 1.]])
print('A1 shape: ',a1.shape)
b1 = np.array([
[ 1., 0., 3., 0.],
[ 1., 1., 2., 2.],
[-... | 897 | 22.631579 | 56 | py |
exatn | exatn-master/python/examples/simple.py | import sys
from pathlib import Path
sys.path.insert(1, str(Path.home()) + '/.exatn')
import exatn
exatn.createTensor('Z0')
exatn.createTensor('T0', [2,2], .01)
exatn.createTensor('T1', [2,2,2], .01)
exatn.createTensor('T2', [2,2], .01)
exatn.createTensor('H0', [2,2,2,2], .01)
exatn.createTensor('S0', [2,2], .01)
exatn... | 611 | 31.210526 | 141 | py |
exatn | exatn-master/python/examples/hamiltonian.py | import sys
from pathlib import Path
sys.path.insert(1, str(Path.home()) + '/.exatn')
import exatn, numpy as np
# Declare MPS tensors:
exatn.createTensor('Q0', [2,2], 1e-2)
exatn.createTensor('Q1', [2,2,4], 1e-2)
exatn.createTensor('Q2', [4,2,2], 1e-2)
exatn.createTensor('Q3', [2,2], 1e-2)
# Declare Hamiltonian Tenso... | 3,592 | 37.223404 | 149 | py |
exatn | exatn-master/python/examples/circuit_conjugate.py | import sys
from pathlib import Path
sys.path.insert(1, str(Path.home()) + '/.exatn')
import exatn, numpy as np
qzero = np.array([1.0, 0.0], dtype=complex)
unitary = np.reshape(np.array([1,-1j,-1j,1], dtype=complex), (2,2))
exatn.createTensor('Q0', qzero)
exatn.createTensor('U', unitary)
exatn.registerTensorIsometry('... | 800 | 26.62069 | 67 | py |
exatn | exatn-master/python/examples/tensor_basic.py | import sys
from pathlib import Path
sys.path.insert(1, str(Path.home()) + '/.exatn')
import exatn
import numpy as np
# Demonstrate simple tensor network manipulation
exatn.createTensor('X', [2, 2], 0)
exatn.createTensor('Y', [2, 2], 0)
exatn.createTensor('Z', [2, 2], 0)
exatn.initTensorRnd('X')
exatn.initTensorRnd('Y... | 1,367 | 24.333333 | 72 | py |
exatn | exatn-master/python/examples/hypercontraction.py | import exatn, numpy as np
def test_exatn():
a1 = np.random.randn(2,3,4)
print('A1 shape: ',a1.shape)
b1 = np.random.randn(2,3,4,5)
print('B1 shape: ',b1.shape)
exatn.createTensor('C1', [3, 4, 5], 0.0)
exatn.createTensor('A1', a1.copy(order='F'))
exatn.createTensor('B1', b1.copy(order='F'... | 735 | 23.533333 | 64 | py |
exatn | exatn-master/python/examples/test_creation_from_array_print_and_transform.py | import exatn, numpy as np
exatn.createTensor("Sx", np.array([[0.,1.],[1.,0.]]))
exatn.createTensor("Sy", np.array([[0.,-1.j],[1.j,0.]]))
exatn.print("Sx")
exatn.print("Sy")
def negate(data):
data *= -1.
exatn.transformTensor("Sx", negate)
exatn.print("Sx")
exatn.transformTensor("Sx", negate)
exatn.print("Sx")
... | 374 | 18.736842 | 56 | py |
exatn | exatn-master/python/examples/quantum_circuit_network.py | import sys
from pathlib import Path
sys.path.insert(1, str(Path.home()) + '/.exatn')
import exatn, numpy as np
#Quantum Circuit:
#Q0----H---------
#Q1----H----C----
#Q2----H----N----
#Define the initial qubit state vector:
qzero = np.array([1.0, 0.0], dtype=complex)
hadamard = np.array([[1., 1.],[1., -1.]], dtype=com... | 1,359 | 25.666667 | 108 | py |
RAFT | RAFT-master/evaluate.py | import sys
sys.path.append('core')
from PIL import Image
import argparse
import os
import time
import numpy as np
import torch
import torch.nn.functional as F
import matplotlib.pyplot as plt
import datasets
from utils import flow_viz
from utils import frame_utils
from raft import RAFT
from utils.utils import InputPa... | 6,618 | 32.429293 | 112 | py |
RAFT | RAFT-master/demo.py | import sys
sys.path.append('core')
import argparse
import os
import cv2
import glob
import numpy as np
import torch
from PIL import Image
from raft import RAFT
from utils import flow_viz
from utils.utils import InputPadder
DEVICE = 'cuda'
def load_image(imfile):
img = np.array(Image.open(imfile)).astype(np.ui... | 2,073 | 26.289474 | 112 | py |
RAFT | RAFT-master/train.py | from __future__ import print_function, division
import sys
sys.path.append('core')
import argparse
import os
import cv2
import time
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from torch.utils.data import DataLoader... | 7,987 | 31.340081 | 103 | py |
RAFT | RAFT-master/core/corr.py | import torch
import torch.nn.functional as F
from utils.utils import bilinear_sampler, coords_grid
try:
import alt_cuda_corr
except:
# alt_cuda_corr is not compiled
pass
class CorrBlock:
def __init__(self, fmap1, fmap2, num_levels=4, radius=4):
self.num_levels = num_levels
self.radius... | 3,085 | 32.543478 | 74 | py |
RAFT | RAFT-master/core/update.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class FlowHead(nn.Module):
def __init__(self, input_dim=128, hidden_dim=256):
super(FlowHead, self).__init__()
self.conv1 = nn.Conv2d(input_dim, hidden_dim, 3, padding=1)
self.conv2 = nn.Conv2d(hidden_dim, 2, 3, padding=1)
... | 5,227 | 36.342857 | 87 | py |
RAFT | RAFT-master/core/extractor.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class ResidualBlock(nn.Module):
def __init__(self, in_planes, planes, norm_fn='group', stride=1):
super(ResidualBlock, self).__init__()
self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, padding=1, stride=stride)
s... | 8,847 | 32.014925 | 93 | py |
RAFT | RAFT-master/core/datasets.py | # Data loading based on https://github.com/NVIDIA/flownet2-pytorch
import numpy as np
import torch
import torch.utils.data as data
import torch.nn.functional as F
import os
import math
import random
from glob import glob
import os.path as osp
from utils import frame_utils
from utils.augmentor import FlowAugmentor, S... | 9,245 | 38.177966 | 111 | py |
RAFT | RAFT-master/core/raft.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from update import BasicUpdateBlock, SmallUpdateBlock
from extractor import BasicEncoder, SmallEncoder
from corr import CorrBlock, AlternateCorrBlock
from utils.utils import bilinear_sampler, coords_grid, upflow8
try:
autocast =... | 4,924 | 32.965517 | 102 | py |
RAFT | RAFT-master/core/__init__.py | 0 | 0 | 0 | py | |
RAFT | RAFT-master/core/utils/utils.py | import torch
import torch.nn.functional as F
import numpy as np
from scipy import interpolate
class InputPadder:
""" Pads images such that dimensions are divisible by 8 """
def __init__(self, dims, mode='sintel'):
self.ht, self.wd = dims[-2:]
pad_ht = (((self.ht // 8) + 1) * 8 - self.ht) % 8
... | 2,489 | 29 | 93 | py |
RAFT | RAFT-master/core/utils/augmentor.py | import numpy as np
import random
import math
from PIL import Image
import cv2
cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)
import torch
from torchvision.transforms import ColorJitter
import torch.nn.functional as F
class FlowAugmentor:
def __init__(self, crop_size, min_scale=-0.2, max_scale=0.5, do_flip=Tru... | 9,108 | 35.878543 | 97 | py |
RAFT | RAFT-master/core/utils/__init__.py | 0 | 0 | 0 | py | |
RAFT | RAFT-master/core/utils/flow_viz.py | # Flow visualization code used from https://github.com/tomrunia/OpticalFlow_Visualization
# MIT License
#
# Copyright (c) 2018 Tom Runia
#
# 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 wi... | 4,318 | 31.719697 | 90 | py |
RAFT | RAFT-master/core/utils/frame_utils.py | import numpy as np
from PIL import Image
from os.path import *
import re
import cv2
cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)
TAG_CHAR = np.array([202021.25], np.float32)
def readFlow(fn):
""" Read .flo file in Middlebury format"""
# Code adapted from:
# http://stackoverflow.com/questions/28013200... | 4,024 | 28.379562 | 109 | py |
RAFT | RAFT-master/alt_cuda_corr/setup.py | from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='correlation',
ext_modules=[
CUDAExtension('alt_cuda_corr',
sources=['correlation.cpp', 'correlation_kernel.cu'],
extra_compile_args={'cxx': [], 'nvcc': ['-O3']}),
]... | 381 | 22.875 | 67 | py |
onnxruntime | onnxruntime-main/setup.py | # ------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# ------------------------------------------------------------------------
# pylint: disable=C0103
import datetime
import logging
import platform
impo... | 31,487 | 41.265772 | 119 | py |
onnxruntime | onnxruntime-main/objectivec/test/testdata/single_add_gen.py | import onnx
from onnx import TensorProto, helper
graph = helper.make_graph(
[ # nodes
helper.make_node("Add", ["A", "B"], ["C"], "Add"),
],
"SingleAdd", # name
[ # inputs
helper.make_tensor_value_info("A", TensorProto.FLOAT, [1]),
helper.make_tensor_value_info("B", TensorProt... | 552 | 26.65 | 77 | py |
onnxruntime | onnxruntime-main/tools/ci_build/patch_manylinux.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import os
import shutil
import sys
from pathlib import Path
from logger import get_logger
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
REPO_DIR = os.path.normpath(os.path.j... | 2,181 | 32.569231 | 106 | py |
onnxruntime | onnxruntime-main/tools/ci_build/op_registration_utils.py | # !/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Utilities to help process files containing kernel registrations.
"""
import os
import pathlib
import sys
import typing
from logger import get_logger
log = get_logger("op_registration_utils")
de... | 11,081 | 39.892989 | 118 | py |
onnxruntime | onnxruntime-main/tools/ci_build/amd_hipify.py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import os
import subprocess
def hipify(hipify_perl_path, src_file_path, dst_file_path):
dir_name = os.path.dirname(dst_file_path)
if not os.path.exists(dir_name):
os.makedirs(dir_name, exist_... | 8,817 | 46.664865 | 120 | py |
onnxruntime | onnxruntime-main/tools/ci_build/gen_def.py | #!/usr/bin/python3
import argparse
import os
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument("--src_root", required=True, help="input symbol file")
parser.add_argument("--output", required=True, help="output file")
parser.add_argument("--output_source", required=True, hel... | 2,917 | 36.410256 | 111 | py |
onnxruntime | onnxruntime-main/tools/ci_build/reduce_op_kernels.py | # !/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import io
import re
import shutil
import sys
import typing
from pathlib import Path
import op_registration_utils
from logger import get_logger
# directory containing the reduced op fi... | 14,490 | 39.591036 | 120 | py |
onnxruntime | onnxruntime-main/tools/ci_build/logger.py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import logging
def get_logger(name):
logging.basicConfig(format="%(asctime)s %(name)s [%(levelname)s] - %(message)s", level=logging.DEBUG)
return logging.getLogger(name)
| 276 | 24.181818 | 105 | py |
onnxruntime | onnxruntime-main/tools/ci_build/get_docker_image.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import os
import shlex
import shutil
import sys
from pathlib import Path
from logger import get_logger
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
REPO_DIR = os.path.normp... | 5,336 | 31.542683 | 110 | py |
onnxruntime | onnxruntime-main/tools/ci_build/upload_python_package_to_azure_storage.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import logging
import os
import subprocess
import warnings
log = logging.getLogger("Build")
def parse_nightly_and_local_version_from_whl_name(blob_name):
night_build = "nightly" i... | 2,904 | 30.923077 | 118 | py |
onnxruntime | onnxruntime-main/tools/ci_build/op_registration_validator.py | # !/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Validate ORT kernel registrations.
"""
import argparse
import dataclasses
import itertools
import os
import sys
import typing
import op_registration_utils
from logger import get_logger
log = get_... | 8,898 | 39.085586 | 120 | py |
onnxruntime | onnxruntime-main/tools/ci_build/coverage.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#
# This script generates test code coverage for Android.
# The prerequistes:
# 1. The Onnxruntime build with coverage option to compile/link the source files using --coverage optoin
# 2. The tes... | 2,312 | 34.584615 | 108 | py |
onnxruntime | onnxruntime-main/tools/ci_build/replace_urls_in_deps.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# This file replaces https URLs in deps.txt to local file paths. It runs after we download the dependencies from Azure
# DevOps Artifacts
import argparse
import csv
import os
from dataclasses import da... | 2,368 | 30.586667 | 118 | py |
onnxruntime | onnxruntime-main/tools/ci_build/__init__.py | 0 | 0 | 0 | py | |
onnxruntime | onnxruntime-main/tools/ci_build/compile_triton.py | # -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import argparse
import importlib.util
import os
import shutil
import tr... | 5,675 | 31.434286 | 116 | py |
onnxruntime | onnxruntime-main/tools/ci_build/update_tsaoptions.py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import json
import os
from pathlib import Path
SCRIPT_DIR = Path(os.path.dirname(os.path.realpath(__file__)))
REPO_DIR = SCRIPT_DIR.parent.parent
with (REPO_DIR / ".config" / "tsaoptions.json").open() as f:
data = json.... | 547 | 26.4 | 68 | py |
onnxruntime | onnxruntime-main/tools/ci_build/clean_docker_image_cache.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import collections
import datetime
import json
import os
import re
import sys
import tempfile
from logger import get_logger
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
REP... | 8,016 | 29.953668 | 117 | py |
onnxruntime | onnxruntime-main/tools/ci_build/build.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import contextlib
import os
import platform
import re
import shlex
import shutil
import subprocess
import sys
from pathlib import Path
SCRIPT_DIR = os.path.dirname(os.path.realpath(__fi... | 113,014 | 42.036938 | 120 | py |
onnxruntime | onnxruntime-main/tools/ci_build/github/linux/ort_minimal/readelf_utils.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""
Utilities to help analyze the sections in a binary using readelf.
"""
import argparse
import collections
import os
import re
import subprocess
import sys
def get_section_sizes(binary_path, readelf... | 4,278 | 33.232 | 117 | py |
onnxruntime | onnxruntime-main/tools/ci_build/github/linux/ort_minimal/check_build_binary_size.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import os
import sys
# local helpers
import readelf_utils
def _check_binary_size(path, readelf, threshold, os_str, arch, build_config):
print(f"Checking binary size of {path} usin... | 2,681 | 37.314286 | 117 | py |
onnxruntime | onnxruntime-main/tools/ci_build/github/linux/ort_minimal/build_ort_and_check_binary_size.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import json
import pathlib
import subprocess
import sys
REPO_ROOT = pathlib.Path(__file__).resolve().parents[5]
def parse_args():
parser = argparse.ArgumentParser(description="Bui... | 3,047 | 29.178218 | 108 | py |
onnxruntime | onnxruntime-main/tools/ci_build/github/linux/ort_minimal/__init__.py | 0 | 0 | 0 | py | |
onnxruntime | onnxruntime-main/tools/ci_build/github/android/build_aar_package.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import json
import os
import pathlib
import shutil
import subprocess
import sys
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
REPO_DIR = os.path.normpath(os.path.join(SCRIPT_... | 9,767 | 37.456693 | 118 | py |
onnxruntime | onnxruntime-main/tools/ci_build/github/js/validate-npm-packages.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import os
import sys
# This is a script to validate NPM packages.
# If package version, publish tag and filename does not fulfill the requirement, an error will raise.
# arg.1 - Folder of extracted ar... | 7,872 | 45.585799 | 120 | py |
onnxruntime | onnxruntime-main/tools/ci_build/github/windows/post_code_coverage_to_dashboard.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# command line arguments
# --report_url=<string>
# --report_file=<string, local file path, TXT/JSON file>
# --commit_hash=<string, full git commit hash>
import argparse
import datetime
import json
imp... | 3,952 | 33.077586 | 107 | py |
onnxruntime | onnxruntime-main/tools/ci_build/github/windows/post_binary_sizes_to_dashboard.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import datetime
import os
import sys
# ingest from dataframe
import pandas
from azure.kusto.data import DataFormat, KustoConnectionStringBuilder
from azure.kusto.ingest import Ingestio... | 3,690 | 33.820755 | 117 | py |
onnxruntime | onnxruntime-main/tools/ci_build/github/apple/test_ios_packages.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import contextlib
import os
import pathlib
import shutil
import subprocess
import tempfile
from c.assemble_c_pod_package import assemble_c_pod_package
from package_assembly_utils import... | 7,240 | 36.518135 | 118 | py |
onnxruntime | onnxruntime-main/tools/ci_build/github/apple/build_and_assemble_ios_pods.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import logging
import pathlib
import shutil
import sys
import tempfile
from c.assemble_c_pod_package import assemble_c_pod_package
from objectivec.assemble_objc_pod_package import asse... | 6,017 | 31.354839 | 119 | py |
onnxruntime | onnxruntime-main/tools/ci_build/github/apple/build_ios_framework.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import glob
import json
import os
import pathlib
import shutil
import subprocess
import sys
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
REPO_DIR = os.path.normpath(os.path.... | 8,434 | 36.65625 | 118 | py |
onnxruntime | onnxruntime-main/tools/ci_build/github/apple/__init__.py | 0 | 0 | 0 | py | |
onnxruntime | onnxruntime-main/tools/ci_build/github/apple/package_assembly_utils.py | # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import enum
import json
import os
import pathlib
import re
import shutil
from typing import Dict, List
_script_dir = pathlib.Path(__file__).parent.resolve(strict=True)
repo_root = _script_dir.parents[3]
class PackageVarian... | 4,642 | 34.442748 | 119 | py |
onnxruntime | onnxruntime-main/tools/ci_build/github/apple/objectivec/assemble_objc_pod_package.py | #!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import pathlib
import sys
_script_dir = pathlib.Path(__file__).parent.resolve(strict=True)
sys.path.append(str(_script_dir.parent))
from c.assemble_c_pod_package import get_pod_confi... | 7,242 | 33.004695 | 119 | py |
onnxruntime | onnxruntime-main/tools/ci_build/github/apple/objectivec/__init__.py | 0 | 0 | 0 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.