id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
9,062
import logging from collections import defaultdict from typing import Any, cast, Dict, List, Optional, Tuple, Union from torch import nn from torchrec.distributed.planner.constants import BIGINT_DTYPE, NUM_POOLINGS from torchrec.distributed.planner.shard_estimators import _calculate_shard_io_sizes from torchrec.distrib...
null
9,063
import logging from collections import defaultdict from typing import Any, cast, Dict, List, Optional, Tuple, Union from torch import nn from torchrec.distributed.planner.constants import BIGINT_DTYPE, NUM_POOLINGS from torchrec.distributed.planner.shard_estimators import _calculate_shard_io_sizes from torchrec.distrib...
null
9,064
import logging from collections import defaultdict from typing import Any, cast, Dict, List, Optional, Tuple, Union from torch import nn from torchrec.distributed.planner.constants import BIGINT_DTYPE, NUM_POOLINGS from torchrec.distributed.planner.shard_estimators import _calculate_shard_io_sizes from torchrec.distrib...
null
9,065
import logging from collections import defaultdict from typing import Any, cast, Dict, List, Optional, Tuple, Union from torch import nn from torchrec.distributed.planner.constants import BIGINT_DTYPE, NUM_POOLINGS from torchrec.distributed.planner.shard_estimators import _calculate_shard_io_sizes from torchrec.distrib...
null
9,066
import logging import math from typing import cast, Dict, List, Optional, Tuple, Type import torch import torchrec.optim as trec_optim from torch import nn from torchrec.distributed.embedding_types import EmbeddingComputeKernel from torchrec.distributed.planner.constants import ( BATCHED_COPY_PERF_FACTOR, BIGIN...
null
9,067
import logging import math from typing import cast, Dict, List, Optional, Tuple, Type import torch import torchrec.optim as trec_optim from torch import nn from torchrec.distributed.embedding_types import EmbeddingComputeKernel from torchrec.distributed.planner.constants import ( BATCHED_COPY_PERF_FACTOR, BIGIN...
Calculates estimated storage sizes for each sharded tensor, comprised of input, output, tensor, gradient, and optimizer sizes. Args: sharder (ModuleSharder[nn.Module]): sharder for module that supports sharding. sharding_type (str): provided ShardingType value. tensor (torch.Tensor): tensor to be sharded. compute_devic...
9,068
import logging from typing import Dict, List, Optional, Tuple, Union from torch import nn from torchrec.distributed.embedding_types import EmbeddingComputeKernel from torchrec.distributed.planner.constants import POOLING_FACTOR from torchrec.distributed.planner.shard_estimators import ( EmbeddingPerfEstimator, ...
null
9,069
import logging from typing import Dict, List, Optional, Tuple, Union from torch import nn from torchrec.distributed.embedding_types import EmbeddingComputeKernel from torchrec.distributed.planner.constants import POOLING_FACTOR from torchrec.distributed.planner.shard_estimators import ( EmbeddingPerfEstimator, ...
Gets corresponding partition by type for provided sharding type. Args: sharding_type (str): sharding type string. Returns: str: the corresponding `PartitionByType` value.
9,070
import logging from typing import Dict, List, Optional, Tuple, Union from torch import nn from torchrec.distributed.embedding_types import EmbeddingComputeKernel from torchrec.distributed.planner.constants import POOLING_FACTOR from torchrec.distributed.planner.shard_estimators import ( EmbeddingPerfEstimator, ...
null
9,071
from typing import Optional from torchrec.distributed.embedding_types import EmbeddingComputeKernel UVM_CACHING_RATIO: float = 0.2 class EmbeddingComputeKernel(Enum): DENSE = "dense" FUSED = "fused" FUSED_UVM = "fused_uvm" FUSED_UVM_CACHING = "fused_uvm_caching" QUANT = "quant" QUANT_UVM = "qua...
Calculates the device bandwidth based on given compute device, compute kernel, and caching ratio. Args: compute_kernel (str): compute kernel. compute_device (str): compute device. hbm_mem_bw (float): the bandwidth of the device HBM. ddr_mem_bw (float): the bandwidth of the system DDR memory. caching_ratio (Optional[flo...
9,072
import copy import heapq import logging from dataclasses import dataclass from enum import Enum from typing import cast, Dict, List, Optional from torchrec.distributed.planner.perf_models import NoopPerfModel from torchrec.distributed.planner.types import ( DeviceHardware, PartitionByType, Partitioner, ...
null
9,073
import copy import heapq import logging from dataclasses import dataclass from enum import Enum from typing import cast, Dict, List, Optional from torchrec.distributed.planner.perf_models import NoopPerfModel from torchrec.distributed.planner.types import ( DeviceHardware, PartitionByType, Partitioner, ...
null
9,074
import copy import heapq import logging from dataclasses import dataclass from enum import Enum from typing import cast, Dict, List, Optional from torchrec.distributed.planner.perf_models import NoopPerfModel from torchrec.distributed.planner.types import ( DeviceHardware, PartitionByType, Partitioner, ...
null
9,075
import copy import heapq import logging from dataclasses import dataclass from enum import Enum from typing import cast, Dict, List, Optional from torchrec.distributed.planner.perf_models import NoopPerfModel from torchrec.distributed.planner.types import ( DeviceHardware, PartitionByType, Partitioner, ...
null
9,076
import abc from dataclasses import dataclass from enum import Enum, unique from typing import Any, Dict, Generic, Iterator, List, Optional, TypeVar import torch from fbgemm_gpu.split_table_batched_embeddings_ops_training import EmbeddingLocation from torch import fx, nn from torch.nn.modules.module import _addindent fr...
null
9,077
import abc import logging from collections import defaultdict, OrderedDict from typing import Any, Dict, List, Optional, Tuple, Union import torch import torch.distributed as dist from torch import nn from torchrec.distributed.embedding_types import ( EmbeddingComputeKernel, GroupedEmbeddingConfig, ShardedE...
It is possible for there to be multiple shards from a table on a single rank. We accumulate them in key_to_local_shards. Repeat shards should have identical global ShardedTensorMetadata.
9,078
import copy import logging from typing import Any, Dict, Iterator, List, Optional, Tuple import torch import torch.distributed as dist from fbgemm_gpu.split_embedding_configs import SparseType from fbgemm_gpu.split_table_batched_embeddings_ops_inference import ( EmbeddingLocation, IntNBitTableBatchedEmbeddingBa...
null
9,079
import copy import logging from typing import Any, Dict, Iterator, List, Optional, Tuple import torch import torch.distributed as dist from fbgemm_gpu.split_embedding_configs import SparseType from fbgemm_gpu.split_table_batched_embeddings_ops_inference import ( EmbeddingLocation, IntNBitTableBatchedEmbeddingBa...
null
9,080
import copy import logging from typing import Any, Dict, Iterator, List, Optional, Tuple import torch import torch.distributed as dist from fbgemm_gpu.split_embedding_configs import SparseType from fbgemm_gpu.split_table_batched_embeddings_ops_inference import ( EmbeddingLocation, IntNBitTableBatchedEmbeddingBa...
null
9,081
import argparse import copy import logging import os import time from functools import partial from typing import List, Optional, Tuple import torch from torchrec.distributed.benchmark.benchmark_utils import ( benchmark_module, BenchmarkResult, CompileMode, DLRM_NUM_EMBEDDINGS_PER_FEATURE, EMBEDDING...
null
9,082
import argparse import copy import logging import os import time from functools import partial from typing import List, Optional, Tuple import torch from torchrec.distributed.benchmark.benchmark_utils import ( benchmark_module, BenchmarkResult, CompileMode, DLRM_NUM_EMBEDDINGS_PER_FEATURE, EMBEDDING...
null
9,083
import argparse import contextlib import copy import gc import logging import os from dataclasses import dataclass from enum import Enum from typing import ( Any, Callable, ContextManager, Dict, List, Optional, Tuple, TypeVar, Union, ) import torch from torch import multiprocessing a...
null
9,084
import argparse import contextlib import copy import gc import logging import os from dataclasses import dataclass from enum import Enum from typing import ( Any, Callable, ContextManager, Dict, List, Optional, Tuple, TypeVar, Union, ) import torch from torch import multiprocessing a...
null
9,085
import argparse import logging import os import time from functools import partial from typing import List, Tuple import torch from torchrec.distributed.benchmark.benchmark_utils import ( benchmark_module, BenchmarkResult, CompileMode, DLRM_NUM_EMBEDDINGS_PER_FEATURE, EMBEDDING_DIM, get_tables, ...
null
9,086
import argparse import logging import os import time from functools import partial from typing import List, Tuple import torch from torchrec.distributed.benchmark.benchmark_utils import ( benchmark_module, BenchmarkResult, CompileMode, DLRM_NUM_EMBEDDINGS_PER_FEATURE, EMBEDDING_DIM, get_tables, ...
null
9,087
import argparse import logging import os import time from functools import partial from typing import List, Tuple import torch from torchrec.distributed.benchmark.benchmark_utils import ( benchmark_module, BenchmarkResult, CompileMode, DLRM_NUM_EMBEDDINGS_PER_FEATURE, EMBEDDING_DIM, get_tables, ...
null
9,088
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, TypeVar import torch import torch.distributed as dist from fbgemm_gpu.permute_pooled_embedding_modules_split import ( PermutePooledEmbeddingsSplit, ) from torchrec.distributed.dist_data import EmbeddingsAllToOne from torchrec.distributed.embedding...
null
9,089
import math from typing import Any, cast, Dict, List, Optional, Tuple, TypeVar, Union import torch import torch.distributed as dist from torchrec.distributed.dist_data import ( EmbeddingsAllToOneReduce, KJTAllToAll, KJTOneToAll, PooledEmbeddingsReduceScatter, VariableBatchPooledEmbeddingsReduceScatt...
null
9,090
import math from typing import Any, cast, Dict, List, Optional, Tuple, TypeVar, Union import torch import torch.distributed as dist from torchrec.distributed.dist_data import ( EmbeddingsAllToOneReduce, KJTAllToAll, KJTOneToAll, PooledEmbeddingsReduceScatter, VariableBatchPooledEmbeddingsReduceScatt...
null
9,091
import math from typing import Any, cast, Dict, List, Optional, Tuple, TypeVar, Union import torch import torch.distributed as dist from torchrec.distributed.dist_data import ( EmbeddingsAllToOneReduce, KJTAllToAll, KJTOneToAll, PooledEmbeddingsReduceScatter, VariableBatchPooledEmbeddingsReduceScatt...
null
9,092
from collections import OrderedDict from dataclasses import dataclass, field from typing import Any, cast, Dict, Iterator, List, Optional, Set, Tuple, Type, TypeVar import torch import torch.distributed as dist from torch import nn from torch.nn.parallel import DistributedDataParallel from torchrec.distributed.comm imp...
null
9,093
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,094
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,095
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,096
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,097
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,098
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,099
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,100
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
Permutes a tensor by segments according to recat tensor. For variable stride tensors we permute across length per key, which reduces the number of permute indices and lengthens each sequence. `keyed_jagged_index_select_dim1` more efficiently parallelizes work for each permute index and sequence across multiple thread b...
9,101
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,102
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,103
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,104
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,105
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,106
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,107
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,108
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,109
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,110
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,111
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,112
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
This function checks if two JaggedTensors are equal by comparing their internal representations. The comparison is done by comparing the values of the internal representations themselves. For optional fields, None values are treated as equal. Args: jt_1 (JaggedTensor): the first JaggedTensor jt_2 (JaggedTensor): the se...
9,113
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
This function checks if two KeyedJaggedTensors are equal by comparing their internal representations. The comparison is done by comparing the values of the internal representations themselves. For optional fields, None values are treated as equal. We compare the keys by ensuring that they have the same length and that ...
9,114
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,115
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,116
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,117
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,118
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,119
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,120
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,121
import abc import operator from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch.autograd.profiler import record_function from torch.fx._pytree import register_pytree_flatten_spec, TreeSpec from torch.utils._pytree import GetAttrKey, KeyEntry, register_pytree_node from torchrec.st...
null
9,122
import csv import math import random from dataclasses import dataclass from functools import partial from io import IOBase from typing import Any, Callable, Iterable, Iterator, List, Sequence, Tuple, TypeVar import torch from iopath.common.file_io import PathManager, PathManagerFactory from torch.utils.data import func...
null
9,123
import csv import math import random from dataclasses import dataclass from functools import partial from io import IOBase from typing import Any, Callable, Iterable, Iterator, List, Sequence, Tuple, TypeVar import torch from iopath.common.file_io import PathManager, PathManagerFactory from torch.utils.data import func...
Via uniform random sampling, generates two IterDataPipe instances representing disjoint train and val splits of the given IterDataPipe. Args: datapipe (IterDataPipe): datapipe to split. train_perc (float): value in range (0.0, 1.0) specifying target proportion of datapipe samples to include in train split. Note that th...
9,124
import csv import math import random from dataclasses import dataclass from functools import partial from io import IOBase from typing import Any, Callable, Iterable, Iterator, List, Sequence, Tuple, TypeVar import torch from iopath.common.file_io import PathManager, PathManagerFactory from torch.utils.data import func...
null
9,125
import csv import math import random from dataclasses import dataclass from functools import partial from io import IOBase from typing import Any, Callable, Iterable, Iterator, List, Sequence, Tuple, TypeVar import torch from iopath.common.file_io import PathManager, PathManagerFactory from torch.utils.data import func...
null
9,126
import os import shutil import time from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union import numpy as np import torch import torch.utils.data.datapipes as dp from iopath.common.file_io import PathManager, PathManagerFactory from pyre_extensions import none_throws from torch.utils....
`Criteo 1TB Click Logs <https://ailab.criteo.com/download-criteo-1tb-click-logs-dataset/>`_ Dataset Args: paths (Iterable[str]): local paths to TSV files that constitute the Criteo 1TB dataset. row_mapper (Optional[Callable[[List[str]], Any]]): function to apply to each split TSV line. open_kw: options to pass to under...
9,127
import os import shutil import time from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union import numpy as np import torch import torch.utils.data.datapipes as dp from iopath.common.file_io import PathManager, PathManagerFactory from pyre_extensions import none_throws from torch.utils....
`Kaggle/Criteo Display Advertising <https://www.kaggle.com/c/criteo-display-ad-challenge/>`_ Dataset Args: path (str): local path to train or test dataset file. row_mapper (Optional[Callable[[List[str]], Any]]): function to apply to each split TSV line. open_kw: options to pass to underlying invocation of iopath.common...
9,128
import argparse import os import sys from multiprocessing import Manager, Process from typing import List import numpy as np from torchrec.datasets.criteo import BinaryCriteoUtils def parse_args(argv: List[str]) -> argparse.Namespace: parser = argparse.ArgumentParser(description="Shuffle preprocessed npy dataset."...
null
9,129
import argparse import os import sys from multiprocessing import Manager, Process from typing import List import numpy as np from torchrec.datasets.criteo import BinaryCriteoUtils def count_rows(rows_per_file, path, day): day_file = os.path.join(path, f"day_{day}_labels.npy") data = np.load(day_file) num_r...
null
9,130
import argparse import math import os import time from typing import Sequence import numpy as np from tqdm import tqdm from utils.criteo_constant import ( CAT_FEATURE_COUNT, DEFAULT_INT_NAMES, NUM_EMBEDDINGS_PER_FEATURE, ) def split_binary_file( binary_file_path: str, output_dir: str, categorica...
null
9,131
import argparse import os import shutil import subprocess import time import numpy as np import nvtabular as nvt from utils.criteo_constant import DAYS, DEFAULT_COLUMN_NAMES, DEFAULT_LABEL_NAME from utils.dask import setup_dask dtypes = {c: np.int32 for c in DEFAULT_COLUMN_NAMES[:14] + [DEFAULT_LABEL_NAME]} dtypes.upda...
null
9,132
import argparse import os import shutil import subprocess import time import numpy as np import nvtabular as nvt from utils.criteo_constant import DAYS, DEFAULT_COLUMN_NAMES, DEFAULT_LABEL_NAME from utils.dask import setup_dask def parse_args(): parser = argparse.ArgumentParser(description="Convert criteo tsv to p...
null
9,133
import argparse import os import shutil import time import numpy as np import nvtabular as nvt from merlin.io import Shuffle from utils.criteo_constant import ( DAYS, DEFAULT_CAT_NAMES, DEFAULT_COLUMN_NAMES, DEFAULT_INT_NAMES, DEFAULT_LABEL_NAME, NUM_EMBEDDINGS_PER_FEATURE_DICT, ) from utils.das...
null
9,134
import argparse import glob import os import time import numpy as np import pandas as pd import tqdm from joblib import delayed, Parallel from utils.criteo_constant import ( DEFAULT_CAT_NAMES, DEFAULT_COLUMN_NAMES, DEFAULT_INT_NAMES, DEFAULT_LABEL_NAME, ) DEFAULT_LABEL_NAME = "label" DEFAULT_INT_NAMES:...
null
9,135
import os import shutil import numba from dask.distributed import Client from dask_cuda import LocalCUDACluster from nvtabular.utils import device_mem_size def setup_dask(dask_workdir): if os.path.exists(dask_workdir): shutil.rmtree(dask_workdir) os.makedirs(dask_workdir) device_limit_frac = 0.8 ...
null
9,136
import argparse import os import sys from typing import List from torchrec.datasets.criteo import BinaryCriteoUtils def parse_args(argv: List[str]) -> argparse.Namespace: parser = argparse.ArgumentParser( description="Criteo sparse -> contiguous preprocessing script. " ) parser.add_argument( ...
null
9,137
import argparse import os import sys from typing import List from torchrec.datasets.criteo import BinaryCriteoUtils def parse_args(argv: List[str]) -> argparse.Namespace: parser = argparse.ArgumentParser( description="Criteo tsv -> npy preprocessing script." ) parser.add_argument( "--input_...
null
9,138
import os from typing import Any, Callable, Dict, List, Optional, Union from torch.utils.data import IterDataPipe from torchrec.datasets.utils import LoadFiles, ReadLinesFromCSV, safe_cast def _default_row_mapper(example: List[str]) -> Dict[str, Union[float, int, str]]: return { DEFAULT_COLUMN_NAMES[idx]: C...
`MovieLens 20M <https://grouplens.org/datasets/movielens/20m/>`_ Dataset Args: root (str): local path to root directory containing MovieLens 20M dataset files. include_movies_data (bool): if True, adds movies data to each line. row_mapper (Optional[Callable[[List[str]], Any]]): function to apply to each split line. ope...
9,139
import os from typing import Any, Callable, Dict, List, Optional, Union from torch.utils.data import IterDataPipe from torchrec.datasets.utils import LoadFiles, ReadLinesFromCSV, safe_cast def _default_row_mapper(example: List[str]) -> Dict[str, Union[float, int, str]]: return { DEFAULT_COLUMN_NAMES[idx]: C...
`MovieLens 25M <https://grouplens.org/datasets/movielens/25m/>`_ Dataset Args: root (str): local path to root directory containing MovieLens 25M dataset files. include_movies_data (bool): if True, adds movies data to each line. row_mapper (Optional[Callable[[List[str]], Any]]): function to apply to each split line. ope...
9,140
from typing import Any, Dict, Iterable, List import torch from torch import Tensor from torch.optim.optimizer import Optimizer def _single_tensor_adagrad( params: List[Tensor], grads: List[Tensor], state_sums: List[Tensor], state_steps: List[Tensor], *, lr: float, weight_decay: float, lr...
r"""Functional API that performs Adagrad algorithm computation. See :class:`~torch.optim.Adagrad` for details.
9,141
import logging import math from dataclasses import dataclass from enum import Enum, unique from typing import Any, List, Tuple import torch from torchrec.optim.keyed import KeyedOptimizer, OptimizerWrapper class WarmupPolicy(Enum): NONE = "none" LINEAR = "linear" CONSTANT = "constant" POLY = "poly" ...
null
9,142
import logging import math from dataclasses import dataclass from enum import Enum, unique from typing import Any, List, Tuple import torch from torchrec.optim.keyed import KeyedOptimizer, OptimizerWrapper class WarmupPolicy(Enum): class WarmupStage: def _get_multiplier(stage: WarmupStage, iter: int) -> float: mul...
null
9,143
from typing import Any, Dict, Iterable, Type from warnings import warn import torch The provided code snippet includes necessary dependencies for implementing the `apply_optimizer_in_backward` function. Write a Python function `def apply_optimizer_in_backward( optimizer_class: Type[torch.optim.Optimizer], para...
NOTE: This API is deprecated. Please use Pytorch Distributed's _apply_optimizer_in_backward instead. Upon backwards(), parameters will fire the corresponding optimizer Each parameter will have the optimizer_class and optimizer_kwargs attached to _optimizer and _optimizer_kwargs. Note - gradients for these parameters wi...
9,144
from typing import Dict, List, Optional, Tuple import torch from torch import nn from torchrec.datasets.utils import Batch from torchrec.modules.crossnet import LowRankCrossNet from torchrec.modules.embedding_modules import EmbeddingBagCollection from torchrec.modules.mlp import MLP from torchrec.sparse.jagged_tensor i...
Simple implementation of math.comb for Python 3.7 compatibility.
9,145
import argparse import concurrent.futures import json import os import subprocess from typing import List from usort import config as usort_config, usort from utils import as_posix, LintMessage, LintSeverity class LintSeverity(str, Enum): ERROR = "error" WARNING = "warning" ADVICE = "advice" DISABLED =...
null
9,146
import argparse import concurrent.futures import json import logging import os import subprocess import sys import time from typing import BinaryIO, List from utils import as_posix, IS_WINDOWS, LintMessage, LintSeverity def run_command( args: List[str], *, stdin: BinaryIO, retries: int, timeout: int...
null
9,147
import argparse import logging import os import subprocess import sys import time from typing import List def run_command(args: List[str]) -> "subprocess.CompletedProcess[bytes]": logging.debug("$ %s", " ".join(args)) start_time = time.monotonic() try: return subprocess.run(args, check=True) fi...
null
9,148
import os import tensorrt as trt import pycuda.autoinit import pycuda.driver as cuda from calibrator import Calibrator from torch.autograd import Variable import torch import numpy as np import time TRT_LOGGER = trt.Logger(trt.Logger.VERBOSE) class Calibrator(trt.IInt8EntropyCalibrator2): def __init__(self, input_...
Attempts to load a serialized engine if available, otherwise builds a new TensorRT engine and saves it.
9,149
import os import tensorrt as trt import pycuda.autoinit import pycuda.driver as cuda from calibrator import Calibrator from torch.autograd import Variable import torch import numpy as np import time class HostDeviceMem(object): def __init__(self, host_mem, device_mem): """Within this context, host_mom means...
null
9,150
import os import tensorrt as trt import pycuda.autoinit import pycuda.driver as cuda from calibrator import Calibrator from torch.autograd import Variable import torch import numpy as np import time class HostDeviceMem(object): def __init__(self, host_mem, device_mem): def __str__(self): def __repr__(sel...
null
9,151
import os import tensorrt as trt import pycuda.autoinit import pycuda.driver as cuda from calibrator import Calibrator from torch.autograd import Variable import torch import numpy as np import time def do_inference(context, bindings, inputs, outputs, stream, batch_size=1): # Transfer data from CPU to GPU. [cu...
null
9,152
import os import tensorrt as trt import pycuda.autoinit import pycuda.driver as cuda from calibrator import Calibrator from torch.autograd import Variable import torch import numpy as np import time def do_inference_v2(context, bindings, inputs, outputs, stream, h_, w_, binding_id): # set the input dimensions ...
null
9,153
import os import tensorrt as trt import pycuda.autoinit import pycuda.driver as cuda from calibrator import Calibrator from torch.autograd import Variable import torch import numpy as np import time def postprocess_the_outputs(h_outputs, shape_of_output): h_outputs = h_outputs.reshape(*shape_of_output).copy() ...
null
9,154
import os import tensorrt as trt import pycuda.autoinit import pycuda.driver as cuda from calibrator import Calibrator from torch.autograd import Variable import torch import numpy as np import time def to_numpy(tensor): return ( tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy...
null
9,155
import numpy as np import torch import torch.nn as nn import util_trt from calibrator import SegBatchStream def evaluate_trt(segmentation_module_trt, loader, cfg, gpu, result_queue_trt): # pbar = tqdm(total=len(loader)) for batch_data in loader: # process data batch_data = batch_data[0] ...
null
9,156
from __future__ import absolute_import from __future__ import division from __future__ import print_function import sys import math import os import argparse import numpy as np import torch import torch.nn as nn import torch.optim as optim import torchvision import torchvision.transforms as transforms from torch.autogr...
null
9,157
from __future__ import absolute_import from __future__ import division from __future__ import print_function import sys import math import os import argparse import numpy as np import torch import torch.nn as nn import torch.optim as optim import torchvision import torchvision.transforms as transforms from torch.autogr...
null
9,158
from __future__ import absolute_import from __future__ import division from __future__ import print_function import sys import math import os import argparse import numpy as np import torch import torch.nn as nn import torch.optim as optim import torchvision import torchvision.transforms as transforms from torch.autogr...
null
9,159
from __future__ import absolute_import from __future__ import division from __future__ import print_function import sys import math import os import argparse import numpy as np import torch import torch.nn as nn import torch.optim as optim import torchvision import torchvision.transforms as transforms from torch.autogr...
null
9,160
from __future__ import absolute_import from __future__ import division from __future__ import print_function import sys import os import math import argparse import numpy as np import torch import torch.nn as nn import torch.optim as optim import torchvision import torchvision.transforms as transforms from torch.autogr...
null
9,161
from __future__ import absolute_import from __future__ import division from __future__ import print_function import sys import os import math import argparse import numpy as np import torch import torch.nn as nn import torch.optim as optim import torchvision import torchvision.transforms as transforms from torch.autogr...
null