commit | 91c90f232ab906c9111ba83929ca8e74811dc484 | [log] [tgz] |
---|---|---|
author | IvanLauLinTiong <ivanlau91@hotmail.com> | Fri Nov 10 21:19:08 2023 +0000 |
committer | PyTorch MergeBot <pytorchmergebot@users.noreply.github.com> | Fri Nov 10 21:19:17 2023 +0000 |
tree | 29ed4ed19c45b7de05c2a64451a7b08b9dfa41ff | |
parent | 9752ef595c5f546e607316bdad2cbc00d782023d [diff] |
Fix docstring errors in reductions.py, spawn.py, pool.py, parameter.py, cpp.py, grad.py, __init__.py, profiler.py, queue.py, graph.py (#113052) Fixes #112595 - `torch/autograd/profiler.py` </br> **Before: 37** ``` torch/autograd/profiler.py:1 at module level: D100: Missing docstring in public module torch/autograd/profiler.py:91 in public class `profile`: D205: 1 blank line required between summary line and description (found 0) torch/autograd/profiler.py:175 in public method `__init__`: D107: Missing docstring in __init__ torch/autograd/profiler.py:261 in public method `config`: D102: Missing docstring in public method torch/autograd/profiler.py:272 in public method `__enter__`: D105: Missing docstring in magic method torch/autograd/profiler.py:290 in public method `__exit__`: D105: Missing docstring in magic method torch/autograd/profiler.py:308 in public method `__repr__`: D105: Missing docstring in magic method torch/autograd/profiler.py:313 in public method `__str__`: D105: Missing docstring in magic method torch/autograd/profiler.py:322 in public method `table`: D102: Missing docstring in public method torch/autograd/profiler.py:346 in public method `export_chrome_trace`: D102: Missing docstring in public method torch/autograd/profiler.py:355 in public method `export_stacks`: D102: Missing docstring in public method torch/autograd/profiler.py:361 in public method `key_averages`: D102: Missing docstring in public method torch/autograd/profiler.py:368 in public method `total_average`: D102: Missing docstring in public method torch/autograd/profiler.py:377 in public method `self_cpu_time_total`: D205: 1 blank line required between summary line and description (found 0) torch/autograd/profiler.py:377 in public method `self_cpu_time_total`: D400: First line should end with a period (not 'f') torch/autograd/profiler.py:555 in public class `record_function`: D205: 1 blank line required between summary line and description (found 0) torch/autograd/profiler.py:555 in public class `record_function`: D400: First line should end with a period (not 'f') torch/autograd/profiler.py:591 in public method `__init__`: D107: Missing docstring in __init__ torch/autograd/profiler.py:602 in public method `__enter__`: D105: Missing docstring in magic method torch/autograd/profiler.py:608 in public method `__exit__`: D105: Missing docstring in magic method torch/autograd/profiler.py:625 in private method `_call_end_callbacks_on_future`: D205: 1 blank line required between summary line and description (found 0) torch/autograd/profiler.py:625 in private method `_call_end_callbacks_on_future`: D400: First line should end with a period (not 'c') torch/autograd/profiler.py:707 in public method `__init__`: D107: Missing docstring in __init__ torch/autograd/profiler.py:712 in public method `__enter__`: D105: Missing docstring in magic method torch/autograd/profiler.py:733 in public method `__exit__`: D105: Missing docstring in magic method torch/autograd/profiler.py:826 in public method `__init__`: D107: Missing docstring in __init__ torch/autograd/profiler.py:831 in public method `__enter__`: D105: Missing docstring in magic method torch/autograd/profiler.py:853 in public method `__exit__`: D105: Missing docstring in magic method torch/autograd/profiler.py:863 in public function `load_nvprof`: D401: First line should be in imperative mood (perhaps 'Open', not 'Opens') torch/autograd/profiler.py:874 in public method `__init__`: D107: Missing docstring in __init__ torch/autograd/profiler.py:877 in public method `see`: D102: Missing docstring in public method torch/autograd/profiler.py:883 in public function `parse_nvprof_trace`: D103: Missing docstring in public function torch/autograd/profiler.py:951 in public class `KinetoStepTracker`: D205: 1 blank line required between summary line and description (found 0) torch/autograd/profiler.py:991 in public method `init_step_count`: D102: Missing docstring in public method torch/autograd/profiler.py:995 in public method `erase_step_count`: D102: Missing docstring in public method torch/autograd/profiler.py:1000 in public method `increment_step`: D205: 1 blank line required between summary line and description (found 0) torch/autograd/profiler.py:1023 in public method `current_step`: D102: Missing docstring in public method 37 ``` **After: 27** ``` torch/autograd/profiler.py:1 at module level: D100: Missing docstring in public module torch/autograd/profiler.py:176 in public method `__init__`: D107: Missing docstring in __init__ torch/autograd/profiler.py:262 in public method `config`: D102: Missing docstring in public method torch/autograd/profiler.py:273 in public method `__enter__`: D105: Missing docstring in magic method torch/autograd/profiler.py:291 in public method `__exit__`: D105: Missing docstring in magic method torch/autograd/profiler.py:309 in public method `__repr__`: D105: Missing docstring in magic method torch/autograd/profiler.py:314 in public method `__str__`: D105: Missing docstring in magic method torch/autograd/profiler.py:323 in public method `table`: D102: Missing docstring in public method torch/autograd/profiler.py:347 in public method `export_chrome_trace`: D102: Missing docstring in public method torch/autograd/profiler.py:356 in public method `export_stacks`: D102: Missing docstring in public method torch/autograd/profiler.py:362 in public method `key_averages`: D102: Missing docstring in public method torch/autograd/profiler.py:369 in public method `total_average`: D102: Missing docstring in public method torch/autograd/profiler.py:593 in public method `__init__`: D107: Missing docstring in __init__ torch/autograd/profiler.py:604 in public method `__enter__`: D105: Missing docstring in magic method torch/autograd/profiler.py:610 in public method `__exit__`: D105: Missing docstring in magic method torch/autograd/profiler.py:708 in public method `__init__`: D107: Missing docstring in __init__ torch/autograd/profiler.py:713 in public method `__enter__`: D105: Missing docstring in magic method torch/autograd/profiler.py:734 in public method `__exit__`: D105: Missing docstring in magic method torch/autograd/profiler.py:827 in public method `__init__`: D107: Missing docstring in __init__ torch/autograd/profiler.py:832 in public method `__enter__`: D105: Missing docstring in magic method torch/autograd/profiler.py:854 in public method `__exit__`: D105: Missing docstring in magic method torch/autograd/profiler.py:875 in public method `__init__`: D107: Missing docstring in __init__ torch/autograd/profiler.py:878 in public method `see`: D102: Missing docstring in public method torch/autograd/profiler.py:884 in public function `parse_nvprof_trace`: D103: Missing docstring in public function torch/autograd/profiler.py:993 in public method `init_step_count`: D102: Missing docstring in public method torch/autograd/profiler.py:997 in public method `erase_step_count`: D102: Missing docstring in public method torch/autograd/profiler.py:1025 in public method `current_step`: D102: Missing docstring in public method 27 ``` - `torch/autograd/graph.py` </br> **Before: 22** ``` torch/autograd/graph.py:1 at module level: D100: Missing docstring in public module torch/autograd/graph.py:24 in public class `Node`: D101: Missing docstring in public class torch/autograd/graph.py:27 in public method `name`: D401: First line should be in imperative mood (perhaps 'Return', not 'Returns') torch/autograd/graph.py:42 in public method `next_functions`: D102: Missing docstring in public method torch/autograd/graph.py:47 in public method `metadata`: D401: First line should be in imperative mood (perhaps 'Return', not 'Returns') torch/autograd/graph.py:56 in public method `register_hook`: D401: First line should be in imperative mood (perhaps 'Register', not 'Registers') torch/autograd/graph.py:94 in public method `register_prehook`: D401: First line should be in imperative mood (perhaps 'Register', not 'Registers') torch/autograd/graph.py:129 in public method `__subclasshook__`: D105: Missing docstring in magic method torch/autograd/graph.py:147 in public function `get_gradient_edge`: D205: 1 blank line required between summary line and description (found 0) torch/autograd/graph.py:147 in public function `get_gradient_edge`: D400: First line should end with a period (not 'f') torch/autograd/graph.py:147 in public function `get_gradient_edge`: D401: First line should be in imperative mood; try rephrasing (found 'This') torch/autograd/graph.py:166 in public function `increment_version`: D205: 1 blank line required between summary line and description (found 0) torch/autograd/graph.py:166 in public function `increment_version`: D400: First line should end with a period (not 'd') torch/autograd/graph.py:166 in public function `increment_version`: D401: First line should be in imperative mood; try rephrasing (found 'This') torch/autograd/graph.py:243 in public method `__init__`: D107: Missing docstring in __init__ torch/autograd/graph.py:251 in public method `__enter__`: D105: Missing docstring in magic method torch/autograd/graph.py:256 in public method `__exit__`: D105: Missing docstring in magic method torch/autograd/graph.py:261 in public class `save_on_cpu`: D205: 1 blank line required between summary line and description (found 0) torch/autograd/graph.py:261 in public class `save_on_cpu`: D400: First line should end with a period (not 'e') torch/autograd/graph.py:303 in public method `__init__`: D107: Missing docstring in __init__ torch/autograd/graph.py:365 in public function `register_multi_grad_hook`: D401: First line should be in imperative mood (perhaps 'Register', not 'Registers') torch/autograd/graph.py:588 in public function `allow_mutation_on_saved_tensors`: D400: First line should end with a period (not 'd') 22 ``` **After: 8** ``` torch/autograd/graph.py:1 at module level: D100: Missing docstring in public module torch/autograd/graph.py:24 in public class `Node`: D101: Missing docstring in public class torch/autograd/graph.py:42 in public method `next_functions`: D102: Missing docstring in public method torch/autograd/graph.py:129 in public method `__subclasshook__`: D105: Missing docstring in magic method torch/autograd/graph.py:244 in public method `__init__`: D107: Missing docstring in __init__ torch/autograd/graph.py:252 in public method `__enter__`: D105: Missing docstring in magic method torch/autograd/graph.py:257 in public method `__exit__`: D105: Missing docstring in magic method torch/autograd/graph.py:303 in public method `__init__`: D107: Missing docstring in __init__ 8 ``` - `torch/multiprocessing/pool.py` </br> **Before: 6** ``` torch/multiprocessing/pool.py:1 at module level: D100: Missing docstring in public module torch/multiprocessing/pool.py:7 in public function `clean_worker`: D103: Missing docstring in public function torch/multiprocessing/pool.py:18 in public class `Pool`: D205: 1 blank line required between summary line and description (found 0) torch/multiprocessing/pool.py:18 in public class `Pool`: D209: Multi-line docstring closing quotes should be on a separate line torch/multiprocessing/pool.py:29 in private method `_repopulate_pool`: D205: 1 blank line required between summary line and description (found 0) torch/multiprocessing/pool.py:29 in private method `_repopulate_pool`: D400: First line should end with a period (not ',') 6 ``` **After: 2** ``` torch/multiprocessing/pool.py:1 at module level: D100: Missing docstring in public module torch/multiprocessing/pool.py:7 in public function `clean_worker`: D103: Missing docstring in public function 2 ``` - `torch/multiprocessing/queue.py` </br> **Before: 11** ``` torch/multiprocessing/queue.py:1 at module level: D100: Missing docstring in public module torch/multiprocessing/queue.py:8 in public class `ConnectionWrapper`: D205: 1 blank line required between summary line and description (found 0) torch/multiprocessing/queue.py:8 in public class `ConnectionWrapper`: D209: Multi-line docstring closing quotes should be on a separate line torch/multiprocessing/queue.py:8 in public class `ConnectionWrapper`: D400: First line should end with a period (not 'o') torch/multiprocessing/queue.py:11 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/queue.py:14 in public method `send`: D102: Missing docstring in public method torch/multiprocessing/queue.py:19 in public method `recv`: D102: Missing docstring in public method torch/multiprocessing/queue.py:23 in public method `__getattr__`: D105: Missing docstring in magic method torch/multiprocessing/queue.py:29 in public class `Queue`: D101: Missing docstring in public class torch/multiprocessing/queue.py:30 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/queue.py:38 in public class `SimpleQueue`: D101: Missing docstring in public class 11 ``` **After: 8** ``` torch/multiprocessing/queue.py:1 at module level: D100: Missing docstring in public module torch/multiprocessing/queue.py:10 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/queue.py:13 in public method `send`: D102: Missing docstring in public method torch/multiprocessing/queue.py:18 in public method `recv`: D102: Missing docstring in public method torch/multiprocessing/queue.py:22 in public method `__getattr__`: D105: Missing docstring in magic method torch/multiprocessing/queue.py:28 in public class `Queue`: D101: Missing docstring in public class torch/multiprocessing/queue.py:29 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/queue.py:37 in public class `SimpleQueue`: D101: Missing docstring in public class 8 ``` - `torch/multiprocessing/reductions.py` </br> **Before: 31** ``` torch/multiprocessing/reductions.py:1 at module level: D100: Missing docstring in public module torch/multiprocessing/reductions.py:24 in public class `StorageWeakRef`: D209: Multi-line docstring closing quotes should be on a separate line torch/multiprocessing/reductions.py:31 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/reductions.py:38 in public method `from_weakref`: D102: Missing docstring in public method torch/multiprocessing/reductions.py:44 in public method `expired`: D102: Missing docstring in public method torch/multiprocessing/reductions.py:47 in public method `__del__`: D105: Missing docstring in magic method torch/multiprocessing/reductions.py:50 in public method `__hash__`: D105: Missing docstring in magic method torch/multiprocessing/reductions.py:53 in public method `__eq__`: D105: Missing docstring in magic method torch/multiprocessing/reductions.py:60 in public class `SharedCache`: D400: First line should end with a period (not 'f') torch/multiprocessing/reductions.py:62 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/reductions.py:75 in public method `get`: D102: Missing docstring in public method torch/multiprocessing/reductions.py:79 in public method `__setitem__`: D105: Missing docstring in magic method torch/multiprocessing/reductions.py:85 in public method `free_dead_references`: D102: Missing docstring in public method torch/multiprocessing/reductions.py:99 in public function `rebuild_event`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:103 in public function `reduce_event`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:108 in public function `rebuild_tensor`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:121 in public function `rebuild_cuda_tensor`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:189 in public function `reduce_tensor`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:347 in public function `rebuild_nested_tensor`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:364 in public function `reduce_nested_tensor`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:389 in public function `fd_id`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:397 in public function `storage_from_cache`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:404 in public function `rebuild_storage_fd`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:417 in public function `rebuild_storage_filename`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:437 in public function `rebuild_storage_empty`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:441 in public function `rebuild_typed_storage`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:446 in public function `reduce_typed_storage`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:450 in public function `rebuild_typed_storage_child`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:455 in public function `reduce_typed_storage_child`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:459 in public function `reduce_storage`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:488 in public function `init_reductions`: D103: Missing docstring in public function 31 ``` **After: 29** ``` torch/multiprocessing/reductions.py:1 at module level: D100: Missing docstring in public module torch/multiprocessing/reductions.py:32 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/reductions.py:39 in public method `from_weakref`: D102: Missing docstring in public method torch/multiprocessing/reductions.py:45 in public method `expired`: D102: Missing docstring in public method torch/multiprocessing/reductions.py:48 in public method `__del__`: D105: Missing docstring in magic method torch/multiprocessing/reductions.py:51 in public method `__hash__`: D105: Missing docstring in magic method torch/multiprocessing/reductions.py:54 in public method `__eq__`: D105: Missing docstring in magic method torch/multiprocessing/reductions.py:63 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/reductions.py:76 in public method `get`: D102: Missing docstring in public method torch/multiprocessing/reductions.py:80 in public method `__setitem__`: D105: Missing docstring in magic method torch/multiprocessing/reductions.py:86 in public method `free_dead_references`: D102: Missing docstring in public method torch/multiprocessing/reductions.py:100 in public function `rebuild_event`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:104 in public function `reduce_event`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:109 in public function `rebuild_tensor`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:122 in public function `rebuild_cuda_tensor`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:190 in public function `reduce_tensor`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:348 in public function `rebuild_nested_tensor`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:365 in public function `reduce_nested_tensor`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:390 in public function `fd_id`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:398 in public function `storage_from_cache`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:405 in public function `rebuild_storage_fd`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:418 in public function `rebuild_storage_filename`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:438 in public function `rebuild_storage_empty`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:442 in public function `rebuild_typed_storage`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:447 in public function `reduce_typed_storage`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:451 in public function `rebuild_typed_storage_child`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:456 in public function `reduce_typed_storage_child`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:460 in public function `reduce_storage`: D103: Missing docstring in public function torch/multiprocessing/reductions.py:489 in public function `init_reductions`: D103: Missing docstring in public function 29 ``` - `torch/multiprocessing/spawn.py` </br> **Before: 19** ``` torch/multiprocessing/spawn.py:1 at module level: D100: Missing docstring in public module torch/multiprocessing/spawn.py:11 in public class `ProcessException`: D101: Missing docstring in public class torch/multiprocessing/spawn.py:14 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/spawn.py:20 in public method `__reduce__`: D105: Missing docstring in magic method torch/multiprocessing/spawn.py:25 in public class `ProcessRaisedException`: D205: 1 blank line required between summary line and description (found 0) torch/multiprocessing/spawn.py:25 in public class `ProcessRaisedException`: D400: First line should end with a period (not 'n') torch/multiprocessing/spawn.py:30 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/spawn.py:40 in public class `ProcessExitedException`: D205: 1 blank line required between summary line and description (found 0) torch/multiprocessing/spawn.py:40 in public class `ProcessExitedException`: D400: First line should end with a period (not 'l') torch/multiprocessing/spawn.py:47 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/spawn.py:59 in public method `__reduce__`: D105: Missing docstring in magic method torch/multiprocessing/spawn.py:85 in public class `ProcessContext`: D101: Missing docstring in public class torch/multiprocessing/spawn.py:86 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/spawn.py:93 in public method `pids`: D102: Missing docstring in public method torch/multiprocessing/spawn.py:97 in public method `join`: D205: 1 blank line required between summary line and description (found 0) torch/multiprocessing/spawn.py:97 in public method `join`: D401: First line should be in imperative mood (perhaps 'Try', not 'Tries') torch/multiprocessing/spawn.py:166 in public class `SpawnContext`: D101: Missing docstring in public class torch/multiprocessing/spawn.py:167 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/spawn.py:180 in public function `start_processes`: D103: Missing docstring in public function 19 ``` **After: 13** ``` torch/multiprocessing/spawn.py:1 at module level: D100: Missing docstring in public module torch/multiprocessing/spawn.py:11 in public class `ProcessException`: D101: Missing docstring in public class torch/multiprocessing/spawn.py:14 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/spawn.py:20 in public method `__reduce__`: D105: Missing docstring in magic method torch/multiprocessing/spawn.py:27 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/spawn.py:41 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/spawn.py:53 in public method `__reduce__`: D105: Missing docstring in magic method torch/multiprocessing/spawn.py:79 in public class `ProcessContext`: D101: Missing docstring in public class torch/multiprocessing/spawn.py:80 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/spawn.py:87 in public method `pids`: D102: Missing docstring in public method torch/multiprocessing/spawn.py:161 in public class `SpawnContext`: D101: Missing docstring in public class torch/multiprocessing/spawn.py:162 in public method `__init__`: D107: Missing docstring in __init__ torch/multiprocessing/spawn.py:175 in public function `start_processes`: D103: Missing docstring in public function 13 ``` - `torch/multiprocessing/__init__.py` </br> **Before: 0** ``` torch/multiprocessing/__init__.py:1 at module level: D205: 1 blank line required between summary line and description (found 0) torch/multiprocessing/__init__.py:1 at module level: D400: First line should end with a period (not '`') torch/multiprocessing/__init__.py:57 in public function `set_sharing_strategy`: D401: First line should be in imperative mood (perhaps 'Set', not 'Sets') torch/multiprocessing/__init__.py:69 in public function `get_sharing_strategy`: D401: First line should be in imperative mood (perhaps 'Return', not 'Returns') torch/multiprocessing/__init__.py:74 in public function `get_all_sharing_strategies`: D401: First line should be in imperative mood (perhaps 'Return', not 'Returns') 5 ``` **After: 0** - `torch/nn/__init__.py` </br> **Before: 3** ``` torch/nn/__init__.py:1 at module level: D104: Missing docstring in public package torch/nn/__init__.py:14 in public function `factory_kwargs`: D205: 1 blank line required between summary line and description (found 0) torch/nn/__init__.py:14 in public function `factory_kwargs`: D400: First line should end with a period (not 'd') 3 ``` **After: 1** ``` torch/nn/__init__.py:1 at module level: D104: Missing docstring in public package 1 ``` - `torch/nn/cpp.py` </br> **Before: 16** ``` torch/nn/cpp.py:7 in public class `OrderedDictWrapper`: D205: 1 blank line required between summary line and description (found 0) torch/nn/cpp.py:7 in public class `OrderedDictWrapper`: D400: First line should end with a period (not 'e') torch/nn/cpp.py:16 in public method `__init__`: D107: Missing docstring in __init__ torch/nn/cpp.py:21 in public method `cpp_dict`: D102: Missing docstring in public method torch/nn/cpp.py:27 in public method `items`: D102: Missing docstring in public method torch/nn/cpp.py:30 in public method `keys`: D102: Missing docstring in public method torch/nn/cpp.py:33 in public method `values`: D102: Missing docstring in public method torch/nn/cpp.py:36 in public method `__iter__`: D105: Missing docstring in magic method torch/nn/cpp.py:39 in public method `__len__`: D105: Missing docstring in magic method torch/nn/cpp.py:42 in public method `__contains__`: D105: Missing docstring in magic method torch/nn/cpp.py:45 in public method `__getitem__`: D105: Missing docstring in magic method torch/nn/cpp.py:50 in public class `ModuleWrapper`: D205: 1 blank line required between summary line and description (found 0) torch/nn/cpp.py:50 in public class `ModuleWrapper`: D400: First line should end with a period (not 'd') torch/nn/cpp.py:55 in public method `__init__`: D107: Missing docstring in __init__ torch/nn/cpp.py:83 in public method `training`: D102: Missing docstring in public method torch/nn/cpp.py:90 in public method `__repr__`: D105: Missing docstring in magic method 16 ``` **After: 12** ``` torch/nn/cpp.py:16 in public method `__init__`: D107: Missing docstring in __init__ torch/nn/cpp.py:21 in public method `cpp_dict`: D102: Missing docstring in public method torch/nn/cpp.py:27 in public method `items`: D102: Missing docstring in public method torch/nn/cpp.py:30 in public method `keys`: D102: Missing docstring in public method torch/nn/cpp.py:33 in public method `values`: D102: Missing docstring in public method torch/nn/cpp.py:36 in public method `__iter__`: D105: Missing docstring in magic method torch/nn/cpp.py:39 in public method `__len__`: D105: Missing docstring in magic method torch/nn/cpp.py:42 in public method `__contains__`: D105: Missing docstring in magic method torch/nn/cpp.py:45 in public method `__getitem__`: D105: Missing docstring in magic method torch/nn/cpp.py:52 in public method `__init__`: D107: Missing docstring in __init__ torch/nn/cpp.py:80 in public method `training`: D102: Missing docstring in public method torch/nn/cpp.py:87 in public method `__repr__`: D105: Missing docstring in magic method 12 ``` - `torch/nn/grad.py` </br> **Before: 10** ``` torch/nn/grad.py:1 at module level: D400: First line should end with a period (not 'e') torch/nn/grad.py:8 in public function `conv1d_input`: D205: 1 blank line required between summary line and description (found 0) torch/nn/grad.py:8 in public function `conv1d_input`: D401: First line should be in imperative mood (perhaps 'Compute', not 'Computes') torch/nn/grad.py:40 in public function `conv1d_weight`: D401: First line should be in imperative mood (perhaps 'Compute', not 'Computes') torch/nn/grad.py:71 in public function `conv2d_input`: D205: 1 blank line required between summary line and description (found 0) torch/nn/grad.py:71 in public function `conv2d_input`: D401: First line should be in imperative mood (perhaps 'Compute', not 'Computes') torch/nn/grad.py:103 in public function `conv2d_weight`: D401: First line should be in imperative mood (perhaps 'Compute', not 'Computes') torch/nn/grad.py:134 in public function `conv3d_input`: D205: 1 blank line required between summary line and description (found 0) torch/nn/grad.py:134 in public function `conv3d_input`: D401: First line should be in imperative mood (perhaps 'Compute', not 'Computes') torch/nn/grad.py:166 in public function `conv3d_weight`: D401: First line should be in imperative mood (perhaps 'Compute', not 'Computes') 10 ``` **After: 0** - `torch/nn/parameter.py` </br> **Before: 17** ``` torch/nn/parameter.py:1 at module level: D100: Missing docstring in public module torch/nn/parameter.py:14 in public class `Parameter`: D204: 1 blank line required after class docstring (found 0) torch/nn/parameter.py:33 in public method `__new__`: D102: Missing docstring in public method torch/nn/parameter.py:54 in public method `__deepcopy__`: D105: Missing docstring in magic method torch/nn/parameter.py:62 in public method `__repr__`: D105: Missing docstring in magic method torch/nn/parameter.py:65 in public method `__reduce_ex__`: D105: Missing docstring in magic method torch/nn/parameter.py:84 in public class `UninitializedTensorMixin`: D101: Missing docstring in public class torch/nn/parameter.py:105 in public method `materialize`: D205: 1 blank line required between summary line and description (found 0) torch/nn/parameter.py:125 in public method `shape`: D102: Missing docstring in public method torch/nn/parameter.py:132 in public method `share_memory_`: D102: Missing docstring in public method torch/nn/parameter.py:138 in public method `__repr__`: D105: Missing docstring in magic method torch/nn/parameter.py:141 in public method `__reduce_ex__`: D105: Missing docstring in magic method torch/nn/parameter.py:149 in public method `__torch_function__`: D105: Missing docstring in magic method torch/nn/parameter.py:164 in public function `is_lazy`: D103: Missing docstring in public function torch/nn/parameter.py:186 in public method `__new__`: D102: Missing docstring in public method torch/nn/parameter.py:191 in public method `__deepcopy__`: D105: Missing docstring in magic method torch/nn/parameter.py:217 in public method `__new__`: D102: Missing docstring in public method 17 ``` **After: 15** ``` torch/nn/parameter.py:1 at module level: D100: Missing docstring in public module torch/nn/parameter.py:34 in public method `__new__`: D102: Missing docstring in public method torch/nn/parameter.py:55 in public method `__deepcopy__`: D105: Missing docstring in magic method torch/nn/parameter.py:63 in public method `__repr__`: D105: Missing docstring in magic method torch/nn/parameter.py:66 in public method `__reduce_ex__`: D105: Missing docstring in magic method torch/nn/parameter.py:85 in public class `UninitializedTensorMixin`: D101: Missing docstring in public class torch/nn/parameter.py:127 in public method `shape`: D102: Missing docstring in public method torch/nn/parameter.py:134 in public method `share_memory_`: D102: Missing docstring in public method torch/nn/parameter.py:140 in public method `__repr__`: D105: Missing docstring in magic method torch/nn/parameter.py:143 in public method `__reduce_ex__`: D105: Missing docstring in magic method torch/nn/parameter.py:151 in public method `__torch_function__`: D105: Missing docstring in magic method torch/nn/parameter.py:166 in public function `is_lazy`: D103: Missing docstring in public function torch/nn/parameter.py:188 in public method `__new__`: D102: Missing docstring in public method torch/nn/parameter.py:193 in public method `__deepcopy__`: D105: Missing docstring in magic method torch/nn/parameter.py:219 in public method `__new__`: D102: Missing docstring in public method 15 ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/113052 Approved by: https://github.com/mikaylagawarecki, https://github.com/soulitzer
PyTorch is a Python package that provides two high-level features:
You can reuse your favorite Python packages such as NumPy, SciPy, and Cython to extend PyTorch when needed.
Our trunk health (Continuous Integration signals) can be found at hud.pytorch.org.
At a granular level, PyTorch is a library that consists of the following components:
Component | Description |
---|---|
torch | A Tensor library like NumPy, with strong GPU support |
torch.autograd | A tape-based automatic differentiation library that supports all differentiable Tensor operations in torch |
torch.jit | A compilation stack (TorchScript) to create serializable and optimizable models from PyTorch code |
torch.nn | A neural networks library deeply integrated with autograd designed for maximum flexibility |
torch.multiprocessing | Python multiprocessing, but with magical memory sharing of torch Tensors across processes. Useful for data loading and Hogwild training |
torch.utils | DataLoader and other utility functions for convenience |
Usually, PyTorch is used either as:
Elaborating Further:
If you use NumPy, then you have used Tensors (a.k.a. ndarray).
PyTorch provides Tensors that can live either on the CPU or the GPU and accelerates the computation by a huge amount.
We provide a wide variety of tensor routines to accelerate and fit your scientific computation needs such as slicing, indexing, mathematical operations, linear algebra, reductions. And they are fast!
PyTorch has a unique way of building neural networks: using and replaying a tape recorder.
Most frameworks such as TensorFlow, Theano, Caffe, and CNTK have a static view of the world. One has to build a neural network and reuse the same structure again and again. Changing the way the network behaves means that one has to start from scratch.
With PyTorch, we use a technique called reverse-mode auto-differentiation, which allows you to change the way your network behaves arbitrarily with zero lag or overhead. Our inspiration comes from several research papers on this topic, as well as current and past work such as torch-autograd, autograd, Chainer, etc.
While this technique is not unique to PyTorch, it's one of the fastest implementations of it to date. You get the best of speed and flexibility for your crazy research.
PyTorch is not a Python binding into a monolithic C++ framework. It is built to be deeply integrated into Python. You can use it naturally like you would use NumPy / SciPy / scikit-learn etc. You can write your new neural network layers in Python itself, using your favorite libraries and use packages such as Cython and Numba. Our goal is to not reinvent the wheel where appropriate.
PyTorch is designed to be intuitive, linear in thought, and easy to use. When you execute a line of code, it gets executed. There isn't an asynchronous view of the world. When you drop into a debugger or receive error messages and stack traces, understanding them is straightforward. The stack trace points to exactly where your code was defined. We hope you never spend hours debugging your code because of bad stack traces or asynchronous and opaque execution engines.
PyTorch has minimal framework overhead. We integrate acceleration libraries such as Intel MKL and NVIDIA (cuDNN, NCCL) to maximize speed. At the core, its CPU and GPU Tensor and neural network backends are mature and have been tested for years.
Hence, PyTorch is quite fast — whether you run small or large neural networks.
The memory usage in PyTorch is extremely efficient compared to Torch or some of the alternatives. We've written custom memory allocators for the GPU to make sure that your deep learning models are maximally memory efficient. This enables you to train bigger deep learning models than before.
Writing new neural network modules, or interfacing with PyTorch's Tensor API was designed to be straightforward and with minimal abstractions.
You can write new neural network layers in Python using the torch API or your favorite NumPy-based libraries such as SciPy.
If you want to write your layers in C/C++, we provide a convenient extension API that is efficient and with minimal boilerplate. No wrapper code needs to be written. You can see a tutorial here and an example here.
Commands to install binaries via Conda or pip wheels are on our website: https://pytorch.org/get-started/locally/
Python wheels for NVIDIA's Jetson Nano, Jetson TX1/TX2, Jetson Xavier NX/AGX, and Jetson AGX Orin are provided here and the L4T container is published here
They require JetPack 4.2 and above, and @dusty-nv and @ptrblck are maintaining them.
If you are installing from source, you will need:
We highly recommend installing an Anaconda environment. You will get a high-quality BLAS library (MKL) and you get controlled dependency versions regardless of your Linux distro.
If you want to compile with CUDA support, select a supported version of CUDA from our support matrix, then install the following:
Note: You could refer to the cuDNN Support Matrix for cuDNN versions with the various supported CUDA, CUDA driver and NVIDIA hardware
If you want to disable CUDA support, export the environment variable USE_CUDA=0
. Other potentially useful environment variables may be found in setup.py
.
If you are building for NVIDIA's Jetson platforms (Jetson Nano, TX1, TX2, AGX Xavier), Instructions to install PyTorch for Jetson Nano are available here
If you want to compile with ROCm support, install
If you want to disable ROCm support, export the environment variable USE_ROCM=0
. Other potentially useful environment variables may be found in setup.py
.
Common
conda install cmake ninja # Run this command from the PyTorch directory after cloning the source code using the “Get the PyTorch Source“ section below pip install -r requirements.txt
On Linux
conda install mkl mkl-include # CUDA only: Add LAPACK support for the GPU if needed conda install -c pytorch magma-cuda110 # or the magma-cuda* that matches your CUDA version from https://anaconda.org/pytorch/repo # (optional) If using torch.compile with inductor/triton, install the matching version of triton # Run from the pytorch directory after cloning make triton
On MacOS
# Add this package on intel x86 processor machines only conda install mkl mkl-include # Add these packages if torch.distributed is needed conda install pkg-config libuv
On Windows
conda install mkl mkl-include # Add these packages if torch.distributed is needed. # Distributed package support on Windows is a prototype feature and is subject to changes. conda install -c conda-forge libuv=1.39
git clone --recursive https://github.com/pytorch/pytorch cd pytorch # if you are updating an existing checkout git submodule sync git submodule update --init --recursive
On Linux
If you would like to compile PyTorch with new C++ ABI enabled, then first run this command:
export _GLIBCXX_USE_CXX11_ABI=1
If you're compiling for AMD ROCm then first run this command:
# Only run this if you're compiling for ROCm python tools/amd_build/build_amd.py
Install PyTorch
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"} python setup.py develop
Aside: If you are using Anaconda, you may experience an error caused by the linker:
build/temp.linux-x86_64-3.7/torch/csrc/stub.o: file not recognized: file format not recognized collect2: error: ld returned 1 exit status error: command 'g++' failed with exit status 1This is caused by
ld
from the Conda environment shadowing the systemld
. You should use a newer version of Python that fixes this issue. The recommended Python version is 3.8.1+.
On macOS
python3 setup.py develop
On Windows
Choose Correct Visual Studio Version.
PyTorch CI uses Visual C++ BuildTools, which come with Visual Studio Enterprise, Professional, or Community Editions. You can also install the build tools from https://visualstudio.microsoft.com/visual-cpp-build-tools/. The build tools do not come with Visual Studio Code by default.
If you want to build legacy python code, please refer to Building on legacy code and CUDA
CPU-only builds
In this mode PyTorch computations will run on your CPU, not your GPU
conda activate python setup.py develop
Note on OpenMP: The desired OpenMP implementation is Intel OpenMP (iomp). In order to link against iomp, you'll need to manually download the library and set up the building environment by tweaking CMAKE_INCLUDE_PATH
and LIB
. The instruction here is an example for setting up both MKL and Intel OpenMP. Without these configurations for CMake, Microsoft Visual C OpenMP runtime (vcomp) will be used.
CUDA based build
In this mode PyTorch computations will leverage your GPU via CUDA for faster number crunching
NVTX is needed to build Pytorch with CUDA. NVTX is a part of CUDA distributive, where it is called “Nsight Compute”. To install it onto an already installed CUDA run CUDA installation once again and check the corresponding checkbox. Make sure that CUDA with Nsight Compute is installed after Visual Studio.
Currently, VS 2017 / 2019, and Ninja are supported as the generator of CMake. If ninja.exe
is detected in PATH
, then Ninja will be used as the default generator, otherwise, it will use VS 2017 / 2019.
If Ninja is selected as the generator, the latest MSVC will get selected as the underlying toolchain.
Additional libraries such as Magma, oneDNN, a.k.a. MKLDNN or DNNL, and Sccache are often needed. Please refer to the installation-helper to install them.
You can refer to the build_pytorch.bat script for some other environment variables configurations
cmd :: Set the environment variables after you have downloaded and unzipped the mkl package, :: else CMake would throw an error as `Could NOT find OpenMP`. set CMAKE_INCLUDE_PATH={Your directory}\mkl\include set LIB={Your directory}\mkl\lib;%LIB% :: Read the content in the previous section carefully before you proceed. :: [Optional] If you want to override the underlying toolset used by Ninja and Visual Studio with CUDA, please run the following script block. :: "Visual Studio 2019 Developer Command Prompt" will be run automatically. :: Make sure you have CMake >= 3.12 before you do this when you use the Visual Studio generator. set CMAKE_GENERATOR_TOOLSET_VERSION=14.27 set DISTUTILS_USE_SDK=1 for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version [15^,17^) -products * -latest -property installationPath`) do call "%i\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=%CMAKE_GENERATOR_TOOLSET_VERSION% :: [Optional] If you want to override the CUDA host compiler set CUDAHOSTCXX=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64\cl.exe python setup.py develop
You can adjust the configuration of cmake variables optionally (without building first), by doing the following. For example, adjusting the pre-detected directories for CuDNN or BLAS can be done with such a step.
On Linux
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"} python setup.py build --cmake-only ccmake build # or cmake-gui build
On macOS
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"} MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py build --cmake-only ccmake build # or cmake-gui build
You can also pull a pre-built docker image from Docker Hub and run with docker v19.03+
docker run --gpus all --rm -ti --ipc=host pytorch/pytorch:latest
Please note that PyTorch uses shared memory to share data between processes, so if torch multiprocessing is used (e.g. for multithreaded data loaders) the default shared memory segment size that container runs with is not enough, and you should increase shared memory size either with --ipc=host
or --shm-size
command line options to nvidia-docker run
.
NOTE: Must be built with a docker version > 18.06
The Dockerfile
is supplied to build images with CUDA 11.1 support and cuDNN v8. You can pass PYTHON_VERSION=x.y
make variable to specify which Python version is to be used by Miniconda, or leave it unset to use the default.
make -f docker.Makefile # images are tagged as docker.io/${your_docker_username}/pytorch
You can also pass the CMAKE_VARS="..."
environment variable to specify additional CMake variables to be passed to CMake during the build. See setup.py for the list of available variables.
CMAKE_VARS="BUILD_CAFFE2=ON BUILD_CAFFE2_OPS=ON" make -f docker.Makefile
To build documentation in various formats, you will need Sphinx and the readthedocs theme.
cd docs/ pip install -r requirements.txt
You can then build the documentation by running make <format>
from the docs/
folder. Run make
to get a list of all available output formats.
If you get a katex error run npm install katex
. If it persists, try npm install -g katex
Note: if you installed
nodejs
with a different package manager (e.g.,conda
) thennpm
will probably install a version ofkatex
that is not compatible with your version ofnodejs
and doc builds will fail. A combination of versions that is known to work isnode@6.13.1
andkatex@0.13.18
. To install the latter withnpm
you can runnpm install -g katex@0.13.18
Installation instructions and binaries for previous PyTorch versions may be found on our website.
Three-pointers to get you started:
Typically, PyTorch has three minor releases a year. Please let us know if you encounter a bug by filing an issue.
We appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion.
If you plan to contribute new features, utility functions, or extensions to the core, please first open an issue and discuss the feature with us. Sending a PR without discussion might end up resulting in a rejected PR because we might be taking the core in a different direction than you might be aware of.
To learn more about making a contribution to Pytorch, please see our Contribution page. For more information about PyTorch releases, see Release page.
PyTorch is a community-driven project with several skillful engineers and researchers contributing to it.
PyTorch is currently maintained by Soumith Chintala, Gregory Chanan, Dmytro Dzhulgakov, Edward Yang, and Nikita Shulga with major contributions coming from hundreds of talented individuals in various forms and means. A non-exhaustive but growing list needs to mention: Trevor Killeen, Sasank Chilamkurthy, Sergey Zagoruyko, Adam Lerer, Francisco Massa, Alykhan Tejani, Luca Antiga, Alban Desmaison, Andreas Koepf, James Bradbury, Zeming Lin, Yuandong Tian, Guillaume Lample, Marat Dukhan, Natalia Gimelshein, Christian Sarofeen, Martin Raison, Edward Yang, Zachary Devito.
Note: This project is unrelated to hughperkins/pytorch with the same name. Hugh is a valuable contributor to the Torch community and has helped with many things Torch and PyTorch.
PyTorch has a BSD-style license, as found in the LICENSE file.