mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
This PR is proposing a new approach to solve the nn/optim only linked by python object identity problem. The idea is to have a function that can swap the content of two Tensors t1 and t2 while preserving all the old references. This would allow us to swap the `model.weight` with a new Tensor (can be any subclass of Tensor and any TensorImpl (xla, sparse, nested tensorimpl would work)). The use within nn will be done in a follow up. This is done by swapping the whole content of the PyObject and then putting back the fields associated with external references (refcount, gc tracking and weakrefs). Note that we have to properly handle all the cases where there is memory used before the public pointer PyObject* and where the PyObject is bigger due to dict/weakref being inlined (older CPython version) or due to slots. The main limitation of this approach is that the number of slots need to match for the objects being swapped and thus limit usage of slots in subclasses. Draft right now to see what @colesbury thinks about doing this? Pull Request resolved: https://github.com/pytorch/pytorch/pull/111747 Approved by: https://github.com/colesbury
91 lines
4.0 KiB
ReStructuredText
91 lines
4.0 KiB
ReStructuredText
torch.utils
|
|
===================================
|
|
.. automodule:: torch.utils
|
|
.. currentmodule:: torch.utils
|
|
|
|
.. autosummary::
|
|
:toctree: generated
|
|
:nosignatures:
|
|
|
|
rename_privateuse1_backend
|
|
generate_methods_for_privateuse1_backend
|
|
get_cpp_backtrace
|
|
set_module
|
|
swap_tensors
|
|
|
|
.. This module needs to be documented. Adding here in the meantime
|
|
.. for tracking purposes
|
|
.. py:module:: torch.utils.backend_registration
|
|
.. py:module:: torch.utils.benchmark.examples.blas_compare_setup
|
|
.. py:module:: torch.utils.benchmark.examples.compare
|
|
.. py:module:: torch.utils.benchmark.examples.fuzzer
|
|
.. py:module:: torch.utils.benchmark.examples.op_benchmark
|
|
.. py:module:: torch.utils.benchmark.examples.simple_timeit
|
|
.. py:module:: torch.utils.benchmark.examples.spectral_ops_fuzz_test
|
|
.. py:module:: torch.utils.benchmark.op_fuzzers.binary
|
|
.. py:module:: torch.utils.benchmark.op_fuzzers.sparse_binary
|
|
.. py:module:: torch.utils.benchmark.op_fuzzers.sparse_unary
|
|
.. py:module:: torch.utils.benchmark.op_fuzzers.spectral
|
|
.. py:module:: torch.utils.benchmark.op_fuzzers.unary
|
|
.. py:module:: torch.utils.benchmark.utils.common
|
|
.. py:module:: torch.utils.benchmark.utils.compare
|
|
.. py:module:: torch.utils.benchmark.utils.compile
|
|
.. py:module:: torch.utils.benchmark.utils.cpp_jit
|
|
.. py:module:: torch.utils.benchmark.utils.fuzzer
|
|
.. py:module:: torch.utils.benchmark.utils.sparse_fuzzer
|
|
.. py:module:: torch.utils.benchmark.utils.timer
|
|
.. py:module:: torch.utils.benchmark.utils.valgrind_wrapper.timer_interface
|
|
.. py:module:: torch.utils.bundled_inputs
|
|
.. py:module:: torch.utils.checkpoint
|
|
.. py:module:: torch.utils.collect_env
|
|
.. py:module:: torch.utils.cpp_backtrace
|
|
.. py:module:: torch.utils.cpp_extension
|
|
.. py:module:: torch.utils.data.backward_compatibility
|
|
.. py:module:: torch.utils.data.dataloader
|
|
.. py:module:: torch.utils.data.datapipes.dataframe.dataframe_wrapper
|
|
.. py:module:: torch.utils.data.datapipes.dataframe.dataframes
|
|
.. py:module:: torch.utils.data.datapipes.dataframe.datapipes
|
|
.. py:module:: torch.utils.data.datapipes.dataframe.structures
|
|
.. py:module:: torch.utils.data.datapipes.datapipe
|
|
.. py:module:: torch.utils.data.datapipes.gen_pyi
|
|
.. py:module:: torch.utils.data.datapipes.iter.callable
|
|
.. py:module:: torch.utils.data.datapipes.iter.combinatorics
|
|
.. py:module:: torch.utils.data.datapipes.iter.combining
|
|
.. py:module:: torch.utils.data.datapipes.iter.filelister
|
|
.. py:module:: torch.utils.data.datapipes.iter.fileopener
|
|
.. py:module:: torch.utils.data.datapipes.iter.grouping
|
|
.. py:module:: torch.utils.data.datapipes.iter.routeddecoder
|
|
.. py:module:: torch.utils.data.datapipes.iter.selecting
|
|
.. py:module:: torch.utils.data.datapipes.iter.sharding
|
|
.. py:module:: torch.utils.data.datapipes.iter.streamreader
|
|
.. py:module:: torch.utils.data.datapipes.iter.utils
|
|
.. py:module:: torch.utils.data.datapipes.map.callable
|
|
.. py:module:: torch.utils.data.datapipes.map.combinatorics
|
|
.. py:module:: torch.utils.data.datapipes.map.combining
|
|
.. py:module:: torch.utils.data.datapipes.map.grouping
|
|
.. py:module:: torch.utils.data.datapipes.map.utils
|
|
.. py:module:: torch.utils.data.datapipes.utils.common
|
|
.. py:module:: torch.utils.data.datapipes.utils.decoder
|
|
.. py:module:: torch.utils.data.datapipes.utils.snapshot
|
|
.. py:module:: torch.utils.data.dataset
|
|
.. py:module:: torch.utils.data.distributed
|
|
.. py:module:: torch.utils.data.graph
|
|
.. py:module:: torch.utils.data.graph_settings
|
|
.. py:module:: torch.utils.data.sampler
|
|
.. py:module:: torch.utils.dlpack
|
|
.. py:module:: torch.utils.file_baton
|
|
.. py:module:: torch.utils.flop_counter
|
|
.. py:module:: torch.utils.hipify.constants
|
|
.. py:module:: torch.utils.hipify.cuda_to_hip_mappings
|
|
.. py:module:: torch.utils.hipify.hipify_python
|
|
.. py:module:: torch.utils.hipify.version
|
|
.. py:module:: torch.utils.hooks
|
|
.. py:module:: torch.utils.jit.log_extract
|
|
.. py:module:: torch.utils.mkldnn
|
|
.. py:module:: torch.utils.mobile_optimizer
|
|
.. py:module:: torch.utils.show_pickle
|
|
.. py:module:: torch.utils.tensorboard.summary
|
|
.. py:module:: torch.utils.tensorboard.writer
|
|
.. py:module:: torch.utils.throughput_benchmark
|
|
.. py:module:: torch.utils.weak
|