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
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/models/mmbt/__init__.py
# flake8: noqa # There's no way to ignore "F401 '...' imported but unused" warnings in this # module, but to preserve other warnings. So, don't check this module at all. # Copyright 2020 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use thi...
1,773
31.254545
115
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/models/marian/modeling_marian.py
# coding=utf-8 # Copyright 2021 The Marian Team Authors and 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/licen...
56,443
45.265574
239
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/models/marian/convert_marian_to_pytorch.py
# Copyright 2020 The HuggingFace 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 by applicabl...
23,458
36.060032
119
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/models/marian/convert_marian_tatoeba_to_pytorch.py
# Copyright 2020 The HuggingFace 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 by applicabl...
33,873
25.693459
175
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/models/marian/__init__.py
# flake8: noqa # There's no way to ignore "F401 '...' imported but unused" warnings in this # module, but to preserve other warnings. So, don't check this module at all. # Copyright 2020 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use thi...
2,535
29.926829
115
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/models/marian/modeling_tf_marian.py
# coding=utf-8 # Copyright 2021 The Marian Team Authors and 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/licen...
61,637
45.837386
236
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/models/flaubert/modeling_tf_flaubert.py
# coding=utf-8 # Copyright 2019-present, Facebook, Inc and 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 # # Un...
39,450
41.058635
160
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/models/flaubert/modeling_flaubert.py
# coding=utf-8 # Copyright 2019-present CNRS, Facebook Inc. and 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 #...
17,516
39.454965
120
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/models/flaubert/__init__.py
# flake8: noqa # There's no way to ignore "F401 '...' imported but unused" warnings in this # module, but to preserve other warnings. So, don't check this module at all. # Copyright 2020 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use thi...
3,337
33.412371
115
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/models/mbart/convert_mbart_original_checkpoint_to_pytorch.py
# Copyright 2020 The HuggingFace 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 by applicabl...
2,119
41.4
117
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/models/mbart/modeling_tf_mbart.py
# coding=utf-8 # Copyright 2021 The Fairseq Authors and 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/...
61,341
46.113671
236
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/models/mbart/modeling_mbart.py
# coding=utf-8 # Copyright 2021, The Facebook AI Research Team and 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.or...
66,941
44.569775
239
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/models/mbart/__init__.py
# flake8: noqa # There's no way to ignore "F401 '...' imported but unused" warnings in this # module, but to preserve other warnings. So, don't check this module at all. # Copyright 2020 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use thi...
2,943
31
115
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/commands/add_new_model.py
# Copyright 2020 The HuggingFace 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 by applicabl...
9,392
40.017467
119
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/commands/convert.py
# Copyright 2020 The HuggingFace 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 by applicabl...
7,189
40.560694
117
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/commands/train.py
# Copyright 2020 The HuggingFace 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 by applicabl...
6,397
38.73913
117
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/commands/env.py
# Copyright 2020 The HuggingFace 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 by applicabl...
2,604
34.684932
105
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/benchmark/benchmark.py
# coding=utf-8 # Copyright 2018 The 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 at # # http://www.a...
10,629
38.664179
181
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/benchmark/benchmark_utils.py
# This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp # Copyright 2020 The HuggingFace Team and the AllenNLP authors. 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 o...
37,341
39.85558
204
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/benchmark/benchmark_args.py
# coding=utf-8 # Copyright 2018 The 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 at # # http://www.a...
3,777
31.568966
127
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/utils/dummy_pt_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..file_utils import requires_pytorch class PyTorchBenchmark: def __init__(self, *args, **kwargs): requires_pytorch(self) class PyTorchBenchmarkArguments: def __init__(self, *args, **kwargs): requires_pytorch(sel...
52,291
20.842941
75
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/utils/dummy_flax_objects.py
# This file is autogenerated by the command `make fix-copies`, do not edit. from ..file_utils import requires_flax class FlaxPreTrainedModel: def __init__(self, *args, **kwargs): requires_flax(self) @classmethod def from_pretrained(self, *args, **kwargs): requires_flax(self) FLAX_MODEL_...
1,088
20.352941
75
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/data/data_collator.py
# Copyright 2020 The HuggingFace 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 by applicabl...
31,408
48.697785
181
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/data/test_generation_utils.py
# Copyright 2020 The HuggingFace 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 by applicabl...
3,438
33.049505
94
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/data/datasets/glue.py
# Copyright 2020 The HuggingFace 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 by applicabl...
6,227
36.293413
119
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/data/datasets/squad.py
# Copyright 2020 The HuggingFace 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 by applicabl...
9,138
39.438053
129
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/data/datasets/language_modeling.py
# Copyright 2020 The HuggingFace 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 by applicabl...
22,821
42.387833
119
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/data/processors/squad.py
# Copyright 2020 The HuggingFace 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 by applicabl...
33,279
38.43128
125
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/data/processors/utils.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The 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 cop...
13,911
38.410765
119
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/pipelines/base.py
# coding=utf-8 # Copyright 2018 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 applicable...
23,006
35.752396
137
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/pipelines/token_classification.py
from typing import TYPE_CHECKING, List, Optional, Union import numpy as np from ..file_utils import add_end_docstrings, is_tf_available, is_torch_available from ..modelcard import ModelCard from ..models.bert.tokenization_bert import BasicTokenizer from ..tokenization_utils import PreTrainedTokenizer from .base impor...
12,183
39.078947
127
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/pipelines/text_classification.py
import numpy as np from ..file_utils import add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING if is_torch_available(): from ..models.auto.modelin...
3,194
38.9375
119
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/pipelines/fill_mask.py
from typing import TYPE_CHECKING, Optional, Union import numpy as np from ..file_utils import add_end_docstrings, is_tf_available, is_torch_available from ..modelcard import ModelCard from ..tokenization_utils import PreTrainedTokenizer from ..utils import logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler...
8,002
40.041026
126
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/pipelines/question_answering.py
from collections.abc import Iterable from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union import numpy as np from ..data import SquadExample, SquadFeatures, squad_convert_examples_to_features from ..file_utils import add_end_docstrings, is_tf_available, is_torch_available from ..modelcard import Model...
23,982
48.04499
128
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/pipelines/text2text_generation.py
from ..file_utils import add_end_docstrings, is_tf_available, is_torch_available from ..tokenization_utils import TruncationStrategy from ..utils import logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.auto.modeling_tf_auto import TF_MODEL_FOR...
12,203
44.707865
179
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/pipelines/conversational.py
import uuid from typing import List, Optional, Union from ..file_utils import add_end_docstrings, is_tf_available, is_torch_available from ..tokenization_utils import TruncationStrategy from ..utils import logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is...
17,335
43.337596
158
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/pipelines/table_question_answering.py
import collections import numpy as np from ..file_utils import add_end_docstrings, is_torch_available, requires_pandas from .base import PIPELINE_INIT_ARGS, ArgumentHandler, Pipeline if is_torch_available(): import torch from ..models.auto.modeling_auto import MODEL_FOR_TABLE_QUESTION_ANSWERING_MAPPING c...
13,772
48.014235
150
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/pipelines/__init__.py
# flake8: noqa # There's no way to ignore "F401 '...' imported but unused" warnings in this # module, but to preserve other warnings. So, don't check this module at all. # coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this...
19,326
45.126492
121
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes/src/transformers/pipelines/text_generation.py
from ..file_utils import add_end_docstrings from .base import PIPELINE_INIT_ARGS, Pipeline @add_end_docstrings(PIPELINE_INIT_ARGS) class TextGenerationPipeline(Pipeline): """ Language generation pipeline using any :obj:`ModelWithLMHead`. This pipeline predicts the words that will follow a specified text p...
8,329
45.277778
147
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/interact.py
# coding=utf-8 import json import datetime import torch from torch import Tensor import numpy as np import os import logging import argparse import random from transformers.trainer_utils import set_seed from utils.building_utils import boolean_string, build_model, deploy_model from inputters import inputters from inp...
5,974
30.781915
87
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/prepare.py
# coding=utf-8 import argparse import json import shutil import pickle import os import logging import multiprocessing as mp from os.path import dirname, exists, join import torch import tqdm from inputters import inputters from utils.building_utils import build_model parser = argparse.ArgumentParser() parser.add_ar...
2,764
30.781609
111
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/infer.py
# coding=utf-8 import argparse import json import logging import os import nltk import numpy as np import torch from sklearn.metrics import classification_report, f1_score, confusion_matrix from torch import Tensor from transformers.trainer_utils import set_seed from inputters import inputters from inputters.inputte...
16,817
42.012788
149
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/train.py
# coding=utf-8 # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import argparse import datetime import json import logging import os import sys import time from os.path import join import numpy as np import torch import tqdm from torch import Tensor from torch.distributed import get_rank, get_...
16,784
38.964286
129
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/inputters/strat.py
# coding=utf-8 import json import tqdm import torch from typing import List from transformers.tokenization_utils import PreTrainedTokenizer import numpy as np import random from functools import partial from torch.utils.data import DataLoader, Sampler, Dataset from torch.nn.utils.rnn import pad_sequence from math impo...
10,191
32.860465
117
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/inputters/inputter_utils.py
# coding=utf-8 import gzip import json import os import math import random import pickle from functools import partial from torch.utils.data import DataLoader, Sampler def _norm(s): return ' '.join(s.strip().split()) class BucketSampler(Sampler): """ this sampler will sort data by sequence length ""...
3,298
33.010309
95
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/inputters/vanilla.py
# coding=utf-8 import json import tqdm import torch from typing import List from transformers.tokenization_utils import PreTrainedTokenizer import numpy as np import random from functools import partial from torch.utils.data import DataLoader, Sampler, Dataset from torch.nn.utils.rnn import pad_sequence from math impo...
9,378
32.859206
117
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/models/vanilla_blenderbot_small.py
# coding=utf-8 # copied from bart import torch import torch.nn as nn import torch.nn.functional as F from models.model_utils import BaseModel from transformers.generation_utils import top_k_top_p_filtering from transformers.models.blenderbot_small import (BlenderbotSmallConfig, BlenderbotSmallForConditionalGeneration,...
4,539
35.910569
114
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/models/model_utils.py
# coding=utf-8 import math from dataclasses import dataclass from typing import Optional, Tuple, Dict, Iterable import torch import torch.nn as nn import torch.nn.functional as F from transformers import (PreTrainedTokenizer, PreTrainedModel, PretrainedConfig) class BaseModel(PreTrainedModel): def __init__(self...
607
26.636364
81
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/models/vanilla_dialogpt.py
# coding=utf-8 # copied from gpt2 import torch import torch.nn as nn import torch.nn.functional as F from models.model_utils import BaseModel from transformers.generation_utils import top_k_top_p_filtering from transformers.models.gpt2 import (GPT2Config, GPT2LMHeadModel,) from transformers.modeling_outputs import (Ca...
5,056
38.20155
119
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/models/strat_blenderbot_small.py
# coding=utf-8 # copied from bart import torch import torch.nn as nn import torch.nn.functional as F from models.model_utils import BaseModel from transformers.generation_utils import top_k_top_p_filtering from transformers.models.blenderbot_small import (BlenderbotSmallConfig, BlenderbotSmallForConditionalGeneration,...
6,130
36.845679
130
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/models/strat_dialogpt.py
# coding=utf-8 # copied from gpt2 import torch import torch.nn as nn import torch.nn.functional as F from models.model_utils import BaseModel from transformers.generation_utils import top_k_top_p_filtering from transformers.models.gpt2 import (GPT2Config, GPT2LMHeadModel,) from transformers.modeling_outputs import (Ca...
6,636
38.041176
119
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/__init__.py
# May help avoid undefined symbol errors https://pytorch.org/cppdocs/notes/faq.html#undefined-symbol-errors-from-pytorch-aten import torch import warnings if torch.distributed.is_available(): from . import parallel from . import amp from . import fp16_utils # For optimizers and normalization there is no Python f...
851
39.571429
125
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/scaler.py
import torch from ..multi_tensor_apply import multi_tensor_applier from ._amp_state import _amp_state, master_params, maybe_print from itertools import product def scale_check_overflow_python(model_grad, master_grad, scale, check_overflow=False): # Exception handling for 18.04 compatibility if check_overflow: ...
10,504
47.188073
110
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/_process_optimizer.py
import types from ..fp16_utils import master_params_to_model_params from ..multi_tensor_apply import multi_tensor_applier from ._amp_state import maybe_print import torch from ..optimizers import FusedSGD class AmpOptimizerState(object): def __init__(self): pass def _master_params_to_model_params(self):...
20,747
41.342857
115
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/_amp_state.py
# This is a "header object" that allows different amp modules to communicate. # I'm a C++ guy, not a python guy. I decided this approach because it seemed most C++-like. # But apparently it's ok: # http://effbot.org/pyfaq/how-do-i-share-global-variables-across-modules.htm import os import torch TORCH_MAJOR = int(torc...
1,987
27.811594
92
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/utils.py
from . import compat import functools import itertools import torch def is_cuda_enabled(): return torch.version.cuda is not None def get_cuda_version(): return tuple(int(x) for x in torch.version.cuda.split('.')) def is_fp_tensor(x): if is_nested(x): # Fast-fail version of all(is_fp_tensor) ...
7,222
33.232227
86
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/opt.py
import contextlib import warnings from .scaler import LossScaler, master_params from ._amp_state import maybe_print import numpy as np class OptimWrapper(object): def __init__(self, optimizer, amp_handle, num_loss): self._optimizer = optimizer self._amp_handle = amp_handle self._num_loss ...
3,446
32.144231
80
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/amp.py
from . import compat, rnn_compat, utils, wrap from .handle import AmpHandle, NoOpHandle from .lists import functional_overrides, torch_overrides, tensor_overrides from ._amp_state import _amp_state from .frontend import * import functools import itertools import torch _DECORATOR_HANDLE = None _USER_CAST_REGISTRY = ...
7,266
39.825843
101
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/compat.py
import torch # True for post-0.4, when Variables/Tensors merged. def variable_is_tensor(): v = torch.autograd.Variable() return isinstance(v, torch.Tensor) def tensor_is_variable(): x = torch.Tensor() return type(x) == torch.autograd.Variable # False for post-0.4 def tensor_is_float_tensor(): x =...
1,393
28.659574
77
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/wrap.py
from . import compat from . import utils from ._amp_state import _amp_state from . import rnn_compat import functools import torch def make_cast_wrapper(orig_fn, cast_fn, handle, try_caching=False): @functools.wraps(orig_fn) def wrapper(*args, **kwargs): if not handle.is_active(...
11,242
39.588448
89
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/_initialize.py
import torch from torch._six import string_classes import functools import numpy as np import sys from types import MethodType import warnings from ._amp_state import _amp_state, warn_or_err, container_abcs from .handle import disable_casts from .scaler import LossScaler from ._process_optimizer import _process_optimiz...
11,606
42.965909
111
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/frontend.py
import torch from ._initialize import _initialize from ._amp_state import _amp_state, warn_or_err, maybe_print from collections import OrderedDict class Properties(object): """ This class has two purposes: to establish a set of default properties, and to route setting of these attributes through __setattr...
21,267
47.009029
115
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/rnn_compat.py
from . import utils, wrap import torch _VF = torch._C._VariableFunctions RNN_NAMES = ['rnn_relu', 'rnn_tanh', 'gru', 'lstm'] def _gen_VF_wrapper(name): def wrapper(*args, **kwargs): return getattr(_VF, name)(*args, **kwargs) return wrapper # Some python magic to generate an object that has the rnn ce...
1,995
35.962963
79
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/handle.py
import contextlib import warnings import sys import torch from . import utils from .opt import OptimWrapper from .scaler import LossScaler from ._amp_state import _amp_state, master_params, maybe_print if torch.distributed.is_available(): from ..parallel.LARC import LARC # There's no reason to expose the notion...
12,066
41.79078
118
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/lists/functional_overrides.py
# TODO: think about the following two. They do weird things. # - torch.nn.utils.clip_grad (but it should always be fp32 anyway) # - torch.nn.utils.weight_norm # Notes: # F.instance_norm uses batch_norm internally. Which correctly handles # fp16 in/out with fp32 weights. So we shouldn't do anything for # either of...
2,248
26.765432
96
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/lists/tensor_overrides.py
from .. import compat from . import torch_overrides import importlib import torch # if compat.variable_is_tensor() and not compat.tensor_is_variable(): MODULE = torch.Tensor # else: # MODULE = torch.autograd.Variable FP16_FUNCS = compat.filter_attrs(MODULE, [ '__matmul__', ]) FP32_FUNCS = compat.filter_at...
1,402
20.921875
72
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/amp/lists/torch_overrides.py
import torch from .. import utils MODULE = torch FP16_FUNCS = [ # Low level functions wrapped by torch.nn layers. # The wrapper layers contain the weights which are then passed in as a parameter # to these functions. 'conv1d', 'conv2d', 'conv3d', 'conv_transpose1d', 'conv_transpose2d'...
2,082
16.956897
84
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/normalization/fused_layer_norm.py
import math import torch import numbers from torch.nn.parameter import Parameter from torch.nn import init from torch.nn import functional as F import importlib global fused_layer_norm_cuda fused_layer_norm_cuda = None class FusedLayerNormAffineFunction(torch.autograd.Function): @staticmethod def forward(ctx, in...
6,612
38.837349
102
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/fp16_utils/fp16_optimizer.py
import torch from torch import nn from torch.autograd import Variable from torch.nn.parameter import Parameter from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors from ..amp._amp_state import _amp_state, maybe_print from ..amp.scaler import LossScaler from ..multi_tensor_apply import multi_tensor...
27,769
49.036036
425
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/fp16_utils/fp16util.py
import torch import torch.nn as nn from torch.autograd import Variable from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors class tofp16(nn.Module): """ Utility module that implements:: def forward(self, input): return input.half() """ def __init__(self): ...
7,141
36.989362
337
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/fp16_utils/loss_scaler.py
import torch # item() is a recent addition, so this helps with backward compatibility. def to_python_float(t): if hasattr(t, 'item'): return t.item() else: return t[0] class LossScaler: """ Class that manages a static loss scale. This class is intended to interact with :class:`FP1...
7,568
39.475936
326
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/parallel/multiproc.py
import torch import sys import subprocess def docstring_hack(): """ Multiproc file which will launch a set of processes locally for multi-gpu usage: python -m apex.parallel.multiproc main.py ... """ pass argslist = list(sys.argv)[1:] world_size = torch.cuda.device_count() if '--world-size' in arg...
884
23.583333
77
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/parallel/optimized_sync_batchnorm.py
import torch from torch.nn.modules.batchnorm import _BatchNorm from torch.nn import functional as F import syncbn from .optimized_sync_batchnorm_kernel import SyncBatchnormFunction class SyncBatchNorm(_BatchNorm): """ synchronized batch normalization module extented from `torch.nn.BatchNormNd` with the a...
4,364
49.755814
252
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/parallel/optimized_sync_batchnorm_kernel.py
import torch from torch.autograd.function import Function import syncbn from apex.parallel import ReduceOp class SyncBatchnormFunction(Function): @staticmethod def forward(ctx, input, z, weight, bias, running_mean, running_variance, eps, track_running_stats = True, momentum = 1.0, process_group = None, chann...
5,559
45.333333
189
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/parallel/LARC.py
import torch from torch import nn from torch.nn.parameter import Parameter class LARC(object): """ :class:`LARC` is a pytorch implementation of both the scaling and clipping variants of LARC, in which the ratio between gradient and parameter magnitudes is used to calculate an adaptive local learning r...
4,018
36.212963
225
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/parallel/distributed.py
import torch import torch.distributed as dist from torch.nn.modules import Module from torch.autograd import Variable from collections import OrderedDict from itertools import chain import copy import importlib from ..multi_tensor_apply import multi_tensor_applier imported_flatten_impl = False def import_flatten_impl...
30,651
46.89375
496
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/parallel/__init__.py
import torch if hasattr(torch.distributed, 'ReduceOp'): ReduceOp = torch.distributed.ReduceOp elif hasattr(torch.distributed, 'reduce_op'): ReduceOp = torch.distributed.reduce_op else: ReduceOp = torch.distributed.deprecated.reduce_op from .distributed import DistributedDataParallel, Reducer # This is tri...
3,667
37.208333
162
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/parallel/sync_batchnorm.py
import torch from torch.nn.modules.batchnorm import _BatchNorm from torch.nn import functional as F from .sync_batchnorm_kernel import SyncBatchnormFunction from apex.parallel import ReduceOp class SyncBatchNorm(_BatchNorm): """ synchronized batch normalization module extented from ``torch.nn.BatchNormNd`` ...
6,532
47.392593
228
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/parallel/sync_batchnorm_kernel.py
import torch from torch.autograd.function import Function from apex.parallel import ReduceOp class SyncBatchnormFunction(Function): @staticmethod def forward(ctx, input, weight, bias, running_mean, running_variance, eps, process_group, world_size): torch.cuda.nvtx.range_push("sync_BN_fw") # ...
3,761
41.75
106
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/RNN/cells.py
import torch import torch.nn as nn import torch.nn.functional as F from .RNNBackend import RNNCell from torch.nn._functions.thnn import rnnFusedPointwise as fusedBackend import math class mLSTMRNNCell(RNNCell): """ mLSTMRNNCell """ def __init__(self, input_size, hidden_size, bias = False, output_...
2,550
29.011765
156
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/RNN/RNNBackend.py
import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.functional as F import math def is_iterable(maybe_iterable): return isinstance(maybe_iterable, list) or isinstance(maybe_iterable, tuple) def flatten_list(tens_list): """ flatten_list """ if not is_iterable(...
11,578
30.636612
126
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/RNN/models.py
import torch from torch.nn._functions.rnn import LSTMCell, RNNReLUCell, RNNTanhCell, GRUCell from .RNNBackend import bidirectionalRNN, stackedRNN, RNNCell from .cells import mLSTMRNNCell, mLSTMCell def toRNNBackend(inputRNN, num_layers, bidirectional=False, dropout = 0): """ :class:`toRNNBackend` """ ...
2,137
37.872727
129
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/nvtx/nvmarker.py
""" This file intercepts (monkey patches) the following functions and adds NVTX markers. torch.* torch.Tensor.* torch.nn.functional.* torch.nn.*.forward The NVTX markers (one or more) contain the following information call trace (a list of file_name:line_number) extra_repr() from torch.nn modules module/class n...
6,153
26.596413
636
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/examples/operators.py
#!/usr/bin/env python3 """ This file checks all Python operators. """ import sys import torch import torch.cuda.profiler as profiler import operator import inspect #Import and initialize pyprof from apex import pyprof pyprof.nvtx.init() X = 1024 Y = 1024 fa = torch.rand(X, Y).cuda() fb = torch.rand(X, Y).cuda() fc...
3,439
22.561644
158
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/examples/simple.py
#!/usr/bin/env python3 """ This simple file provides an example of how to - import the pyprof library and initialize it - use the emit_nvtx context manager - start and stop the profiler Only kernels within profiler.start and profiler.stop calls are profiled. To profile $ nvprof -f -o simple.sql --profile-from-star...
791
19.307692
72
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/examples/lenet.py
#!/usr/bin/env python3 import torch import torch.nn as nn import torch.nn.functional as F import torch.cuda.profiler as profiler import torch.optim as optim from apex import pyprof pyprof.nvtx.init() class LeNet5(nn.Module): def __init__(self): super(LeNet5, self).__init__() # 1 input image channel, 6 output ch...
1,679
24.454545
70
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/examples/imagenet/imagenet.py
#!/usr/bin/env python3 """ Example to run pyprof with imagenet models. """ import sys import torch import torch.nn as nn import torchvision.models as models import torch.cuda.profiler as profiler import argparse from apex import pyprof from apex.optimizers import FusedAdam def parseArgs(): parser = argparse.Argume...
4,109
29.220588
530
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/examples/jit/jit_trace_method.py
#!/usr/bin/env python3 import torch import torch.cuda.profiler as profiler from apex import pyprof class Foo(torch.nn.Module): def __init__(self, size): super(Foo, self).__init__() self.n = torch.nn.Parameter(torch.ones(size)) self.m = torch.nn.Parameter(torch.ones(size)) def forward(...
817
21.108108
53
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/examples/jit/jit_script_function.py
#!/usr/bin/env python3 import torch import torch.cuda.profiler as profiler from apex import pyprof #The following creates an object "foo" of type ScriptModule #The new object has a function called "forward" @torch.jit.script def foo(x, y): return torch.sigmoid(x) + y #Initialize pyprof after the JIT step pyprof.nv...
620
19.032258
59
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/examples/jit/jit_trace_function.py
#!/usr/bin/env python3 import torch import torch.cuda.profiler as profiler from apex import pyprof def foo(x, y): return torch.sigmoid(x) + y x = torch.zeros(4,4).cuda() y = torch.ones(4,4).cuda() #JIT the function using tracing #This returns an object of type ScriptModule with a forward method. traced_foo = torch...
675
20.806452
67
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/examples/jit/jit_script_method.py
#!/usr/bin/env python3 import torch import torch.cuda.profiler as profiler from apex import pyprof class Foo(torch.jit.ScriptModule): def __init__(self, size): super(Foo, self).__init__() self.n = torch.nn.Parameter(torch.ones(size)) self.m = torch.nn.Parameter(torch.ones(size)) @torc...
689
20.5625
53
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/examples/apex/fused_layer_norm.py
import torch import fused_layer_norm_cuda from apex.normalization import FusedLayerNorm from apex import pyprof pyprof.nvtx.init() pyprof.nvtx.wrap(fused_layer_norm_cuda, 'forward') pyprof.nvtx.wrap(fused_layer_norm_cuda, 'backward') pyprof.nvtx.wrap(fused_layer_norm_cuda, 'forward_affine') pyprof.nvtx.wrap(fused_laye...
790
26.275862
69
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/examples/apex/fused_adam.py
import torch import fused_adam_cuda from apex.optimizers import FusedAdam, FP16_Optimizer from apex import pyprof pyprof.nvtx.init() pyprof.nvtx.wrap(fused_adam_cuda, 'adam') model = torch.nn.Linear(10, 20).cuda().half() criterion = torch.nn.CrossEntropyLoss().cuda() optimizer = FusedAdam(model.parameters()) optimize...
546
25.047619
61
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/examples/custom_func_module/custom_module.py
#!/usr/bin/env python3 import torch import torch.cuda.profiler as profiler from apex import pyprof pyprof.nvtx.init() class Foo(torch.nn.Module): def __init__(self, size): super(Foo, self).__init__() self.n = torch.nn.Parameter(torch.ones(size)) self.m = torch.nn.Parameter(torch.ones(size)...
601
20.5
53
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/examples/custom_func_module/custom_function.py
#!/usr/bin/env python3 import torch import torch.cuda.profiler as profiler from apex import pyprof #Initialize pyprof pyprof.nvtx.init() class Foo(torch.autograd.Function): @staticmethod def forward(ctx, in1, in2): out = in1 + in2 #This could be a custom C/C++ function. return out @staticmethod def backward...
762
21.441176
58
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/examples/user_annotation/resnet.py
#!/usr/bin/env python3 """ An example showing use of nested NVTX markers. """ import torch import torch.nn as nn import torch.cuda.profiler as profiler import torch.cuda.nvtx as nvtx from apex import pyprof pyprof.nvtx.init() def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1): """3x3 convolution wi...
5,660
25.208333
90
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/parse/nvvp.py
import sys class NVVP(object): """ This class gets kernel information from the SQL (nvvp) database. """ driverT = "CUPTI_ACTIVITY_KIND_DRIVER" runtimeT = "CUPTI_ACTIVITY_KIND_RUNTIME" kernelT = "CUPTI_ACTIVITY_KIND_CONCURRENT_KERNEL" markerT = "CUPTI_ACTIVITY_KIND_MARKER" stringT = "StringTable" def __init_...
8,803
30.109541
192
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/parse/parse.py
#!/usr/bin/env python3 """ Parse the SQL db and print a dictionary for every kernel. """ import sys import argparse from tqdm import tqdm from .db import DB from .kernel import Kernel from .nvvp import NVVP def parseArgs(): parser = argparse.ArgumentParser(prog=sys.argv[0], description="Parse SQL (nvvp) db.") par...
2,907
22.642276
156
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/parse/kernel.py
import cxxfilt, struct, binascii #Helper functions def demangle(name): """ Demangle a C++ string """ return cxxfilt.demangle(name) def encode_object_id(pid, tid): """ Given process id (pid) and thread id (tid), return the object id. object id = pid (little endian 4 bytes) + tid (little endian 8 bytes) """ o...
5,286
24.056872
175
py
Emotional-Support-Conversation
Emotional-Support-Conversation-main/codes_zcj/apex/pyprof/prof/embedding.py
from collections import OrderedDict from .utility import Utility from .base import OperatorLayerBase class Embedding(OperatorLayerBase): def __init__(self, d): marker = eval(d.argMarker[0]) mod = marker['mod'] op = marker['op'] args = marker['args'] self.marker = marker self.mod_ = mod self.op_ = op ...
1,409
18.583333
105
py