python_code
stringlengths
0
229k
import torch import torchaudio from torch.utils.mobile_optimizer import optimize_for_mobile def get_demo_wrapper(): wrapper = torch.jit.load("scripted_wrapper_tuple.pt") return wrapper wrapper = get_demo_wrapper() scripted_model = torch.jit.script(wrapper) optimized_model = optimize_for_mobile(scripted_model)...
import pyaudio import queue import numpy as np import torch import torchaudio def get_demo_wrapper(): wrapper = torch.jit.load("scripted_wrapper_tuple.pt") return wrapper wrapper = get_demo_wrapper() ################################################################ data_queue = queue.Queue() def callba...
import torch import torchvision from torch.backends._coreml.preprocess import ( CompileSpec, TensorSpec, CoreMLComputeUnit, ) def mobilenetv2_spec(): return { "forward": CompileSpec( inputs=( TensorSpec( shape=[1, 3, 224, 224], ),...
import torch from torch.utils.mobile_optimizer import optimize_for_mobile model = torch.hub.load('pytorch/vision:v0.11.0', 'deeplabv3_resnet50', pretrained=True) model.eval() scripted_module = torch.jit.script(model) optimized_model = optimize_for_mobile(scripted_module) optimized_model.save("ImageSegmentation/deepla...
import torch from torch import Tensor from torch.utils.mobile_optimizer import optimize_for_mobile import torchaudio from torchaudio.models.wav2vec2.utils.import_huggingface import import_huggingface_model from transformers import Wav2Vec2ForCTC # Wav2vec2 model emits sequences of probability (logits) distributions ov...
import torch from pytorchvideo.accelerator.deployment.mobile_cpu.utils.model_conversion import ( convert_to_deployable_form, ) from pytorchvideo.models.accelerator.mobile_cpu.efficient_x3d import EfficientX3d from torch.hub import load_state_dict_from_url from torch.utils.mobile_optimizer import ( optimize_for_...
import torch from transformers import DistilBertTokenizer, DistilBertForQuestionAnswering from torch.utils.mobile_optimizer import optimize_for_mobile tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased-distilled-squad') model = DistilBertForQuestionAnswering.from_pretrained('distilbert-base-uncas...
# based on https://pytorch.org/tutorials/intermediate/seq2seq_translation_tutorial.html from __future__ import unicode_literals, print_function, division from io import open import unicodedata import string import re import random import torch import torch.nn as nn from torch import optim import torch.nn.functional a...
import torch from torch.utils.mobile_optimizer import optimize_for_mobile model = torch.hub.load('facebookresearch/deit:main', 'deit_base_patch16_224', pretrained=True) quantized_model = torch.quantization.quantize_dynamic(model, qconfig_spec={torch.nn.Linear}, dtype=torch.qint8) ts_model = torch.jit.script(quantized_...
import torch import torch.nn.functional as F from torch import nn from einops import rearrange class Residual(nn.Module): def __init__(self, fn): super().__init__() self.fn = fn def forward(self, x, **kwargs): return self.fn(x, **kwargs) + x class PreNorm(nn.Module): def __init__...
import torch import torchvision import time from vit_pytorch import * from torch.utils.mobile_optimizer import optimize_for_mobile torch.manual_seed(42) DOWNLOAD_PATH = 'data/mnist' BATCH_SIZE_TRAIN = 100 BATCH_SIZE_TEST = 1000 # 0.1307 and 0.3081 are the mean and std computed on the MNIST training set transform_mn...
#!/usr/bin/env python3 import contextlib import copy import os import unittest from PIL import Image import torch from torch.utils.mobile_optimizer import optimize_for_mobile from d2go.export.api import convert_and_export_predictor from d2go.export.d2_meta_arch import patch_d2_meta_arch from d2go.runner import creat...
import torch import torchvision from torch.utils.mobile_optimizer import optimize_for_mobile model = torchvision.models.quantization.mobilenet_v2(pretrained=True, quantize=True) model.eval() example = torch.rand(1, 3, 224, 224) traced_script_module = torch.jit.trace(model, example) torchscript_model_optimized = optimi...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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.
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os from pathlib import Path from typing import Dict, List, Optional, Set import torch.utils.data.datapi...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. # Scrip can be used with # find -name '*.py' | grep -v third_party | perl -ne'print "python tools/todo.py $_"' ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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.
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 distutils.sysconfig import os import platform import subprocess import sys from pathlib import Path fro...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 io import os import unittest import expecttest from torchdata.datapipes.iter import GDriveReader, Iter...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 unittest from unittest.mock import MagicMock, patch import expecttest from torch.testing._internal.comm...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os import unittest import warnings import expecttest from _utils._common_utils_for_test import create_...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 unittest from unittest.mock import patch import expecttest from torchdata.datapipes.iter import Huggin...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 random import string import tempfile import unittest from torchdata.datapipes.iter import AISFileLister...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 unittest from torchdata.dataloader2.linter import _check_shuffle_before_sharding from torchdata.datap...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 unittest from torchdata.dataloader2.random import SeedGenerator from torchdata.dataloader2.random._phil...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 asyncio import io import itertools import pickle import unittest import warnings from collections impor...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. from unittest import TestCase from torchdata.dataloader2 import DataLoader2 from torchdata.dataloader2.adapter...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 unittest import torch.multiprocessing as mp from torch.testing._internal.common_utils import slowTest ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 bz2 import functools import hashlib import io import itertools import lzma import os import subprocess i...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os import sys import tempfile import unittest import torch.multiprocessing as mp from torch.testing._i...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 unittest import expecttest from torchdata.datapipes.iter import MapToIterConverter from torchdata.datap...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os import queue import random import socket import sys import unittest from functools import partial f...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os import pickle import unittest import warnings from functools import partial from io import StringIO f...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 types import unittest from typing import Dict, Iterator, List, Tuple, TypeVar import expecttest from ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os import unittest import warnings from functools import partial import expecttest import torch from ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 io import json import os import subprocess import unittest import warnings from unittest.mock import pat...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os import unittest import warnings from itertools import chain import expecttest from _utils._common_ut...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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.
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 hashlib import os import platform import sys import tempfile from typing import List, Tuple, TypeVar fr...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os import tarfile NUMBER_OF_FILES = 3 FILES = [ ("bytes", "bt", "{fn}_0123456789abcdef\n", True), ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 argparse import torchdata import torchdata.dataloader2 import torchdata.datapipes def s3_test(): ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 argparse import torch import torch.distributed as dist from torch.distributed.elastic.multiprocessing...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 multiprocessing as mp import os import pickle import queue import random import socket import unittest ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 multiprocessing as mp import unittest from unittest import TestCase from torch.testing._internal.common...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 random import unittest from unittest import TestCase import numpy as np import torch from torch.tes...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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.
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. """ This file contains the data pipeline to read from a TSV file and output a DataFrame. """ from typing impor...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. # TODO(597): This file can be moved to the dataframe parent directory once Torcharrow # is open sourc...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. """ This file contains the data pipeline to read from a Paruet and output a DataFrame. """ import torcharrow.d...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. from typing import Callable, List, TypeVar T = TypeVar("T") # Criteo Data Set Parameters INT_FEATURE_COUNT = ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. """ This file pre-process the source file and save it as a TSV file and a Parquet file. You do not need to re-r...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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.
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 http.server import os import re import threading import torchvision.datasets as datasets import torchvi...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. from io import BytesIO import requests from torchdata.dataloader2 import DataLoader2, MultiProcessingReadingSe...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os.path import re import torch from torch.utils.data.datapipes.utils.decoder import imagehandler, matha...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os.path from torch.utils.data.datapipes.utils.decoder import imagehandler from torchdata.datapipes.ite...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 functools import os from pathlib import Path from typing import Union import torchaudio from torchdat...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os from functools import partial from torchdata.datapipes.iter import FileOpener, HttpReader, IterableW...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os from functools import partial from pathlib import Path from torchdata.datapipes.iter import FileOpen...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. # The following utility functions are copied from torchtext # https://github.com/pytorch/text/blob/main/torchte...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os from functools import partial from torchdata.datapipes.iter import FileOpener, GDriveReader, Iterabl...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os from functools import partial from torchdata.datapipes.iter import FileOpener, HttpReader, IterableW...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. from torchdata.datapipes.iter import HttpReader from .utils import _add_docstring_header, _create_dataset_dire...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 torch import torch.nn as nn import torchtext import torchtext.functional as F import torchtext.transfor...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 torch from torchdata.dataloader2 import DataLoader2 from torchdata.datapipes.iter import IterableWrappe...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os import torch import torch.distributed as dist from torch import nn from torchdata.dataloader2 impo...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 torch from torchdata.dataloader2 import DataLoader2, MultiProcessingReadingService from torchdata.data...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 argparse import hashlib import os import time from functools import partial from typing import Callable...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 torch from torchvision.transforms import transforms class ClassificationPresetTrain: def __init__(...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 datetime import errno import os import time from collections import defaultdict, deque import torch imp...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 datetime import os import time import warnings import helpers import presets import torch import torch....
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 itertools import os import random from functools import partial from pathlib import Path import torch i...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. # This file is adpated from PyTorch Core # https://github.com/pytorch/pytorch/blob/master/scripts/release_notes...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. # This file is adpated from PyTorch Core # https://github.com/pytorch/pytorch/blob/master/scripts/release_notes...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 os import sys def collect_init_dps(init_file_location): init_dps = set() with open(init_file_l...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. # Use the same timeout as PyTorch Distributed default_timeout_in_s = 30 * 60 default_dl2_worker_join_timeout_i...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. from torchdata import _extension # noqa: F401 from . import datapipes janitor = datapipes.utils.janitor try...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 importlib.machinery import os from pathlib import Path _LIB_DIR = Path(__file__).parent def _init_ex...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 sys import traceback class KeyErrorMessage(str): r"""str subclass that returns itself in repr""" ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 pickle import warnings from typing import Any, Dict, Generic, Iterable, Iterator, Optional, TypeVar, Un...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. class PauseIteration(StopIteration): pass
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. from abc import abstractmethod import torch from torchdata.dataloader2.graph import DataPipe, traverse_dps fr...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 abc class ShuffleSpec(abc.ABC): """Defines a shuffle specification."""
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. from torchdata.dataloader2.dataloader2 import DataLoader2, DataLoader2Iterator from torchdata.dataloader2.erro...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. from torchdata.dataloader2.graph import DataPipe, DataPipeGraph, traverse_dps from torchdata.datapipes.iter im...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 multiprocessing as py_mp import pickle import warnings from abc import ABC, abstractmethod from datetim...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 pickle from torch.utils.data.datapipes.datapipe import ( _DataPipeSerializationWrapper, _IterD...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. from torch.utils.data.graph import DataPipe, DataPipeGraph, traverse_dps from torchdata.dataloader2.graph.sett...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. from collections import deque from typing import Deque, Dict, List, Optional, Set, Type, Union from torchdata...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 inspect from typing import List from torchdata.dataloader2.graph.utils import DataPipe, find_dps, list...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 random from dataclasses import dataclass from multiprocessing.queues import Queue from typing import Ca...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. # from multiprocessing.queues import Queue from typing import Dict, List, Optional, Set from torchdata.datalo...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. from torchdata.dataloader2.utils.worker import process_init_fn, process_reset_fn, WorkerInfo __all__ = [ ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 threading import time class LocalQueue: ops = 0 stored = 0 uid = 0 empty = 0 def ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 time import types import warnings from collections import deque from itertools import cycle from typing...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. from queue import Empty as EmptyException from torchdata.dataloader2 import communication class Protocol: ...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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. from . import eventloop, iter, map, messages, protocol, queue
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 time from itertools import zip_longest from typing import Dict, List import torch from torch.utils.da...
# Copyright (c) Meta Platforms, Inc. and affiliates. # 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 time import types from torch.utils.data import MapDataPipe from torchdata._utils import ExceptionWrappe...