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
lammps-develop
lammps-develop/examples/mliap/jax/mliap_unified_jax_kokkos.py
from lammps.mliap.mliap_unified_abc import MLIAPUnified import numpy as np import jax import jax.dlpack import jax.numpy as jnp from jax import jit from functools import partial import cupy import os # Required else get `jaxlib.xla_extension.XlaRuntimeError: RESOURCE_EXHAUSTED: Out of memory` # Does not fix GPU proble...
2,236
30.957143
93
py
lammps-develop
lammps-develop/examples/mliap/jax/write_unified.py
""" interface for creating LAMMPS MLIAP Unified models. """ import pickle import numpy as np from lammps.mliap.mliap_unified_abc import MLIAPUnified #from deploy_script import MyModel class MLIAPInterface(MLIAPUnified): """ Class for creating ML-IAP Unified model based on hippynn graphs. """ def __in...
2,748
30.597701
140
py
lammps-develop
lammps-develop/examples/mliap/jax/mliap_unified_jax.py
from lammps.mliap.mliap_unified_abc import MLIAPUnified import numpy as np import jax import jax.numpy as jnp from jax import jit from functools import partial import os # Required else get `jaxlib.xla_extension.XlaRuntimeError: RESOURCE_EXHAUSTED: Out of memory` os.environ["XLA_PYTHON_CLIENT_PREALLOCATE"]="false" os....
1,910
29.822581
93
py
lammps-develop
lammps-develop/examples/mliap/jax/deploy_script.py
import lammps import lammps.mliap #from lammps.mliap.mliap_unified_lj import MLIAPUnifiedLJ from mliap_unified_jax import MLIAPUnifiedJAX def create_pickle(): unified = MLIAPUnifiedJAX(["Ar"]) unified.pickle('mliap_unified_jax_Ar.pkl') create_pickle()
262
22.909091
57
py
lammps-develop
lammps-develop/python/lammps/mliap/pytorch.py
# ---------------------------------------------------------------------- # LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator # https://www.lammps.org/ Sandia National Laboratories # LAMMPS Development team: developers@lammps.org # # Copyright (2003) Sandia Corporation. Under the terms of Contr...
9,940
28.852853
115
py
simpletransformers
simpletransformers-master/examples/language_generation/train_new_lm.py
import argparse import logging from simpletransformers.language_modeling import LanguageModelingModel logging.basicConfig(level=logging.INFO) transformers_logger = logging.getLogger("transformers") transformers_logger.setLevel(logging.WARNING) train_args = { "reprocess_input_data": True, "overwrite_output_d...
1,568
23.138462
81
py
simpletransformers
simpletransformers-master/simpletransformers/language_modeling/language_modeling_model.py
#!/usr/bin/env python # coding: utf-8 from __future__ import absolute_import, division, print_function import json import logging import math import os import random import warnings from dataclasses import asdict from multiprocessing import cpu_count from typing import Dict, List import numpy as np import pandas as...
68,455
39.967086
236
py
simpletransformers
simpletransformers-master/simpletransformers/language_modeling/language_modeling_utils.py
import logging import os import pickle from multiprocessing import Pool from typing import Tuple import torch from torch.utils.data import Dataset from datasets import load_dataset from tqdm.auto import tqdm from transformers import PreTrainedTokenizer logger = logging.getLogger(__name__) def encode(data): toke...
9,777
36.037879
111
py
simpletransformers
simpletransformers-master/simpletransformers/classification/classification_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...
33,415
31.857424
102
py
simpletransformers
simpletransformers-master/simpletransformers/classification/classification_model.py
#!/usr/bin/env python # coding: utf-8 from __future__ import absolute_import, division, print_function import collections import logging import math import os import random import warnings from dataclasses import asdict from multiprocessing import cpu_count import tempfile from pathlib import Path from collections i...
100,308
39.545271
227
py
simpletransformers
simpletransformers-master/simpletransformers/classification/multi_label_classification_model.py
import logging import os import random import warnings from multiprocessing import cpu_count import numpy as np import torch from transformers import ( WEIGHTS_NAME, AlbertConfig, AlbertTokenizer, BertConfig, BertTokenizer, BertweetTokenizer, BigBirdConfig, BigBirdTokenizer, Camembe...
12,934
31.176617
194
py
simpletransformers
simpletransformers-master/simpletransformers/classification/multi_modal_classification_model.py
#!/usr/bin/env python # coding: utf-8 from __future__ import absolute_import, division, print_function import json import logging import math import os import random import warnings from dataclasses import asdict from multiprocessing import cpu_count import numpy as np import pandas as pd import torch from scipy.st...
59,498
39.669173
194
py
simpletransformers
simpletransformers-master/simpletransformers/classification/transformer_models/longformer_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.longformer.modeling_longformer import ( LongformerModel, LongformerPreTrainedModel, LongformerClassificationHead, ) class LongformerForSequenceClassification(LongformerPreTrainedModel): def __ini...
2,719
35.756757
119
py
simpletransformers
simpletransformers-master/simpletransformers/classification/transformer_models/xlm_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.xlm.modeling_xlm import ( SequenceSummary, XLMModel, XLMPreTrainedModel, ) class XLMForSequenceClassification(XLMPreTrainedModel): r""" **labels**: (`optional`) ``torch.LongTensor`` of sh...
4,048
41.621053
134
py
simpletransformers
simpletransformers-master/simpletransformers/classification/transformer_models/mmbt_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.mmbt.modeling_mmbt import MMBTModel class MMBTForClassification(nn.Module): r""" **labels**: (`optional`) ``torch.LongTensor`` of shape ``(batch_size,)``: Labels for computing the sequenc...
4,267
43
134
py
simpletransformers
simpletransformers-master/simpletransformers/classification/transformer_models/bert_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.bert.modeling_bert import BertModel, BertPreTrainedModel class BertForSequenceClassification(BertPreTrainedModel): r""" **labels**: (`optional`) ``torch.LongTensor`` of shape ``(batch_size,)``: ...
4,068
44.211111
134
py
simpletransformers
simpletransformers-master/simpletransformers/classification/transformer_models/camembert_model.py
from transformers.models.camembert.configuration_camembert import CamembertConfig from transformers.models.camembert.modeling_camembert import ( CAMEMBERT_PRETRAINED_MODEL_ARCHIVE_LIST, ) from simpletransformers.classification.transformer_models.roberta_model import ( RobertaForSequenceClassification, ) clas...
2,562
63.075
134
py
simpletransformers
simpletransformers-master/simpletransformers/classification/transformer_models/electra_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.electra.modeling_electra import ( ElectraModel, ElectraPreTrainedModel, ElectraClassificationHead, ) class ElectraForSequenceClassification(ElectraPreTrainedModel): r""" **labels**: (`opt...
3,867
43.45977
134
py
simpletransformers
simpletransformers-master/simpletransformers/classification/transformer_models/xlnet_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.xlnet.modeling_xlnet import ( SequenceSummary, XLNetModel, XLNetPreTrainedModel, ) class XLNetForSequenceClassification(XLNetPreTrainedModel): r""" **labels**: (`optional`) ``torch.LongTe...
4,719
45.27451
134
py
simpletransformers
simpletransformers-master/simpletransformers/classification/transformer_models/albert_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.albert.modeling_albert import ( AlbertConfig, AlbertModel, AlbertPreTrainedModel, ) class AlbertForSequenceClassification(AlbertPreTrainedModel): """ **labels**: (`optional`) ``torch.Long...
4,122
43.333333
134
py
simpletransformers
simpletransformers-master/simpletransformers/classification/transformer_models/mobilebert_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.mobilebert.modeling_mobilebert import ( MobileBertModel, MobileBertPreTrainedModel, ) class MobileBertForSequenceClassification(MobileBertPreTrainedModel): def __init__(self, config, weight=None): ...
2,574
35.785714
119
py
simpletransformers
simpletransformers-master/simpletransformers/classification/transformer_models/distilbert_model.py
import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.distilbert.modeling_distilbert import ( DistilBertModel, DistilBertPreTrainedModel, ) class DistilBertForSequenceClassification(DistilBertPreTrainedModel): r""" **labels**: (`optional`) ``torch.LongTensor...
4,183
49.409639
134
py
simpletransformers
simpletransformers-master/simpletransformers/classification/transformer_models/roberta_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.roberta.modeling_roberta import ( ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST, RobertaClassificationHead, RobertaConfig, RobertaModel, ) from transformers import BertPreTrainedModel class RobertaForSe...
4,070
44.741573
134
py
simpletransformers
simpletransformers-master/simpletransformers/classification/transformer_models/flaubert_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.flaubert.modeling_flaubert import FlaubertModel from transformers.modeling_utils import SequenceSummary class FlaubertForSequenceClassification(FlaubertModel): r""" **labels**: (`optional`) ``torch.L...
4,097
43.543478
134
py
simpletransformers
simpletransformers-master/simpletransformers/classification/transformer_models/layoutlm_model.py
import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.bert.modeling_bert import BertPreTrainedModel from transformers.models.layoutlm.modeling_layoutlm import LayoutLMModel class LayoutLMForSequenceClassification(BertPreTrainedModel): def __init__(self, config, weight=None)...
2,066
31.296875
82
py
simpletransformers
simpletransformers-master/simpletransformers/config/model_args.py
import json import os import sys from dataclasses import asdict, dataclass, field, fields from multiprocessing import cpu_count import warnings from torch.utils.data import Dataset def get_default_process_count(): process_count = cpu_count() - 2 if cpu_count() > 2 else 1 if sys.platform == "win32": p...
14,235
31.208145
101
py
simpletransformers
simpletransformers-master/simpletransformers/question_answering/question_answering_utils.py
from __future__ import absolute_import, division, print_function import collections import json import linecache import logging import math import mmap import os import re import string from functools import partial from io import open from multiprocessing import Pool, cpu_count from pprint import pprint import torch...
80,779
35.387387
116
py
simpletransformers
simpletransformers-master/simpletransformers/question_answering/question_answering_model.py
from __future__ import absolute_import, division, print_function import json import logging import math import os import random import warnings from dataclasses import asdict from multiprocessing import cpu_count import numpy as np import pandas as pd import torch from scipy.stats import pearsonr from sklearn.metrics...
61,991
38.310082
178
py
simpletransformers
simpletransformers-master/simpletransformers/conv_ai/conv_ai_model.py
#!/usr/bin/env python # coding: utf-8 from __future__ import absolute_import, division, print_function import json import logging import math import os import random import statistics import warnings from collections import defaultdict from dataclasses import asdict from itertools import chain from multiprocessing i...
56,664
39.359687
194
py
simpletransformers
simpletransformers-master/simpletransformers/conv_ai/conv_ai_utils.py
# Copyright (c) 2019-present, HuggingFace Inc. # All rights reserved. This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. import json import logging import os import socket import tarfile import tempfile from datetime import datetime from multi...
3,756
31.669565
132
py
simpletransformers
simpletransformers-master/simpletransformers/language_generation/language_generation_model.py
import argparse import json import logging import os import random import numpy as np import torch from transformers import ( CTRLConfig, CTRLLMHeadModel, CTRLTokenizer, GPT2Config, GPT2LMHeadModel, GPT2Tokenizer, OpenAIGPTConfig, OpenAIGPTLMHeadModel, OpenAIGPTTokenizer, Transf...
9,026
34.53937
194
py
simpletransformers
simpletransformers-master/simpletransformers/language_representation/representation_model.py
#!/usr/bin/env python # coding: utf-8 from __future__ import absolute_import, division, print_function import logging import random import warnings from functools import partial import numpy as np import torch from tqdm.auto import tqdm from transformers import ( BertConfig, BertTokenizer, GPT2Config, ...
8,249
35.343612
214
py
simpletransformers
simpletransformers-master/simpletransformers/ner/ner_model.py
from __future__ import absolute_import, division, print_function import collections import logging import math import os import random import tempfile import warnings from dataclasses import asdict from pathlib import Path import numpy as np import pandas as pd import torch from seqeval.metrics import ( classifica...
84,423
39.336359
203
py
simpletransformers
simpletransformers-master/simpletransformers/ner/ner_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...
25,620
32.230869
109
py
simpletransformers
simpletransformers-master/simpletransformers/seq2seq/seq2seq_utils.py
import logging import os import pickle from multiprocessing import Pool from functools import partial from typing import Tuple import pandas as pd import torch import transformers from tokenizers.implementations import ByteLevelBPETokenizer from tokenizers.processors import BertProcessing from torch.utils.data import ...
18,719
32.608618
162
py
simpletransformers
simpletransformers-master/simpletransformers/seq2seq/seq2seq_model.py
import json import logging import math import os import random import warnings from dataclasses import asdict from multiprocessing import Pool, cpu_count from pathlib import Path import numpy as np import pandas as pd import torch import transformers from torch.utils.tensorboard import SummaryWriter from torch.nn.util...
73,835
42.204213
228
py
simpletransformers
simpletransformers-master/simpletransformers/t5/t5_model.py
import json import logging import math import os import random import warnings from dataclasses import asdict from multiprocessing import Pool, cpu_count from os import truncate from pathlib import Path import numpy as np import pandas as pd import torch from torch.utils.tensorboard import SummaryWriter from torch.nn....
50,919
39.965406
214
py
simpletransformers
simpletransformers-master/simpletransformers/t5/t5_utils.py
import logging import os import pickle from multiprocessing import Pool from os import truncate from typing import Tuple import pandas as pd import torch from tokenizers.implementations import ByteLevelBPETokenizer from tokenizers.processors import BertProcessing from torch.utils.data import Dataset from tqdm.auto imp...
6,664
32.325
100
py
simpletransformers
simpletransformers-master/simpletransformers/streamlit/simple_view.py
import os import json import logging import streamlit as st from torch.cuda import is_available from simpletransformers.classification import ( ClassificationModel, MultiLabelClassificationModel, ) from simpletransformers.ner import NERModel from simpletransformers.question_answering import QuestionAnsweringM...
7,743
30.100402
142
py
simpletransformers
simpletransformers-master/simpletransformers/retrieval/retrieval_model.py
import json import logging import math import os import random import warnings import string from dataclasses import asdict from multiprocessing import Pool, cpu_count from pathlib import Path import numpy as np import pandas as pd import torch import transformers from tensorboardX import SummaryWriter from torch.nn.u...
75,034
39.75774
288
py
simpletransformers
simpletransformers-master/simpletransformers/retrieval/retrieval_utils.py
import logging import os import pickle from multiprocessing import Pool from functools import partial from simpletransformers.seq2seq.seq2seq_utils import add_faiss_index_to_dataset from datasets.load import load_from_disk import torch import transformers import numpy as np from torch.utils.data import Dataset from t...
26,391
38.27381
114
py
simpletransformers
simpletransformers-master/simpletransformers/experimental/classification/classification_model.py
#!/usr/bin/env python # coding: utf-8 from __future__ import absolute_import, division, print_function import json import math import os import random import warnings from multiprocessing import cpu_count import numpy as np import torch from scipy.stats import pearsonr from sklearn.metrics import ( confusion_ma...
36,129
36.518172
196
py
simpletransformers
simpletransformers-master/simpletransformers/experimental/classification/multi_label_classification_model.py
from multiprocessing import cpu_count import torch from transformers import ( WEIGHTS_NAME, AlbertConfig, AlbertTokenizer, BertConfig, BertTokenizer, DistilBertConfig, DistilBertTokenizer, RobertaConfig, RobertaTokenizer, XLMConfig, XLMTokenizer, XLNetConfig, XLNetTo...
6,733
32.336634
186
py
simpletransformers
simpletransformers-master/simpletransformers/experimental/classification/transformer_models/xlm_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.xlm.modeling_xlm import ( SequenceSummary, XLMModel, XLMPreTrainedModel, ) class XLMForSequenceClassification(XLMPreTrainedModel): r""" **labels**: (`optional`) ``torch.LongTensor`` of sh...
3,870
41.538462
134
py
simpletransformers
simpletransformers-master/simpletransformers/experimental/classification/transformer_models/bert_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.bert.modeling_bert import BertModel, BertPreTrainedModel class BertForSequenceClassification(BertPreTrainedModel): r""" **labels**: (`optional`) ``torch.LongTensor`` of shape ``(batch_size,)``: ...
4,830
44.149533
134
py
simpletransformers
simpletransformers-master/simpletransformers/experimental/classification/transformer_models/camembert_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.camembert.modeling_camembert import ( CAMEMBERT_PRETRAINED_MODEL_ARCHIVE_LIST, CamembertConfig, CamembertModel, ) from transformers.models.roberta.modeling_roberta import ( RobertaClassificationHea...
4,851
45.209524
134
py
simpletransformers
simpletransformers-master/simpletransformers/experimental/classification/transformer_models/xlnet_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.xlnet.modeling_xlnet import ( SequenceSummary, XLNetModel, XLNetPreTrainedModel, ) class XLNetForSequenceClassification(XLNetPreTrainedModel): r""" **labels**: (`optional`) ``torch.LongTe...
5,607
45.347107
134
py
simpletransformers
simpletransformers-master/simpletransformers/experimental/classification/transformer_models/albert_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.albert.modeling_albert import ( AlbertConfig, AlbertModel, AlbertPreTrainedModel, ) class AlbertForSequenceClassification(AlbertPreTrainedModel): """ **labels**: (`optional`) ``torch.Long...
4,880
42.972973
134
py
simpletransformers
simpletransformers-master/simpletransformers/experimental/classification/transformer_models/distilbert_model.py
import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.distilbert.modeling_distilbert import ( DistilBertModel, DistilBertPreTrainedModel, ) class DistilBertForSequenceClassification(DistilBertPreTrainedModel): r""" **labels**: (`optional`) ``torch.LongTensor...
3,980
50.038462
134
py
simpletransformers
simpletransformers-master/simpletransformers/experimental/classification/transformer_models/roberta_model.py
import torch import torch.nn as nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.bert.modeling_bert import BertPreTrainedModel from transformers.models.roberta.modeling_roberta import ( ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST, RobertaClassificationHead, RobertaConfig, RobertaMode...
4,891
45.150943
134
py
simpletransformers
simpletransformers-master/simpletransformers/losses/dice_loss.py
from typing import Optional import torch import torch.nn as nn import torch.nn.functional as F from typing import Optional # based on: # https://github.com/kevinzakka/pytorch-goodies/blob/master/losses.py # adapted from: # https://kornia.readthedocs.io/en/v0.1.2/_modules/torchgeometry/losses/dice.html class DiceLos...
3,911
30.804878
101
py
simpletransformers
simpletransformers-master/simpletransformers/losses/loss_utils.py
import torch import warnings from torch.nn import CrossEntropyLoss from simpletransformers.losses import FocalLoss, DiceLoss, TverskyLoss def init_loss(weight, device, args): if weight and args.loss_type: warnings.warn( f"weight and args.loss_type parametters are set at the same time" ...
957
33.214286
95
py
simpletransformers
simpletransformers-master/simpletransformers/losses/tversky_loss.py
from typing import Optional import torch import torch.nn as nn import torch.nn.functional as F # based on: # https://github.com/kevinzakka/pytorch-goodies/blob/master/losses.py # adapted from: # https://kornia.readthedocs.io/en/v0.1.2/_modules/torchgeometry/losses/tversky.html class TverskyLoss(nn.Module): r"""...
4,342
31.901515
101
py
simpletransformers
simpletransformers-master/simpletransformers/losses/focal_loss.py
from typing import Optional, Union from numbers import Real import warnings import torch import torch.nn as nn import torch.nn.functional as F try: from collections import Iterable except ImportError: from collections.abc import Iterable # based on: # https://github.com/zhezh/focalloss/blob/master/focalloss.p...
5,748
38.108844
115
py
simpletransformers
simpletransformers-master/simpletransformers/custom_models/models.py
import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from transformers import ( BertModel, BertPreTrainedModel, DistilBertModel, ElectraForMaskedLM, ElectraForPreTraining, FlaubertModel, LayoutLMModel, LayoutLMPreTrainedModel, Longformer...
35,433
32.302632
134
py
torch-mlir
torch-mlir-main/setup.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # Script for generating the torch-mlir wheel. # ``` # $ python s...
7,228
41.523529
130
py
torch-mlir
torch-mlir-main/examples/torchscript_resnet18.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. import sys from PIL import Image import requests import torch ...
2,580
32.960526
131
py
torch-mlir
torch-mlir-main/examples/ltc_backend_bert.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. """ Runs a training of the Bert model using the Lazy Tensor Core ...
5,217
31.409938
103
py
torch-mlir
torch-mlir-main/examples/ltc_backend_mnist.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. """ Example use of the example Torch MLIR LTC backend. """ import...
2,793
25.358491
97
py
torch-mlir
torch-mlir-main/examples/torchdynamo_resnet18.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. import sys from typing import List from PIL import Image import...
3,340
34.168421
131
py
torch-mlir
torch-mlir-main/examples/torchscript_resnet18_all_output_types.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. import torch import torchvision import torch_mlir resnet18 = t...
936
43.619048
98
py
torch-mlir
torch-mlir-main/examples/torchscript_stablehlo_backend_resnet.py
import torch import torchvision.models as models import torch_mlir model = models.resnet18(pretrained=True) model.eval() data = torch.randn(2,3,200,200) out_stablehlo_mlir_path = "./resnet18_stablehlo.mlir" module = torch_mlir.compile(model, data, output_type=torch_mlir.OutputType.STABLEHLO, use_tracing=False) with o...
497
32.2
104
py
torch-mlir
torch-mlir-main/examples/torchscript_stablehlo_backend_tinybert.py
import torch import torch_mlir from transformers import BertForMaskedLM # Wrap the bert model to avoid multiple returns problem class BertTinyWrapper(torch.nn.Module): def __init__(self) -> None: super().__init__() self.bert = BertForMaskedLM.from_pretrained("prajjwal1/bert-tiny", return_dict=Fals...
813
31.56
103
py
torch-mlir
torch-mlir-main/python/torch_mlir/_dynamo_fx_importer.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. import pdb # This file implements a pure-Python importer from a r...
17,781
39.139955
120
py
torch-mlir
torch-mlir-main/python/torch_mlir/_version.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. from packaging import version import torch def torch_version_fo...
445
36.166667
79
py
torch-mlir
torch-mlir-main/python/torch_mlir/compiler_utils.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. from io import StringIO import os import sys import tempfile fr...
3,017
37.692308
83
py
torch-mlir
torch-mlir-main/python/torch_mlir/dynamo.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. from typing import List from ._version import torch_version_for_...
6,549
41.810458
98
py
torch-mlir
torch-mlir-main/python/torch_mlir/__init__.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. from typing import Optional, Sequence, Union, List, Dict, Tuple,...
19,553
41.694323
115
py
torch-mlir
torch-mlir-main/python/torch_mlir/dialects/torch/__init__.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. from .._torch_ops_gen import * from ..._mlir_libs._torchMlir imp...
341
41.75
79
py
torch-mlir
torch-mlir-main/python/torch_mlir/dialects/torch/importer/jit_ir/torchscript_annotations.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. from typing import List, Optional, Tuple import torch import t...
2,546
42.913793
80
py
torch-mlir
torch-mlir-main/python/torch_mlir/dialects/torch/importer/jit_ir/__init__.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # This is a trampoline module which loads the _torch_mlir native...
695
30.636364
79
py
torch-mlir
torch-mlir-main/python/torch_mlir/dialects/torch/importer/jit_ir/build_tools/registry.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. """Access to the Torch JIT operator registry.""" from typing im...
18,295
42.561905
102
py
torch-mlir
torch-mlir-main/python/torch_mlir/dialects/torch/importer/jit_ir/build_tools/torch_ods_gen.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. """Queries the pytorch op registry and generates ODS and CC sourc...
41,406
52.359536
215
py
torch-mlir
torch-mlir-main/python/torch_mlir/dialects/torch/importer/jit_ir/build_tools/library_generator.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. import inspect import re from typing import List, Optional, Unio...
10,740
43.020492
150
py
torch-mlir
torch-mlir-main/python/torch_mlir/dialects/torch/importer/jit_ir/build_tools/abstract_interp_lib_gen.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. from typing import List, Optional, Any, Tuple, Union import argp...
189,544
55.111604
363
py
torch-mlir
torch-mlir-main/python/torch_mlir/dialects/torch/importer/jit_ir/build_tools/testing_framework.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. from typing import Any, List, Iterable, Optional, Callable impo...
14,385
46.79402
189
py
torch-mlir
torch-mlir-main/python/torch_mlir/_torch_mlir_custom_op_example/__init__.py
import os import torch # Register _torch_mlir_custom_op_example.identity as a side-effect of importing. current_dir = os.path.dirname(os.path.abspath(__file__)) lib = os.path.join(*[current_dir, 'libtorch_mlir_custom_op_example.so']) torch.ops.load_library(lib)
264
28.444444
80
py
torch-mlir
torch-mlir-main/python/test/lit.cfg.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. import os import platform import re import subprocess import tem...
2,965
34.309524
101
py
torch-mlir
torch-mlir-main/python/test/annotations-sugar.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import torch from torch_mlir_...
1,632
29.811321
97
py
torch-mlir
torch-mlir-main/python/test/debug/lockstep_basic.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s from typing import List impor...
1,697
33.653061
128
py
torch-mlir
torch-mlir-main/python/test/lazy_backend/device_data_name.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import torch import torch._la...
1,018
21.644444
79
py
torch-mlir
torch-mlir-main/python/test/dynamo_fx_importer/basic.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s from typing import List impor...
5,337
44.623932
258
py
torch-mlir
torch-mlir-main/python/test/compile_api/already_scripted.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import torch import torch_mlir...
1,012
30.65625
154
py
torch-mlir
torch-mlir-main/python/test/compile_api/already_traced.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import torch import torch_mlir...
1,004
33.655172
154
py
torch-mlir
torch-mlir-main/python/test/compile_api/tracing.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import torch import torch_mli...
2,586
34.438356
170
py
torch-mlir
torch-mlir-main/python/test/compile_api/backend_legal_ops.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import torch import torch_mli...
730
29.458333
79
py
torch-mlir
torch-mlir-main/python/test/compile_api/make_fx.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import functorch import torch ...
684
30.136364
116
py
torch-mlir
torch-mlir-main/python/test/compile_api/multiple_methods.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import torch import torch_mlir...
1,486
34.404762
79
py
torch-mlir
torch-mlir-main/python/test/compile_api/basic.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import torch import torch_mli...
2,342
38.711864
123
py
torch-mlir
torch-mlir-main/python/test/compile_api/output_type_spec.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import torch import torch_mli...
923
34.538462
100
py
torch-mlir
torch-mlir-main/python/test/torchscript_e2e_test/error_reports.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s from typing import List, Tuple...
5,850
35.117284
211
py
torch-mlir
torch-mlir-main/python/test/torchscript_e2e_test/submodule.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import torch from torch_mlir_...
1,366
27.479167
81
py
torch-mlir
torch-mlir-main/python/test/torchscript_e2e_test/non_tensor_values.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s from typing import List, Tuple...
1,537
26.464286
81
py
torch-mlir
torch-mlir-main/python/test/torchscript_e2e_test/compilation_failure.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import torch from torch_mlir_...
1,516
30.604167
81
py
torch-mlir
torch-mlir-main/python/test/torchscript_e2e_test/basic.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import torch from torch_mlir_...
1,307
28.066667
81
py
torch-mlir
torch-mlir-main/python/test/torchscript_e2e_test/runtime_failure.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. # RUN: %PYTHON %s | FileCheck %s import torch from torch_mlir_...
1,383
30.454545
81
py
torch-mlir
torch-mlir-main/python/torch_mlir_e2e_test/annotations.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. from typing import List, Optional, Tuple, NamedTuple import tor...
2,997
41.225352
80
py
torch-mlir
torch-mlir-main/python/torch_mlir_e2e_test/reporting.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. """ Utilities for reporting the results of the test framework. ""...
13,202
38.06213
133
py
torch-mlir
torch-mlir-main/python/torch_mlir_e2e_test/registry.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. from typing import Callable import torch from .framework impor...
1,501
35.634146
142
py
torch-mlir
torch-mlir-main/python/torch_mlir_e2e_test/utils.py
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Also available under a BSD-style license. See LICENSE. from torch_mlir import TensorPlaceholder from torch_mlir_e2e_tes...
1,017
43.26087
80
py