mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
[BE][16/16] fix typos in torch/ (torch/utils/) (#156606)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156606 Approved by: https://github.com/albanD ghstack dependencies: #156318, #156320, #156602, #156604
This commit is contained in:
parent
11c07c848c
commit
d40aaa42ee
|
|
@ -1157,6 +1157,7 @@ exclude_patterns = [
|
|||
'torch/_vendor/**',
|
||||
'torch/_inductor/fx_passes/serialized_patterns/**',
|
||||
'torch/_inductor/autoheuristic/artifacts/**',
|
||||
'torch/utils/model_dump/preact.mjs',
|
||||
# These files are all grandfathered in, feel free to remove from this list
|
||||
# as necessary
|
||||
# NOTE: remove the patterns in the order they are listed
|
||||
|
|
@ -1174,7 +1175,6 @@ exclude_patterns = [
|
|||
'torch/**',
|
||||
'torch/_*/**',
|
||||
'torch/distributed/tensor/**',
|
||||
'torch/utils/**',
|
||||
]
|
||||
init_command = [
|
||||
'python3',
|
||||
|
|
|
|||
|
|
@ -52,17 +52,17 @@ class _Config(Generic[T]):
|
|||
alias: If set, the directly use the value of the alias.
|
||||
env_name_force: If set, this environment variable has precedence over
|
||||
everything after this.
|
||||
If multiple env variables are given, the precendence order is from
|
||||
If multiple env variables are given, the precedence order is from
|
||||
left to right.
|
||||
user_override: If a user sets a value (i.e. foo.bar=True), that
|
||||
has precedence over everything after this.
|
||||
env_name_default: If set, this environment variable will override everything
|
||||
after this.
|
||||
If multiple env variables are given, the precendence order is from
|
||||
If multiple env variables are given, the precedence order is from
|
||||
left to right.
|
||||
justknob: If this pytorch installation supports justknobs, that will
|
||||
override defaults, but will not override the user_override precendence.
|
||||
default: This value is the lowest precendance, and will be used if nothing is
|
||||
override defaults, but will not override the user_override precedence.
|
||||
default: This value is the lowest precedence, and will be used if nothing is
|
||||
set.
|
||||
|
||||
Environment Variables:
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class DeviceContext(TorchFunctionMode):
|
|||
CURRENT_DEVICE = self.old_device
|
||||
cur_stack = []
|
||||
# Invariant: there should only be one DeviceContext on the stack at any time
|
||||
# (At the bottom), pop all mdoes until we hit the bottom, assert it's a DeviceContext
|
||||
# (At the bottom), pop all modes until we hit the bottom, assert it's a DeviceContext
|
||||
# or else someone else has popped it!
|
||||
for _ in range(_len_torch_function_stack() - 1):
|
||||
mode = _pop_mode()
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class StrobelightCLIFunctionProfiler:
|
|||
|
||||
StrobelightCLIFunctionProfiler can be used to profile a python function and
|
||||
generate a strobelight link with the results. It works on meta servers but
|
||||
does not requries an fbcode target.
|
||||
does not requires an fbcode target.
|
||||
When stop_at_error is false(default), error during profiling does not prevent
|
||||
the work function from running.
|
||||
|
||||
|
|
|
|||
|
|
@ -1055,7 +1055,7 @@ class PowByNatural(sympy.Function):
|
|||
|
||||
|
||||
# base is assumed to be nonnegative, thereby prevent complex numbers from
|
||||
# occuring
|
||||
# occurring
|
||||
class FloatPow(sympy.Function):
|
||||
is_real = True
|
||||
|
||||
|
|
@ -1315,7 +1315,7 @@ def make_opaque_unary_fn(name):
|
|||
constant propagation. This helps avoid performing transformations
|
||||
that are valid for real numbers but are invalid for floating point;
|
||||
in particular, while we are willing to make optimizations that change
|
||||
numerics for Tensor compute, we are NOT willing to make optimziations
|
||||
numerics for Tensor compute, we are NOT willing to make optimizations
|
||||
that change numerics for size compute.
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -920,7 +920,7 @@ class SymPyValueRangeAnalysis:
|
|||
return (a, b)
|
||||
|
||||
# piecewise function can be used to convert a SymBool to SymInt:
|
||||
# int_expr = Piecewise((1, bool_expr), (0, True)), it evalutes to 1 when sym_bool is True and 0 otherwise.
|
||||
# int_expr = Piecewise((1, bool_expr), (0, True)), it evaluates to 1 when sym_bool is True and 0 otherwise.
|
||||
#
|
||||
# ranges is a sequence of (expr_range, condition_range) pairs. The range pair is constructed in expr_cond_pair.
|
||||
# The ValueRange of Piecewise is just the union of all expr ranges whose condition expr can be True.
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ def _normalization_device(
|
|||
elif isinstance(device, str):
|
||||
device = torch.device(device)
|
||||
|
||||
# variable devcie can only be torch.device type or int type
|
||||
# variable device can only be torch.device type or int type
|
||||
if isinstance(device, torch.device):
|
||||
if device.type != custom_backend_name:
|
||||
raise RuntimeError(f"Invalid device, must be {custom_backend_name} device")
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ class Compare:
|
|||
https://pytorch.org/tutorials/recipes/recipes/benchmark.html
|
||||
|
||||
Args:
|
||||
results: List of Measurment to display.
|
||||
results: List of Measurement to display.
|
||||
"""
|
||||
def __init__(self, results: list[common.Measurement]):
|
||||
self._results: list[common.Measurement] = []
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ if HAS_TABULATE:
|
|||
This is a simple utility that can be used to benchmark torch.compile
|
||||
In particular it ensures that your GPU is setup to use tensor cores if it supports its
|
||||
It also tries out all the main backends and prints a table of results so you can easily compare them all
|
||||
Many of the backendds have their own optional dependencies so please pip install them seperately
|
||||
Many of the backendds have their own optional dependencies so please pip install them separately
|
||||
|
||||
You will get one table for inference and another for training
|
||||
If you'd like to leverage this utility for training make sure to pass in a torch.optim.Optimizer
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ def bundle_inputs(
|
|||
)
|
||||
|
||||
# The above cloning function returns a torch._C.scriptmodule and we need a torch.jit.scriptmodule.
|
||||
# Fortunately theres a function in _recursive that does exactly that conversion.
|
||||
# Fortunately there is a function in _recursive that does exactly that conversion.
|
||||
cloned_module = wrap_cpp_module(clone)
|
||||
if isinstance(inputs, dict):
|
||||
assert isinstance(info, dict) or info is None
|
||||
|
|
|
|||
|
|
@ -858,7 +858,7 @@ class _CheckpointFrame:
|
|||
if not len(self.weak_holders) == self.recomp_counter[gid]:
|
||||
# 2. During recompute, fewer tensors were saved
|
||||
#
|
||||
# We know that everytime we save something do original forward
|
||||
# We know that every time we save something do original forward
|
||||
# we append to weak_holder, and every time we save a tensor
|
||||
# during recompute we increment recompute_counter.
|
||||
raise CheckpointError(
|
||||
|
|
@ -1270,7 +1270,7 @@ class CheckpointPolicy(enum.Enum):
|
|||
|
||||
|
||||
def _policy_from_bool(b):
|
||||
# For backward compatability
|
||||
# For backward compatibility
|
||||
return CheckpointPolicy.MUST_SAVE if b else CheckpointPolicy.PREFER_RECOMPUTE
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -493,7 +493,7 @@ def get_env_info():
|
|||
Caching allocator config, XNNPACK availability and CPU information.
|
||||
|
||||
Returns:
|
||||
SystemEnv (namedtuple): A tuple containining various environment details
|
||||
SystemEnv (namedtuple): A tuple containing various environment details
|
||||
and system information.
|
||||
"""
|
||||
run_lambda = run
|
||||
|
|
|
|||
|
|
@ -303,10 +303,10 @@ def _append_sycl_targets_if_missing(cflags):
|
|||
cflags.append('-fsycl-targets=spir64')
|
||||
|
||||
def _get_sycl_device_flags(cflags):
|
||||
# We need last occurence of -fsycl-targets as it will be the one taking effect.
|
||||
# We need last occurrence of -fsycl-targets as it will be the one taking effect.
|
||||
# So searching in reversed list.
|
||||
flags = [f for f in reversed(cflags) if f.startswith('-fsycl-targets=')]
|
||||
assert flags, "bug: -fsycl-targets should have been ammended to cflags"
|
||||
assert flags, "bug: -fsycl-targets should have been amended to cflags"
|
||||
|
||||
arch_list = _get_sycl_arch_list()
|
||||
if arch_list != '':
|
||||
|
|
@ -466,7 +466,7 @@ def get_compiler_abi_compatibility_and_version(compiler) -> tuple[bool, TorchVer
|
|||
logger.warning('Error checking compiler version for %s: %s', compiler, error)
|
||||
return (False, TorchVersion('0.0.0'))
|
||||
|
||||
# convert alpha-numeric string to numeric string
|
||||
# convert alphanumeric string to numeric string
|
||||
# amdclang++ returns str like 0.0.0git, others return 0.0.0
|
||||
numeric_version = [re.sub(r'\D', '', v) for v in version]
|
||||
|
||||
|
|
@ -770,7 +770,7 @@ class BuildExtension(build_ext):
|
|||
r"""Compiles sources by outputting a ninja file and running it."""
|
||||
# NB: I copied some lines from self.compiler (which is an instance
|
||||
# of distutils.UnixCCompiler). See the following link.
|
||||
# https://github.com/python/cpython/blob/f03a8f8d5001963ad5b5b28dbd95497e9cc15596/Lib/distutils/ccompiler.py#L564-L567
|
||||
# https://github.com/python/cpython/blob/f03a8f8d5001963ad5b5b28dbd95497e9cc15596/Lib/distutils/ccompiler.py#L564-L567 # codespell:ignore
|
||||
# This can be fragile, but a lot of other repos also do this
|
||||
# (see https://github.com/search?q=_setup_compile&type=Code)
|
||||
# so it is probably OK; we'll also get CI signal if/when
|
||||
|
|
@ -899,7 +899,7 @@ class BuildExtension(build_ext):
|
|||
if m
|
||||
]
|
||||
|
||||
obj_regex = re.compile('/Fo(.*)')
|
||||
obj_regex = re.compile('/Fo(.*)') # codespell:ignore
|
||||
obj_list = [
|
||||
m.group(1) for m in (obj_regex.match(elem) for elem in cmd)
|
||||
if m
|
||||
|
|
@ -1057,7 +1057,7 @@ class BuildExtension(build_ext):
|
|||
# Return *all* object filenames, not just the ones we just built.
|
||||
return objects
|
||||
# Monkey-patch the _compile or compile method.
|
||||
# https://github.com/python/cpython/blob/dc0284ee8f7a270b6005467f26d8e5773d76e959/Lib/distutils/ccompiler.py#L511
|
||||
# https://github.com/python/cpython/blob/dc0284ee8f7a270b6005467f26d8e5773d76e959/Lib/distutils/ccompiler.py#L511 # codespell:ignore
|
||||
if self.compiler.compiler_type == 'msvc':
|
||||
if self.use_ninja:
|
||||
self.compiler.compile = win_wrap_ninja_compile
|
||||
|
|
@ -1744,7 +1744,7 @@ def _check_and_build_extension_h_precompiler_headers(
|
|||
is_standalone=False):
|
||||
r'''
|
||||
Precompiled Headers(PCH) can pre-build the same headers and reduce build time for pytorch load_inline modules.
|
||||
GCC offical manual: https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Precompiled-Headers.html
|
||||
GCC official manual: https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Precompiled-Headers.html
|
||||
PCH only works when built pch file(header.h.gch) and build target have the same build parameters. So, We need
|
||||
add a signature file to record PCH file parameters. If the build parameters(signature) changed, it should rebuild
|
||||
PCH file.
|
||||
|
|
@ -2447,8 +2447,8 @@ def _get_cuda_arch_flags(cflags: Optional[list[str]] = None) -> list[str]:
|
|||
# Deal with lists that are ' ' separated (only deal with ';' after)
|
||||
_arch_list = _arch_list.replace(' ', ';')
|
||||
# Expand named arches
|
||||
for named_arch, archval in named_arches.items():
|
||||
_arch_list = _arch_list.replace(named_arch, archval)
|
||||
for named_arch, archival in named_arches.items():
|
||||
_arch_list = _arch_list.replace(named_arch, archival)
|
||||
|
||||
arch_list = _arch_list.split(';')
|
||||
|
||||
|
|
@ -2583,7 +2583,7 @@ def _run_ninja_build(build_directory: str, verbose: bool, error_prefix: str) ->
|
|||
# subprocess.run assumes that sys.__stdout__ has not been modified and
|
||||
# attempts to write to it by default. However, when we call _run_ninja_build
|
||||
# from ahead-of-time cpp extensions, the following happens:
|
||||
# 1) If the stdout encoding is not utf-8, setuptools detachs __stdout__.
|
||||
# 1) If the stdout encoding is not utf-8, setuptools detaches __stdout__.
|
||||
# https://github.com/pypa/setuptools/blob/7e97def47723303fafabe48b22168bbc11bb4821/setuptools/dist.py#L1110
|
||||
# (it probably shouldn't do this)
|
||||
# 2) subprocess.run (on POSIX, with no stdout override) relies on
|
||||
|
|
@ -2872,7 +2872,9 @@ e.
|
|||
if IS_WINDOWS:
|
||||
compiler_name = "$cxx" if IS_HIP_EXTENSION else "cl"
|
||||
compile_rule.append(
|
||||
f' command = {compiler_name} /showIncludes $cflags -c $in /Fo$out $post_cflags')
|
||||
f' command = {compiler_name} '
|
||||
'/showIncludes $cflags -c $in /Fo$out $post_cflags' # codespell:ignore
|
||||
)
|
||||
if not IS_HIP_EXTENSION:
|
||||
compile_rule.append(' deps = msvc')
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -480,7 +480,7 @@ class DataLoader(Generic[_T_co]):
|
|||
|
||||
def __iter__(self) -> _BaseDataLoaderIter:
|
||||
# When using a single worker the returned iterator should be
|
||||
# created everytime to avoid resetting its state
|
||||
# created every time to avoid resetting its state
|
||||
# However, in the case of a multiple workers iterator
|
||||
# the iterator is only created once in the lifetime of the
|
||||
# DataLoader object so that workers can be reused
|
||||
|
|
@ -556,10 +556,10 @@ class DataLoader(Generic[_T_co]):
|
|||
# necessary.
|
||||
#
|
||||
#
|
||||
# [Note] Please note that this function repects `cpuset` only when os.sched_getaffinity is
|
||||
# [Note] Please note that this function respects `cpuset` only when os.sched_getaffinity is
|
||||
# available (available in most of Linux system, but not OSX and Windows).
|
||||
# When os.sched_getaffinity is not available, os.cpu_count() is called instead, but
|
||||
# it doesn't repect cpuset.
|
||||
# it doesn't respect cpuset.
|
||||
# We don't take threading into account since each worker process is single threaded
|
||||
# at this time.
|
||||
#
|
||||
|
|
@ -886,7 +886,7 @@ class _MultiProcessingDataLoaderIter(_BaseDataLoaderIter):
|
|||
# 2. A similar issue araises when a `DataLoader` is used in a subprocess.
|
||||
# When a process ends, it shuts the all its daemonic children
|
||||
# down with a SIGTERM (instead of joining them without a timeout).
|
||||
# Simiarly for threads, but by a different mechanism. This fact,
|
||||
# Similarly for threads, but by a different mechanism. This fact,
|
||||
# together with a few implementation details of multiprocessing, forces
|
||||
# us to make workers daemonic. All of our problems arise when a
|
||||
# DataLoader is used in a subprocess, and are caused by multiprocessing
|
||||
|
|
@ -1017,7 +1017,7 @@ class _MultiProcessingDataLoaderIter(_BaseDataLoaderIter):
|
|||
# `cancel_join_thread` on that queue if its `IterableDataset` iterator
|
||||
# happens to exhaust coincidentally, which is out of the control of the
|
||||
# main process). Thus, since we will exit `pin_memory_thread` before the
|
||||
# workers (see below), two separete events are used.
|
||||
# workers (see below), two separate events are used.
|
||||
#
|
||||
# NOTE: In short, the protocol is that the main process will set these
|
||||
# `done_event`s and then the corresponding processes/threads a `None`,
|
||||
|
|
@ -1571,7 +1571,7 @@ class _MultiProcessingDataLoaderIter(_BaseDataLoaderIter):
|
|||
# (2) since we don't join, the worker may still raise error, and we
|
||||
# prefer capturing those, rather than ignoring them, even though they
|
||||
# are raised after the worker has finished its job.
|
||||
# Joinning is deferred to `_shutdown_workers`, which it is called when
|
||||
# Joining is deferred to `_shutdown_workers`, which it is called when
|
||||
# all workers finish their jobs (e.g., `IterableDataset` replicas) or
|
||||
# when this iterator is garbage collected.
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ Note that `__len__` method is optional for `IterDataPipe`.
|
|||
Like `CSVParserIterDataPipe` in the [Using DataPipe sector](#using-datapipe), `__len__` is not implemented because the size of each file streams is unknown for us before loading it.
|
||||
|
||||
Besides, in some special cases, `__len__` method can be provided, but it would either return an integer length or raise Error depending on the arguments of DataPipe.
|
||||
And, the Error is required to be `TypeError` to support Python's build-in functions like `list(dp)`.
|
||||
And, the Error is required to be `TypeError` to support Python's built-in functions like `list(dp)`.
|
||||
Please check NOTE [ Lack of Default `__len__` in Python Abstract Base Classes ] for detailed reason in PyTorch.
|
||||
|
||||
### Registering DataPipe with functional API
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ def _issubtype_with_constraints(variant, constraints, recursive=True):
|
|||
# - TypeVar[TypeVar[...]]
|
||||
# So, variant and each constraint may be a TypeVar or a Union.
|
||||
# In these cases, all of inner types from the variant are required to be
|
||||
# extraced and verified as a subtype of any constraint. And, all of
|
||||
# extracted and verified as a subtype of any constraint. And, all of
|
||||
# inner types from any constraint being a TypeVar or a Union are
|
||||
# also required to be extracted and verified if the variant belongs to
|
||||
# any of them.
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class DataFrameTracedOps(DFIterDataPipe):
|
|||
yield self.output_var.apply_ops(item)
|
||||
|
||||
|
||||
# TODO(VitalyFedyunin): Extract this list from the DFIterDataPipe registred functions
|
||||
# TODO(VitalyFedyunin): Extract this list from the DFIterDataPipe registered functions
|
||||
DATAPIPES_OPS = [
|
||||
"_dataframes_as_tuples",
|
||||
"groupby",
|
||||
|
|
@ -201,7 +201,7 @@ class CaptureLikeMock:
|
|||
def __init__(self, name):
|
||||
import unittest.mock as mock
|
||||
|
||||
# TODO(VitalyFedyunin): Do not use provate function here, copy own implementation instead.
|
||||
# TODO(VitalyFedyunin): Do not use private function here, copy own implementation instead.
|
||||
get_target, attribute = mock._get_target(name) # type: ignore[attr-defined]
|
||||
self.get_target = get_target
|
||||
self.attribute = attribute
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ def _collate_helper(conversion, item):
|
|||
|
||||
for name in conversion.keys():
|
||||
if name not in columns_name:
|
||||
raise RuntimeError("Conversion keys missmatch")
|
||||
raise RuntimeError("Conversion keys mismatch")
|
||||
|
||||
for name in columns_name:
|
||||
if name in conversion:
|
||||
|
|
|
|||
|
|
@ -753,7 +753,7 @@
|
|||
"\n",
|
||||
"Arguments:\n",
|
||||
" - `group_key_fn`\n",
|
||||
" - `group_size` - yeild resulted group as soon as `group_size` elements accumulated\n",
|
||||
" - `group_size` - yield resulted group as soon as `group_size` elements accumulated\n",
|
||||
" - `guaranteed_group_size:int = None`\n",
|
||||
" - `unbatch_level:int = 0` if specified calls `unbatch(unbatch_level=unbatch_level)` on source datapipe before batching (see `unbatch`)\n",
|
||||
"\n",
|
||||
|
|
@ -962,7 +962,7 @@
|
|||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"This behaviour becomes noticable when data is bigger than buffer and some groups getting evicted before gathering all potential items"
|
||||
"This behaviour becomes noticeable when data is bigger than buffer and some groups getting evicted before gathering all potential items"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@
|
|||
"\n",
|
||||
"Note: This decorator is only allowed to be attached to `__iter__` for now. It can be extended into `__getitem__` and further `nonblocking` functions.\n",
|
||||
"\n",
|
||||
"`runtime_validation_disabled` is a context manager to turn off the type validaiton during runtime. It's useful for DataLoader to disable the runtime validaiton after the first epoch is finished for better performance. Note: the runtime validation is enabled by default."
|
||||
"`runtime_validation_disabled` is a context manager to turn off the type validation during runtime. It's useful for DataLoader to disable the runtime validation after the first epoch is finished for better performance. Note: the runtime validation is enabled by default."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -684,7 +684,7 @@
|
|||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"- Compatible with context mangager to disable validation"
|
||||
"- Compatible with context manager to disable validation"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8736,7 +8736,7 @@ CAFFE2_SPECIFIC_MAPPINGS = collections.OrderedDict(
|
|||
]
|
||||
)
|
||||
|
||||
# We must tread very carefully here. Blanket conversions like are done
|
||||
# We must treat very carefully here. Blanket conversions like are done
|
||||
# in CAFFE2_SPECIFIC_MAPPINGS are not presently supported on PyTorch,
|
||||
# because a regex for CUDA will also match a filename like CUDAGuard.h,
|
||||
# but the HIPIFY script doesn't presently move the file and so the substitution
|
||||
|
|
|
|||
|
|
@ -465,7 +465,7 @@ def find_closure_group(input_string, start, group):
|
|||
|
||||
|
||||
def find_bracket_group(input_string, start):
|
||||
"""Finds the first balanced parantheses."""
|
||||
"""Finds the first balanced parentheses."""
|
||||
return find_closure_group(input_string, start, group=["{", "}"])
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -232,14 +232,14 @@ def get_model_info(
|
|||
model_data = get_pickle("data")
|
||||
constants = get_pickle("constants")
|
||||
|
||||
# Intern strings that are likely to be re-used.
|
||||
# Intern strings that are likely to be reused.
|
||||
# Pickle automatically detects shared structure,
|
||||
# so re-used strings are stored efficiently.
|
||||
# so reused strings are stored efficiently.
|
||||
# However, JSON has no way of representing this,
|
||||
# so we have to do it manually.
|
||||
interned_strings : dict[str, int] = {}
|
||||
|
||||
def ist(s):
|
||||
def intern(s):
|
||||
if s not in interned_strings:
|
||||
interned_strings[s] = len(interned_strings)
|
||||
return interned_strings[s]
|
||||
|
|
@ -293,7 +293,7 @@ def get_model_info(
|
|||
s_start = 0
|
||||
s_end = 0
|
||||
text = raw_code[start:end]
|
||||
code_parts.append([text.decode("utf-8"), ist(s_file), s_line, ist(s_text), s_start, s_end])
|
||||
code_parts.append([text.decode("utf-8"), intern(s_file), s_line, intern(s_text), s_start, s_end])
|
||||
code_files[zi.filename] = code_parts
|
||||
|
||||
extra_files_json_pattern = re.compile(re.escape(path_prefix) + "/extra/.*\\.json")
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ def _prepare_video(V):
|
|||
Convesrion is done from [batchsize, time(frame), channel(color), height, width] (5D tensor)
|
||||
to [time(frame), new_width, new_height, channel] (4D tensor).
|
||||
|
||||
A batch of images are spreaded to a grid, which forms a frame.
|
||||
A batch of images are spread to a grid, which forms a frame.
|
||||
e.g. Video with batchsize 16 will have a 4x4 grid.
|
||||
"""
|
||||
b, t, c, h, w = V.shape
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ def observe_garbage(observer):
|
|||
gc.callbacks.remove(gc_callback)
|
||||
return remove
|
||||
|
||||
# Function to visualize cycles adapated from refcycle:
|
||||
# Function to visualize cycles adapted from refcycle:
|
||||
# Copyright 2013 Mark Dickinson
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
@ -482,7 +482,7 @@ def warn_tensor_cycles():
|
|||
Install a warning that reports whenever a cycle that is holding CUDA memory is observed.
|
||||
|
||||
The warning produces an .html file that visualizes the cycle,
|
||||
and links it to the stack frame that allocted the CUDA tensor.
|
||||
and links it to the stack frame that allocated the CUDA tensor.
|
||||
|
||||
Reference cycles are freed by the cycle collector rather than being cleaned up
|
||||
when the objects in the cycle first become unreachable. If a cycle points to a tensor,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user