repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
PIRA | PIRA-master/test/integration/GameOfLife/functors/no_instr_gol_ct.py | def get_method():
return {'passive': True, 'active': False}
def passive(benchmark, **kwargs):
return 'CXX=clang++ make gol'
def active(benchmark, **kwargs):
pass
| 172 | 14.727273 | 43 | py |
PIRA | PIRA-master/test/inputs/functors/runner_test_item_ct.py | def get_method():
return {'passive': True, 'active': False}
def passive(benchmark, **kwargs):
return 'Runner'
def active(benchmark, **kwargs):
pass
| 158 | 13.454545 | 43 | py |
PIRA | PIRA-master/test/inputs/functors/clean_test_item_ct.py | def get_method():
return {'passive': True, 'active': False}
def passive(benchmark, **kwargs):
return 'Clean'
def active(benchmark, **kwargs):
pass
| 157 | 13.363636 | 43 | py |
PIRA | PIRA-master/test/inputs/functors/test_item_ct.py | def get_method():
return {'passive': True, 'active': False}
def passive(benchmark, **kwargs):
return 'Test_Item'
def active(benchmark, **kwargs):
pass
| 161 | 13.727273 | 43 | py |
PIRA | PIRA-master/test/inputs/functors/analyze_test_item_ct.py |
temporary_it = 0
def get_method():
return {'passive': True, 'active': False}
def passive(benchmark, **kwargs):
global temporary_it
temporary_it = 1
return 'echo '
def active(benchmark, **kwargs):
pass
def get_it():
global temporary_it
return temporary_it
| 276 | 12.85 | 43 | py |
PIRA | PIRA-master/test/inputs/functors/no_instr_test_item_ct.py | def get_method():
return {'passive': True, 'active': False}
def passive(benchmark, **kwargs):
return 'No_Instr'
def active(benchmark, **kwargs):
pass
| 160 | 13.636364 | 43 | py |
PIRA | PIRA-master/lib/db.py | """
File: db.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: --
"""
import sqlite3 as db
import lib.Logging as log
class database:
def __init__(self, conf_db_name):
try:
self.conn = db.connect(conf_db_name)
... | 2,057 | 32.193548 | 182 | py |
PIRA | PIRA-master/lib/Measurement.py | """
File: Measurement.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module hosts measurement support infrastructure.
"""
import lib.Utility as U
import lib.Logging as L
import lib.DefaultFlags as D
from lib.Configuration i... | 17,626 | 37.740659 | 138 | py |
PIRA | PIRA-master/lib/BatchSystemGenerator.py | """
File: BatchSystemGenerator.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description:
"""
import math
import os
import subprocess
import time
from typing import Optional, List, Union, Dict
import lib.Logging as L
import lib.Utilit... | 24,903 | 37.196319 | 126 | py |
PIRA | PIRA-master/lib/DefaultFlags.py | """
File: DefaultFlags.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module holds a selection of default flags.
"""
import typing
import os
from lib.Configuration import InvocationConfig
class BackendDefaults:
"""
Me... | 2,339 | 29 | 126 | py |
PIRA | PIRA-master/lib/Checker.py | """
File: Checker.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file
at https://github.com/tudasc/pira
Description: Checks if files and paths in config-file are valid.
"""
import lib.Utility as U
import lib.Configuration as C
import lib.Logging as L
class Checker:
@stat... | 5,138 | 41.122951 | 125 | py |
PIRA | PIRA-master/lib/Analyzer.py | """
File: Analyzer.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module to encapsulate the underlying analysis engine.
"""
import lib.Utility as U
import lib.Logging as L
import lib.TimeTracking as T
import lib.FunctorMana... | 8,705 | 41.262136 | 168 | py |
PIRA | PIRA-master/lib/Utility.py | """
File: Utility.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module to support other tasks.
"""
import re
import sys
sys.path.append('..')
import lib.Logging as L
from lib.Exception import PiraException
import os
impo... | 13,131 | 27.180258 | 126 | py |
PIRA | PIRA-master/lib/Runner.py | """
File: Runner.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module to run the target software.
"""
import sys
sys.path.append('..')
import lib.Utility as U
import lib.Logging as L
import lib.FunctorManagement as F
imp... | 31,852 | 44.374644 | 126 | py |
PIRA | PIRA-master/lib/ConfigurationLoader.py | """
File: ConfigurationLoader.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module to read the PIRA configuration from file.
"""
import lib.Utility as U
import lib.Logging as L
from lib.BatchSystemBackends import BatchSyst... | 17,955 | 37.781857 | 126 | py |
PIRA | PIRA-master/lib/ProfileSink.py | """
File: ProfileSink.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module hosts different profile sinks. These can process resulting profile files outside of regular PIRA iteration.
"""
import sys
sys.path.append('../')
... | 7,292 | 32 | 127 | py |
PIRA | PIRA-master/lib/Logging.py | """
File: Logging.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module to handle output of PIRA.
"""
import logging
import sys
class Logger:
"""
Class to steer output
"""
def __init__(self):
self.state = {... | 6,342 | 27.443946 | 133 | py |
PIRA | PIRA-master/lib/BatchSystemTimer.py | """
File: BatchSystemTimer.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Wrapper for timings in PIRA Slurm jobs, utilizes subprocess and os.times(). This way it is the
same as in PIRA, with in the U.shell call.
"""
import ... | 2,266 | 29.226667 | 126 | py |
PIRA | PIRA-master/lib/Database.py | """
File: Database.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module to run the target software.
"""
import sys
sys.path.append('..')
import lib.FunctorManagement as F
import lib.Utility as U
import lib.tables as T
fr... | 4,484 | 31.035714 | 184 | py |
PIRA | PIRA-master/lib/Builder.py | """
File: Builder.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module to build the target software.
"""
import lib.Utility as U
import lib.Logging as L
import lib.FunctorManagement as F
import lib.DefaultFlags as D
from l... | 6,185 | 37.42236 | 126 | py |
PIRA | PIRA-master/lib/Exporter.py | """
File: Exporter.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module that implements various exporters, e.g., CSV-export.
"""
import csv
import lib.Logging as L
import typing
from lib.Exception import PiraException
fr... | 4,239 | 27.648649 | 126 | py |
PIRA | PIRA-master/lib/BatchSystemBackends.py | """
File: BatchSystemBackends.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description:
"""
import time
import json
from typing import Type, Tuple, Dict, Union, List, Any
import lib.Logging as L
import lib.Utility as U
from lib.Batch... | 19,657 | 41.366379 | 126 | py |
PIRA | PIRA-master/lib/Configuration.py | """
File: Configuration.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module that provides to main data structures.
"""
import sys
# from lib.BatchSystemGenerator import MailType
sys.path.append('..')
import lib.Logging ... | 26,954 | 32.609726 | 128 | py |
PIRA | PIRA-master/lib/ArgumentMapping.py | """
File: ArgumentMapping.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module provides mapper classes to handle argument.
"""
import sys
sys.path.append('..')
class PiraArgument:
"""
In this class the 0-th entry is... | 7,201 | 26.7 | 132 | py |
PIRA | PIRA-master/lib/TimeTracking.py | """
File: TimeTracking.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: This module allows to track timings of the various bits and pieces with convenience functions.
"""
import os
import lib.Logging as L
class TimeTracker(... | 1,483 | 25.981818 | 126 | py |
PIRA | PIRA-master/lib/RunnerFactory.py | """
File: RunnerFactory.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module to create different Runner objects, depending on the configuration.
"""
import lib.Logging as L
from lib.BatchSystemBackends import BatchSystemIn... | 4,947 | 44.814815 | 126 | py |
PIRA | PIRA-master/lib/FunctorManagement.py | """
File: FunctorManagement.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module to load and manage the user-supplied functors.
"""
import typing
import lib.Utility as U
import lib.Logging as L
from lib.Configuration impor... | 6,589 | 37.313953 | 126 | py |
PIRA | PIRA-master/lib/Exception.py | """
File: Exception.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module holding base exception for all PIRA Exceptions.
"""
class PiraException(Exception):
def __init__(self, message):
super().__init__()
self.... | 386 | 23.1875 | 126 | py |
PIRA | PIRA-master/lib/Pira.py | """
File: Pira.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
Description: Module implementing the main workflow of PIRA.
"""
import lib.Logging as L
import lib.Utility as U
import lib.FunctorManagement as F
import lib.TimeTracking as T... | 10,693 | 40.289575 | 126 | py |
PIRA | PIRA-master/lib/tables.py | """
File: tables.py
License: Part of the PIRA project. Licensed under BSD 3 clause license. See LICENSE.txt file at https://github.com/tudasc/pira
"""
import sqlite3 as db
create_application_table = """ CREATE TABLE IF NOT EXISTS Application (
AppID text PRIMARY KEY,
... | 2,553 | 54.521739 | 126 | py |
CPM-Live | CPM-Live-master/cpm-live/cpmbee_translator.py | from typing import Dict
from cpm_live.generation.bee import CPMBeeBeamSearch
from cpm_live.models import CPMBeeTorch, CPMBeeConfig
from cpm_live.tokenizers import CPMBeeTokenizer
import torch
import spacy
import re
def is_chinese(ch: str):
if "\u4e00" <= ch <= "\u9fff":
return True
return False
def ... | 6,854 | 32.768473 | 180 | py |
CPM-Live | CPM-Live-master/cpm-live/setup.py | from setuptools import setup, find_packages
setup(
name="cpm_live",
version="0.1.0",
author="OpenBMB",
author_email="openbmb@gmail.com",
description="Toolkit for CPM-Live",
packages=find_packages(),
install_requires=[
"numpy",
"torch>=1.10",
"bmtrain>=0.1.8",
... | 452 | 20.571429 | 48 | py |
CPM-Live | CPM-Live-master/cpm-live/pretrain_cpm_bee.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 15,523 | 38.805128 | 99 | py |
CPM-Live | CPM-Live-master/cpm-live/preprocess_dataset.py | import os
from cpm_live.dataset import build_dataset, shuffle_dataset
import shutil
from tqdm import tqdm
import json
import argparse
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("--input", type=str, help="raw dataset path", required=True)
parser.add_argument("--output_path", typ... | 1,268 | 27.2 | 93 | py |
CPM-Live | CPM-Live-master/cpm-live/finetune_cpm_bee.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 16,454 | 37.900709 | 99 | py |
CPM-Live | CPM-Live-master/cpm-live/text_generation.py | from cpm_live.generation.bee import CPMBeeBeamSearch
from cpm_live.models import CPMBeeTorch, CPMBeeConfig
from cpm_live.tokenizers import CPMBeeTokenizer
import torch
if __name__ == "__main__":
data_list = [
{"document": "今天天气是真的<mask_0>", "<ans>": {"<mask_0>": ""}},
]
config = CPMBeeConfig.from... | 778 | 26.821429 | 71 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/arguments.py | # coding=utf-8
# Copyright 2020 The OpenBMB 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/LICENSE-2.0
#
# Unless required b... | 5,021 | 32.704698 | 97 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/__init__.py | 0 | 0 | 0 | py | |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/dataset/distributed_dataset.py | # coding=utf-8
# Copyright 2020 The OpenBMB 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/LICENSE-2.0
#
# Unless required b... | 25,959 | 32.758127 | 131 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/dataset/utils.py | # coding=utf-8
# Copyright 2020 The OpenBMB 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/LICENSE-2.0
#
# Unless required b... | 7,647 | 28.302682 | 98 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/dataset/serializer.py | # coding=utf-8
# Copyright 2020 The OpenBMB 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/LICENSE-2.0
#
# Unless required b... | 1,570 | 24.33871 | 74 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/dataset/__init__.py | from .distributed_dataset import DistributedDataset, SimpleDataset, build_dataset
from .utils import shuffle_dataset, compact_dataset, mask_dataset, merge_dataset
| 163 | 53.666667 | 81 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/models/bee.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 11,433 | 38.157534 | 100 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/models/ant.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 7,842 | 35.47907 | 96 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/models/bee_torch.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 9,873 | 39.970954 | 100 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/models/__init__.py | from .ant import CPMAntConfig, CPMAnt
from .bee import CPMBeeConfig, CPMBee
from .ant_torch import CPMAntTorch
from .bee_torch import CPMBeeTorch
| 146 | 28.4 | 37 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/models/ant_torch.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 6,552 | 37.547059 | 96 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/training_tasks/__init__.py | from . import ant
from . import bee
| 36 | 11.333333 | 17 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/training_tasks/ant/pretrain.py | # coding=utf-8
# Copyright 2020 The OpenBMB 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/LICENSE-2.0
#
# Unless required b... | 4,499 | 37.135593 | 99 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/training_tasks/ant/__init__.py | from .pretrain import CPMAntPretrainDataset
| 44 | 21.5 | 43 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/training_tasks/bee/pretrain.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 38,408 | 35.860845 | 100 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/training_tasks/bee/finetune.py | from ...tokenizers import CPMBeeTokenizer
from .pretrain import _MixedDatasetBatchPacker, _MixedDatasetConfig, CPMBeeBatch
from ...dataset import SimpleDataset
import bmtrain as bmt
class FinetuneDataset:
def __init__(
self,
dataset_path: str,
batch_size: int,
max_length: int,
... | 2,390 | 32.208333 | 81 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/training_tasks/bee/__init__.py | from .pretrain import MixedDataset
from .finetune import FinetuneDataset
| 73 | 23.666667 | 37 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/native_layers/embedding.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 4,165 | 36.531532 | 151 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/native_layers/position_embedding.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 8,848 | 34.681452 | 100 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/native_layers/feedforward.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 3,676 | 29.38843 | 176 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/native_layers/layernorm.py | import torch
@torch.jit.script # type: ignore
def rms_layernorm(hidden: torch.Tensor, weight: torch.Tensor, eps: float):
old_dtype = hidden.dtype
variance = hidden.to(torch.float32).pow(2).mean(dim=-1, keepdim=True)
hidden = (hidden * torch.rsqrt(variance + eps)).to(old_dtype)
return hidden * weight
... | 1,156 | 29.447368 | 122 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/native_layers/linear.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 1,721 | 32.115385 | 109 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/native_layers/transformer.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 4,852 | 37.515873 | 155 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/native_layers/__init__.py | from .embedding import Embedding, EmbeddingExt
from .position_embedding import SegmentPositionEmbedding, BucketPositionBias, RotaryEmbedding
from .linear import Linear
from .layernorm import LayerNorm
from .attention import Attention
from .feedforward import FeedForward
from .blocks import TransformerBlock
from .transf... | 341 | 37 | 93 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/native_layers/attention.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 4,604 | 38.025424 | 191 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/native_layers/blocks.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 8,723 | 34.036145 | 198 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/tokenizers/bee.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 7,675 | 33.267857 | 96 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/tokenizers/ant.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 4,557 | 27.4875 | 99 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/tokenizers/__init__.py | from .ant import CPMAntTokenizer
from .bee import CPMBeeTokenizer
| 66 | 21.333333 | 32 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/layers/embedding.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 4,458 | 36.788136 | 151 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/layers/position_embedding.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 9,197 | 35.070588 | 100 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/layers/feedforward.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 3,770 | 29.658537 | 176 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/layers/layernorm.py | import torch
import bmtrain as bmt
@torch.jit.script # type: ignore
def rms_layernorm(hidden: torch.Tensor, weight: torch.Tensor, eps: float):
old_dtype = hidden.dtype
variance = hidden.to(torch.float32).pow(2).mean(dim=-1, keepdim=True)
hidden = (hidden * torch.rsqrt(variance + eps)).to(old_dtype)
r... | 1,180 | 29.282051 | 122 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/layers/linear.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 1,901 | 31.793103 | 109 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/layers/transformer.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 4,948 | 37.664063 | 155 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/layers/__init__.py | from .embedding import Embedding, EmbeddingExt
from .position_embedding import SegmentPositionEmbedding, BucketPositionBias, RotaryEmbedding
from .linear import Linear
from .layernorm import LayerNorm
from .attention import Attention
from .feedforward import FeedForward
from .blocks import TransformerBlock
from .transf... | 341 | 37 | 93 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/layers/attention.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 4,800 | 38.677686 | 191 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/layers/blocks.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 8,751 | 34.008 | 198 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/utils/export.py | import os
import time
import functools
import torch
import bmtrain as bmt
import json
from cpm_live.models import CPMBee
from .log import logger
from typing import List, Optional
def rename_if_exists(file_path):
if not os.path.exists(file_path):
return
timestamp = time.strftime('%Y%m%d%H%M%S')
fil... | 1,820 | 30.947368 | 95 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/utils/object.py | import bmtrain as bmt
import pickle
import torch
def allgather_objects(obj):
if bmt.world_size() == 1:
return [obj]
with torch.no_grad():
data_bytes: bytes = pickle.dumps(obj)
data_length: int = len(data_bytes)
gpu_data_length = torch.tensor([data_length], device="cuda", dtyp... | 994 | 33.310345 | 88 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/utils/data_utils.py | import torch
def pad(orig_items, key, padding_value=0, padding_side="left"):
items = []
if isinstance(orig_items[0][key], list):
assert isinstance(orig_items[0][key][0], torch.Tensor)
for it in orig_items:
for tr in it[key]:
items.append({key: tr})
else:
... | 1,550 | 33.466667 | 94 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/utils/log.py | import os
import sys
from typing import Any, Dict, Optional, Tuple, Union
import datetime
import json
import logging
import bmtrain as bmt
# Set up the common logger
def _get_logger():
log = logging.getLogger('__name__')
log.setLevel(logging.INFO)
console_handle = logging.StreamHandler(sys.stdout)
nod... | 3,067 | 29.989899 | 97 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/utils/gradient_shrink.py | import torch
class OpGradientShrink(torch.autograd.Function):
@staticmethod
def forward(ctx, x: torch.Tensor, alpha: float):
ctx.alpha = alpha
return x
@staticmethod
def backward(ctx, grad_output):
return grad_output * ctx.alpha, None
def gradient_shrink(x: torch.Tensor, alp... | 382 | 21.529412 | 57 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/utils/config.py | # coding=utf-8
# Copyright 2022 The OpenBMB 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 applicable law or a... | 2,672 | 33.269231 | 93 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/utils/__init__.py | from .config import Config
from .data_utils import pad
from .object import allgather_objects
from .log import LogManager, logger
from .config import load_dataset_config
| 169 | 27.333333 | 39 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/generation/bee.py | from typing import Any, Dict, List, Tuple
import numpy as np
import torch
import torch.nn.functional as F
from .generation_utils import BeamHypotheses, apply_repetition_penalty
from ..tokenizers.bee import CPMBeeTokenizer
from ..models.bee import CPMBee
from ..training_tasks.bee.pretrain import convert_data_to_id
from ... | 26,159 | 40.52381 | 148 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/generation/ant.py | import torch
import torch.nn.functional as F
from .generation_utils import BeamHypotheses, apply_repetition_penalty, top_k_top_p_filtering
from ..utils import pad
class CPMAntGeneration:
def __init__(self, model, tokenizer, prompt_length=32):
model.eval()
self.model = model
self.tokenizer ... | 14,654 | 36.966321 | 148 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/generation/generation_utils.py | import torch
import torch.nn.functional as F
def top_k_top_p_filtering(logits, top_k=0, top_p=0.0, filter_value=-float("inf")):
# This function has been mostly taken from huggingface conversational ai code at
# https://medium.com/huggingface/how-to-build-a-state-of-the-art-conversational-ai-with-transfer-lear... | 4,382 | 37.787611 | 122 | py |
CPM-Live | CPM-Live-master/cpm-live/cpm_live/generation/__init__.py | from .ant import CPMAntBeamSearch, CPMAntRandomSampling, CPMAntGeneration
| 74 | 36.5 | 73 | py |
LOSTIN | LOSTIN-main/GNN-supernode/inference.py | import torch
from torch_geometric.data import DataLoader
import torch.optim as optim
import torch.nn.functional as F
from gnn import GNN
from torch.optim.lr_scheduler import ReduceLROnPlateau
from torch_geometric.utils import degree
from tqdm import tqdm
import argparse
import time
import numpy as np
import json
impor... | 7,700 | 43.514451 | 183 | py |
LOSTIN | LOSTIN-main/GNN-supernode/node_encoder.py | import torch
from features import get_node_feature_dims, get_edge_feature_dims
full_node_feature_dims = get_node_feature_dims()
full_edge_feature_dims = get_edge_feature_dims()
class NodeEncoder(torch.nn.Module):
def __init__(self, emb_dim):
super(NodeEncoder, self).__init__()
self.node... | 1,815 | 28.770492 | 90 | py |
LOSTIN | LOSTIN-main/GNN-supernode/features.py | import json
import pandas as pd
from os import listdir
from os.path import isfile, join
allowable_features = {
'node_type' : ['input', 'intermediate', 'output'],
'command_type' : ['b', 'rf', 'rfz', 'rw', 'rwz', 'resub', 'resub -z'],
'op_type' : ['and_oper', 'or_oper', 'not_oper', 'misc'],
... | 9,664 | 30.792763 | 111 | py |
LOSTIN | LOSTIN-main/GNN-supernode/test_evaluation.py | import torch
from torch_geometric.loader import DataLoader
from torch.utils.data import TensorDataset
import torch.optim as optim
import torch.nn.functional as F
from gnn import GNN
from torch.optim.lr_scheduler import ReduceLROnPlateau
from tqdm import tqdm
import argparse
import time
import numpy as np
import json
i... | 7,667 | 40.225806 | 183 | py |
LOSTIN | LOSTIN-main/GNN-supernode/evaluate.py | from sklearn.metrics import roc_auc_score, average_precision_score
import pandas as pd
import os
import numpy as np
try:
import torch
except ImportError:
torch = None
### Evaluator for graph classification
class Evaluator:
def __init__(self, name):
self.name = name
meta_info = pd.read_csv... | 14,336 | 40.677326 | 222 | py |
LOSTIN | LOSTIN-main/GNN-supernode/make_master_file.py | ### script for writing meta information of datasets into master.csv
### for graph property prediction datasets.
import pandas as pd
dataset_list = []
dataset_dict = {}
### add cdfg_lut
name = 'pita_db'
dataset_dict[name] = {'eval metric': 'rmse'}
dataset_dict[name]['download_name'] = 'cdfg_lut'
dataset_dict[name]['v... | 854 | 29.535714 | 67 | py |
LOSTIN | LOSTIN-main/GNN-supernode/read_graph_pyg.py | import pandas as pd
import torch
from torch_geometric.data import Data
import os.path as osp
import numpy as np
from read_graph_raw import read_csv_graph_raw
from tqdm import tqdm
def read_graph_pyg(raw_dir, add_inverse_edge = False, additional_node_files = [], additional_edge_files = [], binary = False):
graph_l... | 1,697 | 29.321429 | 185 | py |
LOSTIN | LOSTIN-main/GNN-supernode/read_graph_raw.py | import pandas as pd
import os.path as osp
import os
import numpy as np
from tqdm import tqdm
### reading raw files from a directory.
### for homogeneous graph
def read_csv_graph_raw(raw_dir, add_inverse_edge = False, additional_node_files = [], additional_edge_files = []):
'''
raw_dir: path to the raw director... | 6,248 | 37.103659 | 170 | py |
LOSTIN | LOSTIN-main/GNN-supernode/main_gnn.py | import torch
from torch_geometric.loader import DataLoader
import torch.optim as optim
import torch.nn.functional as F
from gnn import GNN
from torch.optim.lr_scheduler import ReduceLROnPlateau
from tqdm import tqdm
import argparse
import time
import numpy as np
import json
import operator
from functools import reduce... | 9,703 | 41.375546 | 183 | py |
LOSTIN | LOSTIN-main/GNN-supernode/gnn.py | import torch
from torch_geometric.nn import MessagePassing,BatchNorm
from torch_geometric.nn import global_add_pool, global_mean_pool, global_max_pool, GlobalAttention, Set2Set
import torch.nn.functional as F
from torch_geometric.nn.inits import uniform
from torch.nn import Sequential, ReLU, Linear, ModuleList
from co... | 3,673 | 39.822222 | 188 | py |
LOSTIN | LOSTIN-main/GNN-supernode/conv.py | import torch
from torch_geometric.nn import MessagePassing
import torch.nn.functional as F
from torch_geometric.nn import global_mean_pool, global_add_pool
from node_encoder import NodeEncoder,EdgeEncoder
from torch_geometric.utils import degree
import math
### GIN convolution along the graph structure
class GINConv(... | 8,910 | 35.520492 | 182 | py |
LOSTIN | LOSTIN-main/GNN-supernode/dataset_pyg.py | from torch_geometric.data import InMemoryDataset
import pandas as pd
import shutil, os
import os.path as osp
import torch
import numpy as np
from read_graph_pyg import read_graph_pyg
class PygGraphPropPredDataset(InMemoryDataset):
def __init__(self, name, root = 'dataset', transform=None, pre_transform = None, me... | 6,385 | 41.291391 | 212 | py |
LOSTIN | LOSTIN-main/GNN-LSTM/main_gnn_customized_delay.py | ### Libraries
import numpy as np
import argparse
from tqdm import tqdm
import matplotlib.pyplot as plts
import pandas as pd
import torch
# Preliminaries
# torchtext 0.6.0
from torchtext.data import Field, TabularDataset, BucketIterator
# Models
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence... | 9,155 | 36.679012 | 148 | py |
LOSTIN | LOSTIN-main/GNN-LSTM/node_encoder.py | import torch
from features import get_node_feature_dims, get_edge_feature_dims
full_node_feature_dims = get_node_feature_dims()
full_edge_feature_dims = get_edge_feature_dims()
class NodeEncoder(torch.nn.Module):
def __init__(self, emb_dim):
super(NodeEncoder, self).__init__()
self.node... | 1,857 | 28.967742 | 90 | py |
LOSTIN | LOSTIN-main/GNN-LSTM/features.py | import json
import pandas as pd
allowable_features = {
'node_type': ['input', 'intermediate', 'output'],
'op_type': ['and_oper', 'or_oper', 'not_oper', 'misc'],
}
def safe_index(l, e):
"""
Return index of element e in list l. If e is not present, return the last index
"""
try:
re... | 2,664 | 23.906542 | 107 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.