Upload folder using huggingface_hub (part 20)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +45 -0
- .venv/lib/python3.12/site-packages/thop/__pycache__/utils.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/thop/profile.py +441 -0
- .venv/lib/python3.12/site-packages/thop/rnn_hooks.py +179 -0
- .venv/lib/python3.12/site-packages/thop/utils.py +48 -0
- .venv/lib/python3.12/site-packages/thop/vision/__init__.py +1 -0
- .venv/lib/python3.12/site-packages/thop/vision/__pycache__/__init__.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/thop/vision/__pycache__/basic_hooks.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/thop/vision/__pycache__/calc_func.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/thop/vision/basic_hooks.py +205 -0
- .venv/lib/python3.12/site-packages/thop/vision/calc_func.py +53 -0
- .venv/lib/python3.12/site-packages/torch/_C.cpython-312-x86_64-linux-gnu.so +0 -0
- .venv/lib/python3.12/site-packages/torch/_C/_VariableFunctions.pyi +0 -0
- .venv/lib/python3.12/site-packages/torch/_C/__init__.pyi +0 -0
- .venv/lib/python3.12/site-packages/torch/_C/_acc/__init__.pyi +15 -0
- .venv/lib/python3.12/site-packages/torch/_C/_aoti.pyi +183 -0
- .venv/lib/python3.12/site-packages/torch/_C/_autograd.pyi +167 -0
- .venv/lib/python3.12/site-packages/torch/_C/_cpu.pyi +8 -0
- .venv/lib/python3.12/site-packages/torch/_C/_cudnn.pyi +14 -0
- .venv/lib/python3.12/site-packages/torch/_C/_cusparselt.pyi +1 -0
- .venv/lib/python3.12/site-packages/torch/_C/_distributed.pyi +21 -0
- .venv/lib/python3.12/site-packages/torch/_C/_distributed_autograd.pyi +26 -0
- .venv/lib/python3.12/site-packages/torch/_C/_distributed_c10d.pyi +1184 -0
- .venv/lib/python3.12/site-packages/torch/_C/_distributed_rpc.pyi +188 -0
- .venv/lib/python3.12/site-packages/torch/_C/_distributed_rpc_testing.pyi +32 -0
- .venv/lib/python3.12/site-packages/torch/_C/_dynamo/__init__.pyi +72 -0
- .venv/lib/python3.12/site-packages/torch/_C/_dynamo/compiled_autograd.pyi +13 -0
- .venv/lib/python3.12/site-packages/torch/_C/_dynamo/eval_frame.pyi +106 -0
- .venv/lib/python3.12/site-packages/torch/_C/_dynamo/guards.pyi +519 -0
- .venv/lib/python3.12/site-packages/torch/_C/_export/__init__.pyi +9 -0
- .venv/lib/python3.12/site-packages/torch/_C/_export/pt2_archive_constants.pyi +26 -0
- .venv/lib/python3.12/site-packages/torch/_C/_functionalization.pyi +16 -0
- .venv/lib/python3.12/site-packages/torch/_C/_functions.pyi +22 -0
- .venv/lib/python3.12/site-packages/torch/_C/_functorch.pyi +102 -0
- .venv/lib/python3.12/site-packages/torch/_C/_instruction_counter.pyi +4 -0
- .venv/lib/python3.12/site-packages/torch/_C/_itt.pyi +5 -0
- .venv/lib/python3.12/site-packages/torch/_C/_jit_tree_views.pyi +200 -0
- .venv/lib/python3.12/site-packages/torch/_C/_lazy.pyi +26 -0
- .venv/lib/python3.12/site-packages/torch/_C/_lazy_ts_backend.pyi +12 -0
- .venv/lib/python3.12/site-packages/torch/_C/_monitor.pyi +58 -0
- .venv/lib/python3.12/site-packages/torch/_C/_nn.pyi +347 -0
- .venv/lib/python3.12/site-packages/torch/_C/_nvtx.pyi +9 -0
- .venv/lib/python3.12/site-packages/torch/_C/_onnx.pyi +39 -0
- .venv/lib/python3.12/site-packages/torch/_C/_profiler.pyi +353 -0
- .venv/lib/python3.12/site-packages/torch/_C/_verbose.pyi +3 -0
- .venv/lib/python3.12/site-packages/torch/_C_flatbuffer/__init__.pyi +11 -0
- .venv/lib/python3.12/site-packages/torch/_VF.py +31 -0
- .venv/lib/python3.12/site-packages/torch/_VF.pyi +0 -0
- .venv/lib/python3.12/site-packages/torch/__config__.py +22 -0
- .venv/lib/python3.12/site-packages/torch/__future__.py +75 -0
.gitattributes
CHANGED
|
@@ -500,3 +500,48 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 500 |
.venv/lib/python3.12/site-packages/sympy/utilities/tests/__pycache__/test_lambdify.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 501 |
.venv/lib/python3.12/site-packages/sympy/utilities/tests/__pycache__/test_wester.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 502 |
.venv/lib/python3.12/site-packages/tests/__pycache__/test_python.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 500 |
.venv/lib/python3.12/site-packages/sympy/utilities/tests/__pycache__/test_lambdify.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 501 |
.venv/lib/python3.12/site-packages/sympy/utilities/tests/__pycache__/test_wester.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 502 |
.venv/lib/python3.12/site-packages/tests/__pycache__/test_python.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 503 |
+
.venv/lib/python3.12/site-packages/torch/__pycache__/__init__.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 504 |
+
.venv/lib/python3.12/site-packages/torch/__pycache__/_meta_registrations.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 505 |
+
.venv/lib/python3.12/site-packages/torch/__pycache__/_tensor_docs.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 506 |
+
.venv/lib/python3.12/site-packages/torch/__pycache__/_torch_docs.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 507 |
+
.venv/lib/python3.12/site-packages/torch/__pycache__/overrides.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 508 |
+
.venv/lib/python3.12/site-packages/torch/_decomp/__pycache__/decompositions.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 509 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/convert_frame.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 510 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/eval_frame.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 511 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/guards.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 512 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/output_graph.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 513 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/symbolic_convert.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 514 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/trace_rules.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 515 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/utils.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 516 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/base.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 517 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/builder.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 518 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/builtin.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 519 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/functions.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 520 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/higher_order_ops.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 521 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/lists.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 522 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/misc.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 523 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/tensor.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 524 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/torch.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 525 |
+
.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/user_defined.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 526 |
+
.venv/lib/python3.12/site-packages/torch/_export/serde/__pycache__/serialize.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 527 |
+
.venv/lib/python3.12/site-packages/torch/_functorch/__pycache__/partitioners.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 528 |
+
.venv/lib/python3.12/site-packages/torch/_functorch/_aot_autograd/__pycache__/runtime_wrappers.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 529 |
+
.venv/lib/python3.12/site-packages/torch/_higher_order_ops/__pycache__/triton_kernel_wrap.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 530 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/__pycache__/codecache.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 531 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/__pycache__/compile_fx.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 532 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/__pycache__/cpp_builder.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 533 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/__pycache__/cudagraph_trees.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 534 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/__pycache__/graph.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 535 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/__pycache__/ir.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 536 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/__pycache__/lowering.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 537 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/__pycache__/pattern_matcher.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 538 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/__pycache__/scheduler.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 539 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/__pycache__/select_algorithm.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 540 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/__pycache__/utils.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 541 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/codegen/__pycache__/common.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 542 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/codegen/__pycache__/cpp.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 543 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/codegen/__pycache__/cpp_wrapper_cpu.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 544 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/codegen/__pycache__/pallas.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 545 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/codegen/__pycache__/simd.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 546 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/codegen/__pycache__/triton.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 547 |
+
.venv/lib/python3.12/site-packages/torch/_inductor/codegen/__pycache__/wrapper.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
.venv/lib/python3.12/site-packages/thop/__pycache__/utils.cpython-312.pyc
ADDED
|
Binary file (1.91 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/thop/profile.py
ADDED
|
@@ -0,0 +1,441 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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m,
|
| 9 |
+
count_lstm_cell,
|
| 10 |
+
count_rnn,
|
| 11 |
+
count_rnn_cell,
|
| 12 |
+
torch,
|
| 13 |
+
)
|
| 14 |
+
from thop.vision.basic_hooks import (
|
| 15 |
+
count_adap_avgpool,
|
| 16 |
+
count_avgpool,
|
| 17 |
+
count_bilinear,
|
| 18 |
+
count_convNd,
|
| 19 |
+
count_convtNd,
|
| 20 |
+
count_embedding,
|
| 21 |
+
count_linear,
|
| 22 |
+
count_multihead_attention,
|
| 23 |
+
count_normalization,
|
| 24 |
+
count_prelu,
|
| 25 |
+
count_softmax,
|
| 26 |
+
count_upsample,
|
| 27 |
+
logging,
|
| 28 |
+
nn,
|
| 29 |
+
zero_ops,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
from .utils import prRed
|
| 33 |
+
from .vision.calc_func import calculate_parameters
|
| 34 |
+
|
| 35 |
+
default_dtype = torch.float64
|
| 36 |
+
|
| 37 |
+
# torch>=2.0
|
| 38 |
+
_HOOK_TAKES_KWARGS = "with_kwargs" in inspect.signature(nn.Module.register_forward_hook).parameters
|
| 39 |
+
|
| 40 |
+
register_hooks = {
|
| 41 |
+
# the padding and dropout families through the private base each shares, as the norm families below
|
| 42 |
+
# need for the same reason: naming the two concrete classes left their 10 siblings rule-less, so
|
| 43 |
+
# report_missing warned about layers that have nothing to count and taught the reader to ignore it
|
| 44 |
+
nn.modules.padding._ConstantPadNd: zero_ops, # padding does not involve any multiplication
|
| 45 |
+
nn.modules.padding._ReflectionPadNd: zero_ops,
|
| 46 |
+
nn.modules.padding._ReplicationPadNd: zero_ops,
|
| 47 |
+
nn.modules.dropout._DropoutNd: zero_ops,
|
| 48 |
+
nn.Conv1d: count_convNd,
|
| 49 |
+
nn.Conv2d: count_convNd,
|
| 50 |
+
nn.Conv3d: count_convNd,
|
| 51 |
+
nn.ConvTranspose1d: count_convtNd,
|
| 52 |
+
nn.ConvTranspose2d: count_convtNd,
|
| 53 |
+
nn.ConvTranspose3d: count_convtNd,
|
| 54 |
+
# the batch- and instance-norm families through the base they share, which count_normalization is
|
| 55 |
+
# already annotated for. A lazy norm needs the base: LazyBatchNorm2d derives from _BatchNorm, not
|
| 56 |
+
# from BatchNorm2d, so its concrete counterpart is a sibling and never appears in its MRO.
|
| 57 |
+
nn.modules.batchnorm._NormBase: count_normalization,
|
| 58 |
+
nn.LayerNorm: count_normalization,
|
| 59 |
+
nn.GroupNorm: count_normalization,
|
| 60 |
+
nn.PReLU: count_prelu,
|
| 61 |
+
# The softmax family shares no base, so each member is registered explicitly.
|
| 62 |
+
nn.Softmax: count_softmax,
|
| 63 |
+
nn.LogSoftmax: count_softmax,
|
| 64 |
+
nn.Softmin: count_softmax,
|
| 65 |
+
nn.Softmax2d: count_softmax,
|
| 66 |
+
nn.ReLU: zero_ops,
|
| 67 |
+
nn.ReLU6: zero_ops,
|
| 68 |
+
nn.LeakyReLU: zero_ops,
|
| 69 |
+
nn.MaxPool1d: zero_ops,
|
| 70 |
+
nn.MaxPool2d: zero_ops,
|
| 71 |
+
nn.MaxPool3d: zero_ops,
|
| 72 |
+
nn.AdaptiveMaxPool1d: zero_ops,
|
| 73 |
+
nn.AdaptiveMaxPool2d: zero_ops,
|
| 74 |
+
nn.AdaptiveMaxPool3d: zero_ops,
|
| 75 |
+
nn.FractionalMaxPool2d: zero_ops, # a max pool that picks its windows randomly still only selects
|
| 76 |
+
nn.FractionalMaxPool3d: zero_ops,
|
| 77 |
+
nn.modules.pooling._MaxUnpoolNd: zero_ops, # scattering into a larger zero tensor adds nothing
|
| 78 |
+
nn.AvgPool1d: count_avgpool,
|
| 79 |
+
nn.AvgPool2d: count_avgpool,
|
| 80 |
+
nn.AvgPool3d: count_avgpool,
|
| 81 |
+
nn.AdaptiveAvgPool1d: count_adap_avgpool,
|
| 82 |
+
nn.AdaptiveAvgPool2d: count_adap_avgpool,
|
| 83 |
+
nn.AdaptiveAvgPool3d: count_adap_avgpool,
|
| 84 |
+
nn.Linear: count_linear,
|
| 85 |
+
nn.Bilinear: count_bilinear,
|
| 86 |
+
nn.Upsample: count_upsample,
|
| 87 |
+
nn.UpsamplingBilinear2d: count_upsample,
|
| 88 |
+
nn.UpsamplingNearest2d: count_upsample,
|
| 89 |
+
nn.RNNCell: count_rnn_cell,
|
| 90 |
+
nn.GRUCell: count_gru_cell,
|
| 91 |
+
nn.LSTMCell: count_lstm_cell,
|
| 92 |
+
nn.RNN: count_rnn,
|
| 93 |
+
nn.GRU: count_gru,
|
| 94 |
+
nn.LSTM: count_lstm,
|
| 95 |
+
# containers hold children and compute nothing themselves; they share no base but nn.Module.
|
| 96 |
+
nn.Sequential: zero_ops,
|
| 97 |
+
nn.ModuleList: zero_ops,
|
| 98 |
+
nn.ModuleDict: zero_ops,
|
| 99 |
+
nn.ParameterList: zero_ops,
|
| 100 |
+
nn.ParameterDict: zero_ops,
|
| 101 |
+
# layers that only move elements around: a view, a re-index or a permutation reads and writes each
|
| 102 |
+
# element once and multiplies nothing. The elementwise activations that also reach no rule are left
|
| 103 |
+
# warned about on purpose, because registering one asserts it is free and SiLU, Mish, GELU, GLU and
|
| 104 |
+
# Hardswish each multiply per element, so they want formulas rather than a blanket entry. nn.Fold is
|
| 105 |
+
# out because it sums OVERLAPPING blocks, and an addition per input over a window is the work
|
| 106 |
+
# count_adap_avgpool charges rather than something a view does.
|
| 107 |
+
nn.Identity: zero_ops,
|
| 108 |
+
nn.Flatten: zero_ops,
|
| 109 |
+
nn.Unflatten: zero_ops,
|
| 110 |
+
nn.Unfold: zero_ops,
|
| 111 |
+
nn.PixelShuffle: zero_ops,
|
| 112 |
+
nn.PixelUnshuffle: zero_ops,
|
| 113 |
+
nn.ChannelShuffle: zero_ops,
|
| 114 |
+
# a gather, so it belongs with the block above, but max_norm keeps it out of a blanket zero: that rescale is
|
| 115 |
+
# real work and count_embedding warns rather than assert it away, the way count_upsample does for a mode it has
|
| 116 |
+
# no cost for. nn.EmbeddingBag stays unregistered, since it really does reduce each bag and how many adds that
|
| 117 |
+
# takes is not a function of shape either: padding_idx entries drop out and repeated offsets make empty bags.
|
| 118 |
+
nn.Embedding: count_embedding,
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
if _HOOK_TAKES_KWARGS:
|
| 122 |
+
register_hooks[nn.MultiheadAttention] = count_multihead_attention
|
| 123 |
+
|
| 124 |
+
if hasattr(nn, "RMSNorm"): # torch>=2.4, and its elementwise_affine flag is one count_normalization already reads
|
| 125 |
+
register_hooks[nn.RMSNorm] = count_normalization
|
| 126 |
+
|
| 127 |
+
if hasattr(nn.modules.padding, "_CircularPadNd"): # torch>=2.1, which is where the CircularPad classes start
|
| 128 |
+
register_hooks[nn.modules.padding._CircularPadNd] = zero_ops
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def _resolve_rule(m_type, custom_ops, types_collection, verbose, report_missing):
|
| 132 |
+
"""Return the counting rule for a module type, or None when no ancestor of it carries one.
|
| 133 |
+
|
| 134 |
+
The whole MRO is walked, most derived first, so a subclass of a supported type is counted by that type's rule
|
| 135 |
+
instead of being skipped, and a lazy module resolves through the class it derives from. custom_ops is consulted
|
| 136 |
+
ahead of the built-ins at every level, so a caller's own rule still wins.
|
| 137 |
+
"""
|
| 138 |
+
first_seen = m_type not in types_collection
|
| 139 |
+
for t in m_type.__mro__:
|
| 140 |
+
if t in custom_ops: # if defined in both op maps, custom_ops overwrites
|
| 141 |
+
fn = custom_ops[t]
|
| 142 |
+
if first_seen and verbose:
|
| 143 |
+
print(f"[INFO] Customize rule {getattr(fn, '__qualname__', fn)}() {m_type}.")
|
| 144 |
+
return fn
|
| 145 |
+
if t in register_hooks:
|
| 146 |
+
fn = register_hooks[t]
|
| 147 |
+
if first_seen and verbose:
|
| 148 |
+
print(f"[INFO] Register {getattr(fn, '__qualname__', fn)}() for {m_type}.")
|
| 149 |
+
return fn
|
| 150 |
+
if first_seen and report_missing:
|
| 151 |
+
prRed(f"[WARN] Cannot find rule for {m_type}. Treat it as zero Macs.")
|
| 152 |
+
return None
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def _register_counter(m, fn, keep_result):
|
| 156 |
+
"""Register a counting hook that receives positional and keyword arguments."""
|
| 157 |
+
if _HOOK_TAKES_KWARGS:
|
| 158 |
+
|
| 159 |
+
def counter(m, args, kwargs, y, fn=fn):
|
| 160 |
+
"""Apply the counting rule to the arguments the module was called with."""
|
| 161 |
+
result = fn(m, _positional(m, args, kwargs) if kwargs else args, y)
|
| 162 |
+
return result if keep_result else None
|
| 163 |
+
|
| 164 |
+
return m.register_forward_hook(counter, with_kwargs=True)
|
| 165 |
+
|
| 166 |
+
def counter(m, args, y, fn=fn):
|
| 167 |
+
"""Apply the counting rule; this torch delivers no keyword arguments for it to be given."""
|
| 168 |
+
result = fn(m, args, y)
|
| 169 |
+
return result if keep_result else None
|
| 170 |
+
|
| 171 |
+
return m.register_forward_hook(counter)
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def _positional(m, args, kwargs):
|
| 175 |
+
"""Return supplied arguments in the order m.forward declares them."""
|
| 176 |
+
try:
|
| 177 |
+
bound = inspect.signature(m.forward).bind(*args, **kwargs)
|
| 178 |
+
except (TypeError, ValueError):
|
| 179 |
+
return ()
|
| 180 |
+
values = []
|
| 181 |
+
for name, value in bound.arguments.items():
|
| 182 |
+
kind = bound.signature.parameters[name].kind
|
| 183 |
+
if kind == inspect.Parameter.VAR_POSITIONAL:
|
| 184 |
+
values.extend(value)
|
| 185 |
+
elif kind != inspect.Parameter.VAR_KEYWORD:
|
| 186 |
+
values.append(value)
|
| 187 |
+
return tuple(values)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def _parents_first(roots):
|
| 191 |
+
"""List reachable modules with every parent before its children."""
|
| 192 |
+
order, seen = [], set()
|
| 193 |
+
|
| 194 |
+
def visit(m):
|
| 195 |
+
seen.add(m)
|
| 196 |
+
for c in m.children():
|
| 197 |
+
if c not in seen:
|
| 198 |
+
visit(c)
|
| 199 |
+
order.append(m)
|
| 200 |
+
|
| 201 |
+
for root in roots:
|
| 202 |
+
if root not in seen:
|
| 203 |
+
visit(root)
|
| 204 |
+
order.reverse()
|
| 205 |
+
return order
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
def _displace_total_ops(m):
|
| 209 |
+
"""Temporarily remove a caller-owned `total_ops` buffer or attribute; reject a name thop cannot borrow."""
|
| 210 |
+
kind = None
|
| 211 |
+
if any(hasattr(vars(c).get("total_ops"), "__set__") for c in type(m).__mro__):
|
| 212 |
+
kind = "data descriptor" # no per-instance value to displace, and the hook's writes never reach the total
|
| 213 |
+
elif "total_ops" in m._parameters:
|
| 214 |
+
kind = "parameter" # displacing it would come back as a smaller parameter count
|
| 215 |
+
elif "total_ops" in m._modules:
|
| 216 |
+
kind = "child module" # displacing it would come back as a dropped subtree
|
| 217 |
+
if kind:
|
| 218 |
+
raise TypeError(f"{m!s} owns total_ops as a {kind}; thop needs that name to profile it.")
|
| 219 |
+
displaced = [(store, store["total_ops"]) for store in (m._buffers, m.__dict__) if "total_ops" in store]
|
| 220 |
+
if displaced:
|
| 221 |
+
logging.warning(f"{m!s} already has a .total_ops; it is shadowed while profiling and restored after.")
|
| 222 |
+
for store, _ in displaced:
|
| 223 |
+
del store["total_ops"]
|
| 224 |
+
return displaced
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
def _restore_modes(prev_training):
|
| 228 |
+
"""Restore recorded modes without changing modules attached during forward."""
|
| 229 |
+
order = _parents_first(prev_training)
|
| 230 |
+
modes = {m: prev_training.get(m, m.training) for m in order} # read before the first train() call moves any
|
| 231 |
+
for m, was_training in modes.items():
|
| 232 |
+
if m.training != was_training:
|
| 233 |
+
m.train(was_training)
|
| 234 |
+
for m, was_training in modes.items():
|
| 235 |
+
m.training = was_training
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
def profile_origin(model, inputs, custom_ops=None, verbose=True, report_missing=False):
|
| 239 |
+
"""Profile a model with the legacy per-leaf-module traversal, returning total operations and parameters."""
|
| 240 |
+
handler_collection = {}
|
| 241 |
+
displaced_collection = {}
|
| 242 |
+
types_collection = set()
|
| 243 |
+
if custom_ops is None:
|
| 244 |
+
custom_ops = {}
|
| 245 |
+
if report_missing:
|
| 246 |
+
verbose = True
|
| 247 |
+
|
| 248 |
+
def add_hooks(m):
|
| 249 |
+
m_type = type(m)
|
| 250 |
+
has_own_rule = any(t in custom_ops or t in register_hooks for t in m_type.__mro__)
|
| 251 |
+
if (list(m.children()) and not has_own_rule) or m in handler_collection:
|
| 252 |
+
return
|
| 253 |
+
|
| 254 |
+
fn = _resolve_rule(m_type, custom_ops, types_collection, verbose, report_missing)
|
| 255 |
+
|
| 256 |
+
displaced = _displace_total_ops(m)
|
| 257 |
+
if displaced:
|
| 258 |
+
displaced_collection[m] = displaced
|
| 259 |
+
# register_buffer discards this flag; restore it without requiring the newer persistent= argument.
|
| 260 |
+
non_persistent = "total_ops" in m._non_persistent_buffers_set
|
| 261 |
+
m.register_buffer("total_ops", torch.zeros(1, dtype=default_dtype))
|
| 262 |
+
if non_persistent:
|
| 263 |
+
m._non_persistent_buffers_set.add("total_ops")
|
| 264 |
+
handler_collection[m] = None
|
| 265 |
+
if fn is not None and fn is not zero_ops:
|
| 266 |
+
handler_collection[m] = _register_counter(m, fn, keep_result=True) # as profile_origin always has
|
| 267 |
+
types_collection.add(m_type)
|
| 268 |
+
|
| 269 |
+
prev_training = {m: m.training for m in model.modules()}
|
| 270 |
+
|
| 271 |
+
try:
|
| 272 |
+
model.eval()
|
| 273 |
+
model.apply(add_hooks)
|
| 274 |
+
|
| 275 |
+
with torch.no_grad():
|
| 276 |
+
model(*inputs)
|
| 277 |
+
|
| 278 |
+
total_ops = 0
|
| 279 |
+
for m in handler_collection:
|
| 280 |
+
total_ops += m.total_ops
|
| 281 |
+
|
| 282 |
+
total_ops = total_ops.item()
|
| 283 |
+
total_params = float(calculate_parameters(model.parameters()))
|
| 284 |
+
finally: # no failure, at any stage, may leave behind the hooks or the buffers this call created
|
| 285 |
+
for handler in filter(None, handler_collection.values()):
|
| 286 |
+
handler.remove()
|
| 287 |
+
for m in handler_collection:
|
| 288 |
+
m._buffers.pop("total_ops", None)
|
| 289 |
+
for m, displaced in displaced_collection.items():
|
| 290 |
+
for store, value in displaced:
|
| 291 |
+
store["total_ops"] = value
|
| 292 |
+
_restore_modes(prev_training) # last: it calls train(), which is the caller's code and may raise
|
| 293 |
+
|
| 294 |
+
return total_ops, total_params
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
def profile(
|
| 298 |
+
model: nn.Module,
|
| 299 |
+
inputs,
|
| 300 |
+
custom_ops=None,
|
| 301 |
+
verbose=True,
|
| 302 |
+
ret_layer_info=False,
|
| 303 |
+
report_missing=False,
|
| 304 |
+
stride=None,
|
| 305 |
+
):
|
| 306 |
+
"""Profiles a PyTorch model, optionally estimating target-image MACs from smaller stride-aligned inputs."""
|
| 307 |
+
handler_collection = {}
|
| 308 |
+
displaced_collection = {}
|
| 309 |
+
types_collection = set()
|
| 310 |
+
if custom_ops is None:
|
| 311 |
+
custom_ops = {}
|
| 312 |
+
if report_missing:
|
| 313 |
+
# overwrite `verbose` option when enable report_missing
|
| 314 |
+
verbose = True
|
| 315 |
+
|
| 316 |
+
def add_hooks(m: nn.Module):
|
| 317 |
+
"""Registers a hook on a neural network module to track its total operations."""
|
| 318 |
+
if m in handler_collection: # model.apply() revisits modules shared by several parents, e.g. a common act
|
| 319 |
+
return
|
| 320 |
+
|
| 321 |
+
m_type = type(m)
|
| 322 |
+
fn = _resolve_rule(m_type, custom_ops, types_collection, verbose, report_missing)
|
| 323 |
+
|
| 324 |
+
displaced = _displace_total_ops(m)
|
| 325 |
+
if displaced:
|
| 326 |
+
displaced_collection[m] = displaced
|
| 327 |
+
# a plain int attribute, not a float64 buffer: buffer reads go through nn.Module.__getattr__ and every
|
| 328 |
+
# hook would allocate a tensor per call, which dominates profiling cost on module-heavy models.
|
| 329 |
+
# Written straight into __dict__ (mirroring the teardown below) to skip nn.Module.__setattr__.
|
| 330 |
+
m.__dict__["total_ops"] = 0
|
| 331 |
+
|
| 332 |
+
handler_collection[m] = None
|
| 333 |
+
if fn is not None and fn is not zero_ops:
|
| 334 |
+
handler_collection[m] = _register_counter(m, fn, keep_result=False) # never the module output
|
| 335 |
+
types_collection.add(m_type)
|
| 336 |
+
|
| 337 |
+
counted = set()
|
| 338 |
+
|
| 339 |
+
def dfs_count(module: nn.Module, prefix="\t") -> (float, dict):
|
| 340 |
+
"""Build layer details from the module tree left after forward."""
|
| 341 |
+
total_ops = float(module.__dict__.get("total_ops", 0)) if module in handler_collection else 0.0
|
| 342 |
+
ret_dict = {}
|
| 343 |
+
for n, m in module.named_children():
|
| 344 |
+
# every child is walked, whether or not it carries a rule of its own: a rule accounts for its
|
| 345 |
+
# module's own arithmetic, not for its subtree's, so the two are added rather than one replacing
|
| 346 |
+
# the other. This is what the root of the traversal has always done with its own total_ops above
|
| 347 |
+
m_ops, next_dict = dfs_count(m, prefix=prefix + "\t")
|
| 348 |
+
if ret_layer_info: # the per-layer tree is the caller's opt-in, so it is not built when discarded
|
| 349 |
+
ret_dict[n] = (m_ops, float(calculate_parameters(m.parameters())), next_dict)
|
| 350 |
+
if m in counted: # a module reached through several parents already accumulated all of its calls
|
| 351 |
+
continue
|
| 352 |
+
counted.add(m)
|
| 353 |
+
total_ops += m_ops
|
| 354 |
+
# print(prefix, module._get_name(), total_ops)
|
| 355 |
+
return total_ops, ret_dict
|
| 356 |
+
|
| 357 |
+
prev_training = {m: m.training for m in model.modules()} # per module: model.eval() below recurses
|
| 358 |
+
|
| 359 |
+
try:
|
| 360 |
+
model.eval()
|
| 361 |
+
model.apply(add_hooks)
|
| 362 |
+
|
| 363 |
+
def run(input_values):
|
| 364 |
+
"""Profile one set of inputs while reusing the registered hooks."""
|
| 365 |
+
counted.clear()
|
| 366 |
+
for m in handler_collection:
|
| 367 |
+
m.__dict__["total_ops"] = 0
|
| 368 |
+
with torch.no_grad():
|
| 369 |
+
model(*input_values)
|
| 370 |
+
# Count the executed hook record; build the surviving tree only when requested.
|
| 371 |
+
total = sum(float(m.__dict__.get("total_ops", 0)) for m in handler_collection)
|
| 372 |
+
return total, dfs_count(model)[1] if ret_layer_info else {}
|
| 373 |
+
|
| 374 |
+
if stride is None or ret_layer_info:
|
| 375 |
+
total_ops, ret_dict = run(inputs)
|
| 376 |
+
else:
|
| 377 |
+
if len(inputs) != 1 or not isinstance(inputs[0], torch.Tensor) or inputs[0].ndim != 4:
|
| 378 |
+
raise ValueError("stride requires inputs to contain one BCHW image tensor")
|
| 379 |
+
stride = (stride, stride) if isinstance(stride, int) else tuple(stride)
|
| 380 |
+
if len(stride) != 2 or min(stride) < 1:
|
| 381 |
+
raise ValueError("stride must be a positive integer or a pair of positive integers")
|
| 382 |
+
|
| 383 |
+
image = inputs[0]
|
| 384 |
+
target_height, target_width = image.shape[-2:]
|
| 385 |
+
fixed_ops = (
|
| 386 |
+
nn.Linear,
|
| 387 |
+
nn.AdaptiveAvgPool1d,
|
| 388 |
+
nn.AdaptiveAvgPool2d,
|
| 389 |
+
nn.AdaptiveAvgPool3d,
|
| 390 |
+
nn.RNNBase,
|
| 391 |
+
nn.RNNCell,
|
| 392 |
+
nn.GRUCell,
|
| 393 |
+
nn.LSTMCell,
|
| 394 |
+
)
|
| 395 |
+
required_samples = 2 if any(isinstance(m, fixed_ops) for m in model.modules()) else 1
|
| 396 |
+
samples = []
|
| 397 |
+
proxy_area = stride[0] * stride[1]
|
| 398 |
+
if (
|
| 399 |
+
# two small samples can only fit a cost that is affine in image area. Attention is quadratic in it,
|
| 400 |
+
# and a caller's own rule may be anything at all, so a model carrying either is measured directly.
|
| 401 |
+
not any(
|
| 402 |
+
isinstance(m, nn.MultiheadAttention) or any(t in custom_ops for t in type(m).__mro__)
|
| 403 |
+
for m in model.modules()
|
| 404 |
+
)
|
| 405 |
+
and target_height % stride[0] == target_width % stride[1] == 0
|
| 406 |
+
and proxy_area < target_height * target_width
|
| 407 |
+
):
|
| 408 |
+
try:
|
| 409 |
+
for width in (stride[1], stride[1] * 2)[:required_samples]:
|
| 410 |
+
ops, _ = run((image.new_empty((*image.shape[:-2], stride[0], width)),))
|
| 411 |
+
samples.append((stride[0] * width, ops))
|
| 412 |
+
except Exception:
|
| 413 |
+
samples.clear()
|
| 414 |
+
|
| 415 |
+
if len(samples) == 2:
|
| 416 |
+
(area1, ops1), (area2, ops2) = samples
|
| 417 |
+
slope = (ops2 - ops1) / (area2 - area1)
|
| 418 |
+
total_ops = slope * target_height * target_width + ops1 - slope * area1
|
| 419 |
+
ret_dict = {}
|
| 420 |
+
elif len(samples) == 1 and required_samples == 1:
|
| 421 |
+
area, ops = samples[0]
|
| 422 |
+
total_ops = ops * target_height * target_width / area
|
| 423 |
+
ret_dict = {}
|
| 424 |
+
else:
|
| 425 |
+
total_ops, ret_dict = run(inputs)
|
| 426 |
+
# Parameters belong to the module tree, not to the traced call. parameters() deduplicates shared tensors
|
| 427 |
+
# and includes unsupported or unexecuted modules.
|
| 428 |
+
total_params = float(calculate_parameters(model.parameters()))
|
| 429 |
+
finally: # no failure, at any stage, may leave behind hooks or temporary attributes
|
| 430 |
+
for handler in filter(None, handler_collection.values()):
|
| 431 |
+
handler.remove()
|
| 432 |
+
for m in handler_collection:
|
| 433 |
+
m.__dict__.pop("total_ops", None)
|
| 434 |
+
for m, displaced in displaced_collection.items():
|
| 435 |
+
for store, value in displaced:
|
| 436 |
+
store["total_ops"] = value
|
| 437 |
+
_restore_modes(prev_training) # last: it calls train(), which is the caller's code and may raise
|
| 438 |
+
|
| 439 |
+
if ret_layer_info:
|
| 440 |
+
return total_ops, total_params, ret_dict
|
| 441 |
+
return total_ops, total_params
|
.venv/lib/python3.12/site-packages/thop/rnn_hooks.py
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
from torch import nn
|
| 5 |
+
from torch.nn.utils.rnn import PackedSequence
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def _cell_evaluations(x):
|
| 9 |
+
"""Return how many cell evaluations a recurrent layer's input asks for."""
|
| 10 |
+
if isinstance(x, PackedSequence):
|
| 11 |
+
return int(x.batch_sizes.sum()) # the padded rectangle is the work packing exists to avoid
|
| 12 |
+
return x.size(0) if x.dim() == 2 else x.size(0) * x.size(1) # unbatched (L, H_in) carries no batch axis
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def _count_rnn_cell(input_size, hidden_size, bias=True):
|
| 16 |
+
"""Calculate the total operations for an RNN cell given input size, hidden size, and optional bias."""
|
| 17 |
+
total_ops = hidden_size * (input_size + hidden_size) + hidden_size
|
| 18 |
+
if bias:
|
| 19 |
+
total_ops += hidden_size * 2
|
| 20 |
+
|
| 21 |
+
return total_ops
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def count_rnn_cell(m: nn.RNNCell, x: torch.Tensor, y: torch.Tensor):
|
| 25 |
+
"""Counts the total RNN cell operations based on input tensor, hidden size, bias, and batch size."""
|
| 26 |
+
total_ops = _count_rnn_cell(m.input_size, m.hidden_size, m.bias)
|
| 27 |
+
|
| 28 |
+
# a cell takes one vector per batch entry, so a 1-dimensional input is a single unbatched sample
|
| 29 |
+
total_ops *= x[0].size(0) if x[0].dim() == 2 else 1
|
| 30 |
+
|
| 31 |
+
m.total_ops += int(total_ops)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def _count_gru_cell(input_size, hidden_size, bias=True):
|
| 35 |
+
"""Counts the total operations for a GRU cell based on input size, hidden size, and bias configuration."""
|
| 36 |
+
total_ops = 0
|
| 37 |
+
# r = \sigma(W_{ir} x + b_{ir} + W_{hr} h + b_{hr}) \\
|
| 38 |
+
# z = \sigma(W_{iz} x + b_{iz} + W_{hz} h + b_{hz}) \\
|
| 39 |
+
state_ops = (hidden_size + input_size) * hidden_size + hidden_size
|
| 40 |
+
if bias:
|
| 41 |
+
state_ops += hidden_size * 2
|
| 42 |
+
total_ops += state_ops * 2
|
| 43 |
+
|
| 44 |
+
# n = \tanh(W_{in} x + b_{in} + r * (W_{hn} h + b_{hn})) \\
|
| 45 |
+
total_ops += (hidden_size + input_size) * hidden_size + hidden_size
|
| 46 |
+
if bias:
|
| 47 |
+
total_ops += hidden_size * 2
|
| 48 |
+
# r hadamard : r * (~)
|
| 49 |
+
total_ops += hidden_size
|
| 50 |
+
|
| 51 |
+
# h' = (1 - z) * n + z * h
|
| 52 |
+
# hadamard hadamard add
|
| 53 |
+
total_ops += hidden_size * 3
|
| 54 |
+
|
| 55 |
+
return total_ops
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def count_gru_cell(m: nn.GRUCell, x: torch.Tensor, y: torch.Tensor):
|
| 59 |
+
"""Calculates and updates the total operations for a GRU cell in a mini-batch during inference."""
|
| 60 |
+
total_ops = _count_gru_cell(m.input_size, m.hidden_size, m.bias)
|
| 61 |
+
|
| 62 |
+
# a cell takes one vector per batch entry, so a 1-dimensional input is a single unbatched sample
|
| 63 |
+
total_ops *= x[0].size(0) if x[0].dim() == 2 else 1
|
| 64 |
+
|
| 65 |
+
m.total_ops += int(total_ops)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def _count_lstm_cell(input_size, hidden_size, bias=True, proj_size=0):
|
| 69 |
+
"""Counts LSTM cell operations during inference based on input size, hidden size, and bias configuration."""
|
| 70 |
+
total_ops = 0
|
| 71 |
+
real_hidden_size = proj_size or hidden_size # what the recurrent matmuls read, torch's own name for it
|
| 72 |
+
|
| 73 |
+
# i = \sigma(W_{ii} x + b_{ii} + W_{hi} h + b_{hi}) \\
|
| 74 |
+
# f = \sigma(W_{if} x + b_{if} + W_{hf} h + b_{hf}) \\
|
| 75 |
+
# o = \sigma(W_{io} x + b_{io} + W_{ho} h + b_{ho}) \\
|
| 76 |
+
# g = \tanh(W_{ig} x + b_{ig} + W_{hg} h + b_{hg}) \\
|
| 77 |
+
state_ops = (input_size + real_hidden_size) * hidden_size + hidden_size
|
| 78 |
+
if bias:
|
| 79 |
+
state_ops += hidden_size * 2
|
| 80 |
+
total_ops += state_ops * 4
|
| 81 |
+
|
| 82 |
+
# c' = f * c + i * g \\
|
| 83 |
+
# hadamard hadamard add
|
| 84 |
+
total_ops += hidden_size * 3
|
| 85 |
+
|
| 86 |
+
# h' = W_{hr} (o * \tanh(c')) \\
|
| 87 |
+
total_ops += hidden_size + hidden_size * proj_size
|
| 88 |
+
|
| 89 |
+
return total_ops
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def count_lstm_cell(m: nn.LSTMCell, x: torch.Tensor, y: torch.Tensor):
|
| 93 |
+
"""Counts and updates the total operations for an LSTM cell in a mini-batch during inference."""
|
| 94 |
+
total_ops = _count_lstm_cell(m.input_size, m.hidden_size, m.bias)
|
| 95 |
+
|
| 96 |
+
# a cell takes one vector per batch entry, so a 1-dimensional input is a single unbatched sample
|
| 97 |
+
total_ops *= x[0].size(0) if x[0].dim() == 2 else 1
|
| 98 |
+
|
| 99 |
+
m.total_ops += int(total_ops)
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def count_rnn(m: nn.RNN, x, y):
|
| 103 |
+
"""Calculate and update the total number of operations for each RNN cell in a given batch."""
|
| 104 |
+
bias = m.bias
|
| 105 |
+
input_size = m.input_size
|
| 106 |
+
hidden_size = m.hidden_size
|
| 107 |
+
num_layers = m.num_layers
|
| 108 |
+
|
| 109 |
+
evaluations = _cell_evaluations(x[0])
|
| 110 |
+
|
| 111 |
+
total_ops = 0
|
| 112 |
+
if m.bidirectional:
|
| 113 |
+
total_ops += _count_rnn_cell(input_size, hidden_size, bias) * 2
|
| 114 |
+
else:
|
| 115 |
+
total_ops += _count_rnn_cell(input_size, hidden_size, bias)
|
| 116 |
+
|
| 117 |
+
for _ in range(num_layers - 1):
|
| 118 |
+
total_ops += (
|
| 119 |
+
_count_rnn_cell(hidden_size * 2, hidden_size, bias) * 2
|
| 120 |
+
if m.bidirectional
|
| 121 |
+
else _count_rnn_cell(hidden_size, hidden_size, bias)
|
| 122 |
+
)
|
| 123 |
+
total_ops *= evaluations
|
| 124 |
+
|
| 125 |
+
m.total_ops += int(total_ops)
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def count_gru(m: nn.GRU, x, y):
|
| 129 |
+
"""Calculates total operations for a GRU layer, updating the model's operation count based on batch size."""
|
| 130 |
+
bias = m.bias
|
| 131 |
+
input_size = m.input_size
|
| 132 |
+
hidden_size = m.hidden_size
|
| 133 |
+
num_layers = m.num_layers
|
| 134 |
+
|
| 135 |
+
evaluations = _cell_evaluations(x[0])
|
| 136 |
+
|
| 137 |
+
total_ops = 0
|
| 138 |
+
if m.bidirectional:
|
| 139 |
+
total_ops += _count_gru_cell(input_size, hidden_size, bias) * 2
|
| 140 |
+
else:
|
| 141 |
+
total_ops += _count_gru_cell(input_size, hidden_size, bias)
|
| 142 |
+
|
| 143 |
+
for _ in range(num_layers - 1):
|
| 144 |
+
total_ops += (
|
| 145 |
+
_count_gru_cell(hidden_size * 2, hidden_size, bias) * 2
|
| 146 |
+
if m.bidirectional
|
| 147 |
+
else _count_gru_cell(hidden_size, hidden_size, bias)
|
| 148 |
+
)
|
| 149 |
+
total_ops *= evaluations
|
| 150 |
+
|
| 151 |
+
m.total_ops += int(total_ops)
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
def count_lstm(m: nn.LSTM, x, y):
|
| 155 |
+
"""Calculate total operations for LSTM layers, including bidirectional, updating model's total operations."""
|
| 156 |
+
bias = m.bias
|
| 157 |
+
input_size = m.input_size
|
| 158 |
+
hidden_size = m.hidden_size
|
| 159 |
+
num_layers = m.num_layers
|
| 160 |
+
proj_size = m.proj_size
|
| 161 |
+
stacked_size = proj_size or hidden_size # the width a projected layer hands the next one
|
| 162 |
+
|
| 163 |
+
evaluations = _cell_evaluations(x[0])
|
| 164 |
+
|
| 165 |
+
total_ops = 0
|
| 166 |
+
if m.bidirectional:
|
| 167 |
+
total_ops += _count_lstm_cell(input_size, hidden_size, bias, proj_size) * 2
|
| 168 |
+
else:
|
| 169 |
+
total_ops += _count_lstm_cell(input_size, hidden_size, bias, proj_size)
|
| 170 |
+
|
| 171 |
+
for _ in range(num_layers - 1):
|
| 172 |
+
total_ops += (
|
| 173 |
+
_count_lstm_cell(stacked_size * 2, hidden_size, bias, proj_size) * 2
|
| 174 |
+
if m.bidirectional
|
| 175 |
+
else _count_lstm_cell(stacked_size, hidden_size, bias, proj_size)
|
| 176 |
+
)
|
| 177 |
+
total_ops *= evaluations
|
| 178 |
+
|
| 179 |
+
m.total_ops += int(total_ops)
|
.venv/lib/python3.12/site-packages/thop/utils.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
| 2 |
+
|
| 3 |
+
from collections.abc import Iterable
|
| 4 |
+
|
| 5 |
+
COLOR_RED = "91m"
|
| 6 |
+
COLOR_GREEN = "92m"
|
| 7 |
+
COLOR_YELLOW = "93m"
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def colorful_print(fn_print, color=COLOR_RED):
|
| 11 |
+
"""A decorator to print text in the specified terminal color by wrapping the given print function."""
|
| 12 |
+
|
| 13 |
+
def actual_call(*args, **kwargs):
|
| 14 |
+
print(f"\033[{color}", end="")
|
| 15 |
+
fn_print(*args, **kwargs)
|
| 16 |
+
print("\033[00m", end="")
|
| 17 |
+
|
| 18 |
+
return actual_call
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
prRed = colorful_print(print, color=COLOR_RED)
|
| 22 |
+
prGreen = colorful_print(print, color=COLOR_GREEN)
|
| 23 |
+
prYellow = colorful_print(print, color=COLOR_YELLOW)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def clever_format(nums, format="%.2f"):
|
| 27 |
+
"""Formats numbers into human-readable strings with units (K for thousand, M for million, etc.)."""
|
| 28 |
+
if not isinstance(nums, Iterable):
|
| 29 |
+
nums = [nums]
|
| 30 |
+
clever_nums = []
|
| 31 |
+
|
| 32 |
+
for num in nums:
|
| 33 |
+
for unit, scale in (("T", 1e12), ("G", 1e9), ("M", 1e6), ("K", 1e3)):
|
| 34 |
+
# abs() and >=, not the value against >: a negative satisfied no comparison and came out unscaled,
|
| 35 |
+
# and an exact power of 1000 belongs to the unit it is one of rather than to the one below it
|
| 36 |
+
if abs(num) >= scale:
|
| 37 |
+
clever_nums.append(format % (num / scale) + unit)
|
| 38 |
+
break
|
| 39 |
+
else:
|
| 40 |
+
clever_nums.append(format % num + "B")
|
| 41 |
+
|
| 42 |
+
return clever_nums[0] if len(clever_nums) == 1 else (*clever_nums,)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
if __name__ == "__main__":
|
| 46 |
+
prRed("hello", "world")
|
| 47 |
+
prGreen("hello", "world")
|
| 48 |
+
prYellow("hello", "world")
|
.venv/lib/python3.12/site-packages/thop/vision/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
.venv/lib/python3.12/site-packages/thop/vision/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (186 Bytes). View file
|
|
|
.venv/lib/python3.12/site-packages/thop/vision/__pycache__/basic_hooks.cpython-312.pyc
ADDED
|
Binary file (10.9 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/thop/vision/__pyc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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
| 2 |
+
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
+
import torch
|
| 6 |
+
from torch import nn
|
| 7 |
+
from torch.nn.modules.conv import _ConvNd
|
| 8 |
+
|
| 9 |
+
from thop.vision.calc_func import (
|
| 10 |
+
calculate_conv2d_flops,
|
| 11 |
+
calculate_linear,
|
| 12 |
+
calculate_norm,
|
| 13 |
+
calculate_softmax,
|
| 14 |
+
calculate_zero_ops,
|
| 15 |
+
l_prod,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
multiply_adds = 1
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def zero_ops(m, x, y):
|
| 22 |
+
"""Incrementally add zero operations to the model's total operations count."""
|
| 23 |
+
m.total_ops += calculate_zero_ops()
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def count_embedding(m, x, y):
|
| 27 |
+
"""Charge nothing for an embedding gather, warning when max_norm makes that incomplete."""
|
| 28 |
+
if m.max_norm is not None: # it renormalizes only the rows the indices push over the limit, so data decides
|
| 29 |
+
logging.getLogger(__name__).warning("max_norm renormalization is not counted")
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def count_convNd(m: _ConvNd, x, y: torch.Tensor):
|
| 33 |
+
"""Calculate and add the number of convolutional operations (FLOPs) for a ConvNd layer to the model's total ops."""
|
| 34 |
+
x = x[0]
|
| 35 |
+
|
| 36 |
+
m.total_ops += calculate_conv2d_flops(
|
| 37 |
+
input_size=list(x.shape),
|
| 38 |
+
output_size=list(y.shape),
|
| 39 |
+
kernel_size=list(m.weight.shape),
|
| 40 |
+
groups=m.groups,
|
| 41 |
+
bias=m.bias,
|
| 42 |
+
transpose=False,
|
| 43 |
+
)
|
| 44 |
+
# N x Cout x H x W x (Cin x Kw x Kh + bias)
|
| 45 |
+
# m.total_ops += calculate_conv(
|
| 46 |
+
# bias_ops,
|
| 47 |
+
# torch.zeros(m.weight.size()[2:]).numel(),
|
| 48 |
+
# y.nelement(),
|
| 49 |
+
# m.in_channels,
|
| 50 |
+
# m.groups,
|
| 51 |
+
# )
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def count_convtNd(m: _ConvNd, x, y: torch.Tensor):
|
| 55 |
+
"""Calculate and add the number of convolutional operations (FLOPs) for a ConvNd layer to the model's total ops."""
|
| 56 |
+
x = x[0]
|
| 57 |
+
|
| 58 |
+
m.total_ops += calculate_conv2d_flops(
|
| 59 |
+
input_size=list(x.shape),
|
| 60 |
+
output_size=list(y.shape),
|
| 61 |
+
kernel_size=list(m.weight.shape),
|
| 62 |
+
groups=m.groups,
|
| 63 |
+
bias=m.bias,
|
| 64 |
+
transpose=True,
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def count_normalization(m: nn.modules.batchnorm._BatchNorm, x, y):
|
| 69 |
+
"""Calculate and add the FLOPs for a batch normalization layer, including elementwise and affine operations."""
|
| 70 |
+
# https://github.com/Lyken17/pytorch-OpCounter/issues/124
|
| 71 |
+
# y = (x - mean) / sqrt(eps + var) * weight + bias
|
| 72 |
+
x = x[0]
|
| 73 |
+
# bn is by default fused in inference
|
| 74 |
+
flops = calculate_norm(x.numel())
|
| 75 |
+
if getattr(m, "affine", False) or getattr(m, "elementwise_affine", False):
|
| 76 |
+
flops *= 2
|
| 77 |
+
m.total_ops += flops
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
# def count_layer_norm(m, x, y):
|
| 81 |
+
# x = x[0]
|
| 82 |
+
# m.total_ops += calculate_norm(x.numel())
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
# def count_instance_norm(m, x, y):
|
| 86 |
+
# x = x[0]
|
| 87 |
+
# m.total_ops += calculate_norm(x.numel())
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def count_prelu(m, x, y):
|
| 91 |
+
"""Calculate and update the total operation counts for a PReLU layer using input element number."""
|
| 92 |
+
x = x[0]
|
| 93 |
+
|
| 94 |
+
if not m.training:
|
| 95 |
+
m.total_ops += x.numel()
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def count_softmax(m, x, y):
|
| 99 |
+
"""Calculate and update the total operation counts for a Softmax layer in a PyTorch model."""
|
| 100 |
+
x = x[0]
|
| 101 |
+
# Softmax2d always normalizes channels, with or without a batch dimension.
|
| 102 |
+
dim = -3 if isinstance(m, nn.Softmax2d) else m.dim
|
| 103 |
+
if dim is None:
|
| 104 |
+
# Match torch's deprecated implicit dimension.
|
| 105 |
+
dim = 0 if x.dim() in {0, 1, 3} else 1
|
| 106 |
+
# a scalar normalizes over itself, which no shape entry can say: torch returns 1.0 for it, so the cost is
|
| 107 |
+
# the one exponential and the one division that produce that, and indexing the empty shape only raises
|
| 108 |
+
nfeatures = x.size()[dim] if x.dim() else 1
|
| 109 |
+
batch_size = x.numel() // nfeatures if nfeatures else 0
|
| 110 |
+
|
| 111 |
+
m.total_ops += calculate_softmax(batch_size, nfeatures)
|
| 112 |
+
if isinstance(m, nn.Softmin):
|
| 113 |
+
m.total_ops += x.numel()
|
| 114 |
+
elif isinstance(m, nn.LogSoftmax):
|
| 115 |
+
m.total_ops += batch_size
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def count_avgpool(m, x, y):
|
| 119 |
+
"""Calculate and update the total operation count for an AvgPool layer."""
|
| 120 |
+
kernel = m.kernel_size
|
| 121 |
+
if isinstance(kernel, int): # only AvgPool2d and AvgPool3d keep it as passed, AvgPool1d normalizes to a tuple
|
| 122 |
+
kernel = (kernel,) * (3 if isinstance(m, nn.AvgPool3d) else 2)
|
| 123 |
+
dims = len(kernel)
|
| 124 |
+
stride = (m.stride,) * dims if isinstance(m.stride, int) else m.stride
|
| 125 |
+
padding = (m.padding,) * dims if isinstance(m.padding, int) else m.padding
|
| 126 |
+
windows = 1
|
| 127 |
+
for size, output, k, s, p in zip(x[0].shape[-dims:], y.shape[-dims:], kernel, stride, padding):
|
| 128 |
+
lower, upper = (-p, size + p) if m.count_include_pad else (0, size)
|
| 129 |
+
windows *= sum(max(min(i * s - p + k, upper) - max(i * s - p, lower), 0) for i in range(output))
|
| 130 |
+
m.total_ops += l_prod(x[0].shape[:-dims]) * windows + y.numel() # one add per input, one divide per output
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def count_adap_avgpool(m, x, y):
|
| 134 |
+
"""Calculate and update the total operation counts for an AdaptiveAvgPool layer from the windows it pools."""
|
| 135 |
+
# the windows nn.AdaptiveAvgPool* actually slices, per dimension: output j spans
|
| 136 |
+
# [j * I // O, ceil((j + 1) * I / O)), so their sizes are integral and unequal whenever O does not divide I.
|
| 137 |
+
# The input-over-output ratio this replaced was a float, which made total_ops fractional, and it was also
|
| 138 |
+
# smaller than the window it stood for.
|
| 139 |
+
# Every axis is walked, not only the pooled ones: an axis the layer leaves alone has one input per output, so
|
| 140 |
+
# it contributes its own length and the batch and channel counts fall out of the same product. That is what
|
| 141 |
+
# the pooled-axes slice had to multiply back by hand, and it needs no batch axis to be there to slice off.
|
| 142 |
+
m.total_ops += (
|
| 143 |
+
l_prod(
|
| 144 |
+
o if i == o else sum(-(-(j + 1) * i // o) - j * i // o for j in range(o))
|
| 145 |
+
for i, o in zip(x[0].shape, y.shape)
|
| 146 |
+
)
|
| 147 |
+
+ y.numel()
|
| 148 |
+
) # one add per pooled input, one divide per output
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
# TODO: verify the accuracy
|
| 152 |
+
def count_upsample(m, x, y):
|
| 153 |
+
"""Update total operations counter for upsampling layers based on the mode used."""
|
| 154 |
+
ops_per_element = {
|
| 155 |
+
"nearest": 0,
|
| 156 |
+
"nearest-exact": 0,
|
| 157 |
+
"linear": 5,
|
| 158 |
+
"bilinear": 11,
|
| 159 |
+
"bicubic": 259,
|
| 160 |
+
"trilinear": 31,
|
| 161 |
+
}.get(m.mode)
|
| 162 |
+
if ops_per_element is None: # one lookup owns both the cost and whether the mode has one at all
|
| 163 |
+
logging.getLogger(__name__).warning(f"mode {m.mode} is not implemented yet, take it a zero op")
|
| 164 |
+
ops_per_element = 0
|
| 165 |
+
m.total_ops += ops_per_element * y.nelement()
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
# nn.Linear
|
| 169 |
+
def count_linear(m, x, y):
|
| 170 |
+
"""Counts total operations for nn.Linear layers using input and output element dimensions."""
|
| 171 |
+
total_mul = m.in_features
|
| 172 |
+
# total_add = m.in_features - 1
|
| 173 |
+
# total_add += 1 if m.bias is not None else 0
|
| 174 |
+
num_elements = y.numel()
|
| 175 |
+
|
| 176 |
+
m.total_ops += calculate_linear(total_mul, num_elements)
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def count_bilinear(m, x, y):
|
| 180 |
+
"""Count both contractions of each bilinear output."""
|
| 181 |
+
m.total_ops += calculate_linear((m.in1_features + 1) * m.in2_features, y.numel())
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
def count_multihead_attention(m: nn.MultiheadAttention, x, y):
|
| 185 |
+
"""Count projections, attention matrix products, and softmax.
|
| 186 |
+
|
| 187 |
+
MultiheadAttention calls its projection weights functionally, so none of this work reaches a child-module hook.
|
| 188 |
+
Returned weights reveal appended key positions; calls that suppress them fall back to the key input.
|
| 189 |
+
"""
|
| 190 |
+
out, weights = y if isinstance(y, tuple) else (y, None)
|
| 191 |
+
batch_first = getattr(m, "batch_first", False) # added in torch 1.9; before it the layout is always (L, N, E)
|
| 192 |
+
tgt_len = out.shape[-2] if batch_first or out.dim() == 2 else out.shape[0]
|
| 193 |
+
batch_size = 1 if out.dim() == 2 else out.shape[0 if batch_first else 1]
|
| 194 |
+
appended = (m.bias_k is not None) + m.add_zero_attn # each adds one key position, after the projections have run
|
| 195 |
+
if weights is not None:
|
| 196 |
+
attended = weights.shape[-1]
|
| 197 |
+
else:
|
| 198 |
+
key = x[1]
|
| 199 |
+
attended = (key.shape[-2] if batch_first or key.dim() == 2 else key.shape[0]) + appended
|
| 200 |
+
|
| 201 |
+
# Heads sum to embed_dim across both attention matrix products, so num_heads only multiplies the softmax rows.
|
| 202 |
+
projections = m.embed_dim * (2 * tgt_len * m.embed_dim + (attended - appended) * (m.kdim + m.vdim))
|
| 203 |
+
attention = 2 * tgt_len * attended * m.embed_dim
|
| 204 |
+
softmax = calculate_softmax(batch_size * m.num_heads * tgt_len, attended)
|
| 205 |
+
m.total_ops += batch_size * (projections + attention) + softmax
|
.venv/lib/python3.12/site-packages/thop/vision/calc_func.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
| 2 |
+
|
| 3 |
+
from torch.nn.parameter import UninitializedParameter
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def l_prod(in_list):
|
| 7 |
+
"""Compute the product of all elements in the input list."""
|
| 8 |
+
res = 1
|
| 9 |
+
for _ in in_list:
|
| 10 |
+
res *= _
|
| 11 |
+
return res
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def calculate_parameters(param_list):
|
| 15 |
+
"""Sum the element counts of an iterable of parameters, skipping any a lazy module has not created yet."""
|
| 16 |
+
# a lazy module's parameters hold no elements until its first forward pass, and asking one for its
|
| 17 |
+
# element count raises rather than answering 0, so they are skipped instead of being counted.
|
| 18 |
+
# isinstance rather than torch.nn.parameter.is_lazy: that helper only exists from torch 1.9 on
|
| 19 |
+
return sum(p.nelement() for p in param_list if not isinstance(p, UninitializedParameter))
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def calculate_zero_ops():
|
| 23 |
+
"""Return the zero operation count."""
|
| 24 |
+
return 0
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def calculate_conv2d_flops(
|
| 28 |
+
input_size: list, output_size: list, kernel_size: list, groups: int, bias: bool = False, transpose: bool = False
|
| 29 |
+
):
|
| 30 |
+
"""Calculate FLOPs for a ConvNd layer using input/output sizes, kernel size, groups, and the bias flag."""
|
| 31 |
+
# A transpose scatters rather than gathers, so it walks the input and takes its channel from the output.
|
| 32 |
+
volume, channels = (input_size, output_size) if transpose else (output_size, input_size)
|
| 33 |
+
# The channel axis is counted from the trailing end, so unbatched input lands on it too.
|
| 34 |
+
return l_prod(volume) * (channels[-(len(kernel_size) - 1)] // groups) * l_prod(kernel_size[2:])
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def calculate_norm(input_size):
|
| 38 |
+
"""Compute the L2 norm of a tensor or array based on its input size."""
|
| 39 |
+
return 2 * input_size
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def calculate_softmax(batch_size, nfeatures):
|
| 43 |
+
"""Compute FLOPs for a softmax activation given batch size and feature count."""
|
| 44 |
+
total_exp = nfeatures
|
| 45 |
+
total_add = max(nfeatures - 1, 0) # normalizing an empty axis costs nothing, rather than one negative addition
|
| 46 |
+
total_div = nfeatures
|
| 47 |
+
total_ops = batch_size * (total_exp + total_add + total_div)
|
| 48 |
+
return int(total_ops)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def calculate_linear(in_feature, num_elements):
|
| 52 |
+
"""Calculate the linear operation count for given input feature and number of elements."""
|
| 53 |
+
return int(in_feature * num_elements)
|
.venv/lib/python3.12/site-packages/torch/_C.cpython-312-x86_64-linux-gnu.so
ADDED
|
Binary file (10.7 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/torch/_C/_VariableFunctions.pyi
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
.venv/lib/python3.12/site-packages/torch/_C/__init__.pyi
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
.venv/lib/python3.12/site-packages/torch/_C/_acc/__init__.pyi
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from torch import Tensor
|
| 2 |
+
from torch.types import _dtype, _int, Device
|
| 3 |
+
|
| 4 |
+
# Defined in torch/csrc/acc/Module.cpp
|
| 5 |
+
class PrivateUse1Hooks:
|
| 6 |
+
def has_primary_context(self, device_index: _int) -> bool: ...
|
| 7 |
+
def is_built(self) -> bool: ...
|
| 8 |
+
def is_available(self) -> bool: ...
|
| 9 |
+
|
| 10 |
+
class DeviceGuard:
|
| 11 |
+
def type_(self) -> Device: ...
|
| 12 |
+
|
| 13 |
+
def register_python_privateuseone_device_guard(guard: DeviceGuard) -> bool: ...
|
| 14 |
+
def register_python_privateuseone_hook(hook: PrivateUse1Hooks) -> bool: ...
|
| 15 |
+
def create_empty_tensor(shape: tuple[_int, ...], dtype: _dtype) -> Tensor: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_aoti.pyi
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ctypes import c_void_p
|
| 2 |
+
from typing import overload, Protocol
|
| 3 |
+
|
| 4 |
+
from torch import Tensor
|
| 5 |
+
|
| 6 |
+
# Defined in torch/csrc/inductor/aoti_runner/pybind.cpp
|
| 7 |
+
|
| 8 |
+
# Tensor to AtenTensorHandle
|
| 9 |
+
def unsafe_alloc_void_ptrs_from_tensors(tensors: list[Tensor]) -> list[c_void_p]: ...
|
| 10 |
+
def unsafe_alloc_void_ptr_from_tensor(tensor: Tensor) -> c_void_p: ...
|
| 11 |
+
|
| 12 |
+
# AtenTensorHandle to Tensor
|
| 13 |
+
def alloc_tensors_by_stealing_from_void_ptrs(
|
| 14 |
+
handles: list[c_void_p],
|
| 15 |
+
) -> list[Tensor]: ...
|
| 16 |
+
def alloc_tensor_by_stealing_from_void_ptr(
|
| 17 |
+
handle: c_void_p,
|
| 18 |
+
) -> Tensor: ...
|
| 19 |
+
|
| 20 |
+
class AOTIModelContainerRunner(Protocol):
|
| 21 |
+
def run(
|
| 22 |
+
self, inputs: list[Tensor], stream_handle: c_void_p = ...
|
| 23 |
+
) -> list[Tensor]: ...
|
| 24 |
+
def get_call_spec(self) -> list[str]: ...
|
| 25 |
+
def get_constant_names_to_original_fqns(self) -> dict[str, str]: ...
|
| 26 |
+
def get_constant_names_to_dtypes(self) -> dict[str, int]: ...
|
| 27 |
+
def extract_constants_map(self, use_inactive: bool) -> dict[str, Tensor]: ...
|
| 28 |
+
def update_constant_buffer(
|
| 29 |
+
self,
|
| 30 |
+
tensor_map: dict[str, Tensor],
|
| 31 |
+
use_inactive: bool,
|
| 32 |
+
validate_full_updates: bool,
|
| 33 |
+
user_managed: bool = ...,
|
| 34 |
+
) -> None: ...
|
| 35 |
+
def swap_constant_buffer(self) -> None: ...
|
| 36 |
+
def free_inactive_constant_buffer(self) -> None: ...
|
| 37 |
+
|
| 38 |
+
class AOTIModelContainerRunnerCpu:
|
| 39 |
+
def __init__(self, model_so_path: str, num_models: int) -> None: ...
|
| 40 |
+
def run(
|
| 41 |
+
self, inputs: list[Tensor], stream_handle: c_void_p = ...
|
| 42 |
+
) -> list[Tensor]: ...
|
| 43 |
+
def get_call_spec(self) -> list[str]: ...
|
| 44 |
+
def get_constant_names_to_original_fqns(self) -> dict[str, str]: ...
|
| 45 |
+
def get_constant_names_to_dtypes(self) -> dict[str, int]: ...
|
| 46 |
+
def extract_constants_map(self, use_inactive: bool) -> dict[str, Tensor]: ...
|
| 47 |
+
def update_constant_buffer(
|
| 48 |
+
self,
|
| 49 |
+
tensor_map: dict[str, Tensor],
|
| 50 |
+
use_inactive: bool,
|
| 51 |
+
validate_full_updates: bool,
|
| 52 |
+
user_managed: bool = ...,
|
| 53 |
+
) -> None: ...
|
| 54 |
+
def swap_constant_buffer(self) -> None: ...
|
| 55 |
+
def free_inactive_constant_buffer(self) -> None: ...
|
| 56 |
+
|
| 57 |
+
class AOTIModelContainerRunnerCuda:
|
| 58 |
+
@overload
|
| 59 |
+
def __init__(self, model_so_path: str, num_models: int) -> None: ...
|
| 60 |
+
@overload
|
| 61 |
+
def __init__(
|
| 62 |
+
self, model_so_path: str, num_models: int, device_str: str
|
| 63 |
+
) -> None: ...
|
| 64 |
+
@overload
|
| 65 |
+
def __init__(
|
| 66 |
+
self, model_so_path: str, num_models: int, device_str: str, cubin_dir: str
|
| 67 |
+
) -> None: ...
|
| 68 |
+
def run(
|
| 69 |
+
self, inputs: list[Tensor], stream_handle: c_void_p = ...
|
| 70 |
+
) -> list[Tensor]: ...
|
| 71 |
+
def get_call_spec(self) -> list[str]: ...
|
| 72 |
+
def get_constant_names_to_original_fqns(self) -> dict[str, str]: ...
|
| 73 |
+
def get_constant_names_to_dtypes(self) -> dict[str, int]: ...
|
| 74 |
+
def extract_constants_map(self, use_inactive: bool) -> dict[str, Tensor]: ...
|
| 75 |
+
def update_constant_buffer(
|
| 76 |
+
self,
|
| 77 |
+
tensor_map: dict[str, Tensor],
|
| 78 |
+
use_inactive: bool,
|
| 79 |
+
validate_full_updates: bool,
|
| 80 |
+
user_managed: bool = ...,
|
| 81 |
+
) -> None: ...
|
| 82 |
+
def update_constant_buffer_from_cpu(
|
| 83 |
+
self,
|
| 84 |
+
tensor_map: dict[str, Tensor],
|
| 85 |
+
use_inactive: bool,
|
| 86 |
+
validate_full_updates: bool,
|
| 87 |
+
) -> None: ...
|
| 88 |
+
def swap_constant_buffer(self) -> None: ...
|
| 89 |
+
def free_inactive_constant_buffer(self) -> None: ...
|
| 90 |
+
|
| 91 |
+
class AOTIModelContainerRunnerXpu:
|
| 92 |
+
@overload
|
| 93 |
+
def __init__(self, model_so_path: str, num_models: int) -> None: ...
|
| 94 |
+
@overload
|
| 95 |
+
def __init__(
|
| 96 |
+
self, model_so_path: str, num_models: int, device_str: str
|
| 97 |
+
) -> None: ...
|
| 98 |
+
@overload
|
| 99 |
+
def __init__(
|
| 100 |
+
self, model_so_path: str, num_models: int, device_str: str, kernel_bin_dir: str
|
| 101 |
+
) -> None: ...
|
| 102 |
+
def run(
|
| 103 |
+
self, inputs: list[Tensor], stream_handle: c_void_p = ...
|
| 104 |
+
) -> list[Tensor]: ...
|
| 105 |
+
def get_call_spec(self) -> list[str]: ...
|
| 106 |
+
def get_constant_names_to_original_fqns(self) -> dict[str, str]: ...
|
| 107 |
+
def get_constant_names_to_dtypes(self) -> dict[str, int]: ...
|
| 108 |
+
def extract_constants_map(self, use_inactive: bool) -> dict[str, Tensor]: ...
|
| 109 |
+
def update_constant_buffer(
|
| 110 |
+
self,
|
| 111 |
+
tensor_map: dict[str, Tensor],
|
| 112 |
+
use_inactive: bool,
|
| 113 |
+
validate_full_updates: bool,
|
| 114 |
+
user_managed: bool = ...,
|
| 115 |
+
) -> None: ...
|
| 116 |
+
def update_constant_buffer_from_cpu(
|
| 117 |
+
self,
|
| 118 |
+
tensor_map: dict[str, Tensor],
|
| 119 |
+
use_inactive: bool,
|
| 120 |
+
validate_full_updates: bool,
|
| 121 |
+
) -> None: ...
|
| 122 |
+
def swap_constant_buffer(self) -> None: ...
|
| 123 |
+
def free_inactive_constant_buffer(self) -> None: ...
|
| 124 |
+
|
| 125 |
+
class AOTIModelContainerRunnerMps:
|
| 126 |
+
def __init__(self, model_so_path: str, num_models: int) -> None: ...
|
| 127 |
+
def run(
|
| 128 |
+
self, inputs: list[Tensor], stream_handle: c_void_p = ...
|
| 129 |
+
) -> list[Tensor]: ...
|
| 130 |
+
def get_call_spec(self) -> list[str]: ...
|
| 131 |
+
def get_constant_names_to_original_fqns(self) -> dict[str, str]: ...
|
| 132 |
+
def get_constant_names_to_dtypes(self) -> dict[str, int]: ...
|
| 133 |
+
def extract_constants_map(self, use_inactive: bool) -> dict[str, Tensor]: ...
|
| 134 |
+
def update_constant_buffer(
|
| 135 |
+
self,
|
| 136 |
+
tensor_map: dict[str, Tensor],
|
| 137 |
+
use_inactive: bool,
|
| 138 |
+
validate_full_updates: bool,
|
| 139 |
+
user_managed: bool = ...,
|
| 140 |
+
) -> None: ...
|
| 141 |
+
def update_constant_buffer_from_cpu(
|
| 142 |
+
self,
|
| 143 |
+
tensor_map: dict[str, Tensor],
|
| 144 |
+
use_inactive: bool,
|
| 145 |
+
validate_full_updates: bool,
|
| 146 |
+
) -> None: ...
|
| 147 |
+
def swap_constant_buffer(self) -> None: ...
|
| 148 |
+
def free_inactive_constant_buffer(self) -> None: ...
|
| 149 |
+
|
| 150 |
+
# Defined in torch/csrc/inductor/aoti_package/pybind.cpp
|
| 151 |
+
class AOTIModelPackageLoader:
|
| 152 |
+
def __init__(
|
| 153 |
+
self,
|
| 154 |
+
model_package_path: str,
|
| 155 |
+
model_name: str,
|
| 156 |
+
run_single_threaded: bool,
|
| 157 |
+
num_runners: int,
|
| 158 |
+
device_index: int,
|
| 159 |
+
) -> None: ...
|
| 160 |
+
def get_metadata(self) -> dict[str, str]: ...
|
| 161 |
+
def run(
|
| 162 |
+
self, inputs: list[Tensor], stream_handle: c_void_p = ...
|
| 163 |
+
) -> list[Tensor]: ...
|
| 164 |
+
def boxed_run(
|
| 165 |
+
self, inputs: list[Tensor], stream_handle: c_void_p = ...
|
| 166 |
+
) -> list[Tensor]: ...
|
| 167 |
+
def get_call_spec(self) -> list[str]: ...
|
| 168 |
+
def get_constant_fqns(self) -> list[str]: ...
|
| 169 |
+
def load_constants(
|
| 170 |
+
self,
|
| 171 |
+
constants_map: dict[str, Tensor],
|
| 172 |
+
use_inactive: bool,
|
| 173 |
+
check_full_update: bool,
|
| 174 |
+
user_managed: bool = ...,
|
| 175 |
+
allow_h2d_copy: bool = ...,
|
| 176 |
+
) -> None: ...
|
| 177 |
+
def update_constant_buffer(
|
| 178 |
+
self,
|
| 179 |
+
tensor_map: dict[str, Tensor],
|
| 180 |
+
use_inactive: bool,
|
| 181 |
+
validate_full_updates: bool,
|
| 182 |
+
user_managed: bool = ...,
|
| 183 |
+
) -> None: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_autograd.pyi
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
from collections.abc import Callable
|
| 3 |
+
from enum import Enum
|
| 4 |
+
from typing import Any
|
| 5 |
+
|
| 6 |
+
import torch
|
| 7 |
+
from torch._C._profiler import (
|
| 8 |
+
_ProfilerEvent,
|
| 9 |
+
ActiveProfilerType,
|
| 10 |
+
ProfilerActivity,
|
| 11 |
+
ProfilerConfig,
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
# Defined in torch/csrc/autograd/init.cpp
|
| 15 |
+
|
| 16 |
+
class DeviceType(Enum):
|
| 17 |
+
CPU = ...
|
| 18 |
+
CUDA = ...
|
| 19 |
+
XPU = ...
|
| 20 |
+
MKLDNN = ...
|
| 21 |
+
OPENGL = ...
|
| 22 |
+
OPENCL = ...
|
| 23 |
+
IDEEP = ...
|
| 24 |
+
HIP = ...
|
| 25 |
+
FPGA = ...
|
| 26 |
+
MAIA = ...
|
| 27 |
+
XLA = ...
|
| 28 |
+
MTIA = ...
|
| 29 |
+
MPS = ...
|
| 30 |
+
HPU = ...
|
| 31 |
+
Meta = ...
|
| 32 |
+
Vulkan = ...
|
| 33 |
+
Metal = ...
|
| 34 |
+
PrivateUse1 = ...
|
| 35 |
+
|
| 36 |
+
class ProfilerEvent:
|
| 37 |
+
def cpu_elapsed_us(self, other: ProfilerEvent) -> float: ...
|
| 38 |
+
def cpu_memory_usage(self) -> int: ...
|
| 39 |
+
def cuda_elapsed_us(self, other: ProfilerEvent) -> float: ...
|
| 40 |
+
def privateuse1_elapsed_us(self, other: ProfilerEvent) -> float: ...
|
| 41 |
+
def cuda_memory_usage(self) -> int: ...
|
| 42 |
+
def device(self) -> int: ...
|
| 43 |
+
def handle(self) -> int: ...
|
| 44 |
+
def has_cuda(self) -> bool: ...
|
| 45 |
+
def is_remote(self) -> bool: ...
|
| 46 |
+
def kind(self) -> int: ...
|
| 47 |
+
def name(self) -> str: ...
|
| 48 |
+
def node_id(self) -> int: ...
|
| 49 |
+
def sequence_nr(self) -> int: ...
|
| 50 |
+
def shapes(self) -> list[list[int]]: ...
|
| 51 |
+
def thread_id(self) -> int: ...
|
| 52 |
+
def flops(self) -> float: ...
|
| 53 |
+
def is_async(self) -> bool: ...
|
| 54 |
+
|
| 55 |
+
class _KinetoEvent:
|
| 56 |
+
def name(self) -> str: ...
|
| 57 |
+
def overload_name(self) -> str: ...
|
| 58 |
+
def device_index(self) -> int: ...
|
| 59 |
+
def device_resource_id(self) -> int: ...
|
| 60 |
+
def start_ns(self) -> int: ...
|
| 61 |
+
def end_ns(self) -> int: ...
|
| 62 |
+
def duration_ns(self) -> int: ...
|
| 63 |
+
def is_async(self) -> bool: ...
|
| 64 |
+
def linked_correlation_id(self) -> int: ...
|
| 65 |
+
def external_id(self) -> int: ...
|
| 66 |
+
def shapes(self) -> list[list[int]]: ...
|
| 67 |
+
def dtypes(self) -> list[str]: ...
|
| 68 |
+
def concrete_inputs(self) -> list[Any]: ...
|
| 69 |
+
def kwinputs(self) -> dict[str, Any]: ...
|
| 70 |
+
def device_type(self) -> DeviceType: ...
|
| 71 |
+
def start_thread_id(self) -> int: ...
|
| 72 |
+
def end_thread_id(self) -> int: ...
|
| 73 |
+
def correlation_id(self) -> int: ...
|
| 74 |
+
def fwd_thread_id(self) -> int: ...
|
| 75 |
+
def stack(self) -> list[str]: ...
|
| 76 |
+
def scope(self) -> int: ...
|
| 77 |
+
def sequence_nr(self) -> int: ...
|
| 78 |
+
def flops(self) -> int: ...
|
| 79 |
+
def cuda_elapsed_us(self) -> int: ...
|
| 80 |
+
def privateuse1_elapsed_us(self) -> int: ...
|
| 81 |
+
def is_user_annotation(self) -> bool: ...
|
| 82 |
+
def is_python_function(self) -> bool: ...
|
| 83 |
+
def is_hidden_event(self) -> bool: ...
|
| 84 |
+
def metadata_json(self) -> str: ...
|
| 85 |
+
def activity_type(self) -> str: ...
|
| 86 |
+
def extra_meta(self) -> dict[str, str]: ...
|
| 87 |
+
def typed_metadata(self) -> dict[str, Any]: ...
|
| 88 |
+
def flow_id(self) -> int: ...
|
| 89 |
+
def flow_type(self) -> int: ...
|
| 90 |
+
def flow_start(self) -> bool: ...
|
| 91 |
+
def structured_input_shapes(self) -> list[list[int] | list[list[int]]]: ...
|
| 92 |
+
def structured_input_strides(self) -> list[list[int] | list[list[int]]]: ...
|
| 93 |
+
def python_id(self) -> int: ...
|
| 94 |
+
def python_parent_id(self) -> int: ...
|
| 95 |
+
def python_module_id(self) -> int: ...
|
| 96 |
+
|
| 97 |
+
class _ProfilerResult:
|
| 98 |
+
def events(self) -> list[_KinetoEvent]: ...
|
| 99 |
+
def legacy_events(self) -> list[list[ProfilerEvent]]: ...
|
| 100 |
+
def save(self, path: str) -> None: ...
|
| 101 |
+
def experimental_event_tree(self) -> list[_ProfilerEvent]: ...
|
| 102 |
+
def trace_start_ns(self) -> int: ...
|
| 103 |
+
|
| 104 |
+
class SavedTensor:
|
| 105 |
+
def unpack(self) -> torch.Tensor: ...
|
| 106 |
+
|
| 107 |
+
def _make_saved_tensor(
|
| 108 |
+
tensor: torch.Tensor,
|
| 109 |
+
is_output: bool,
|
| 110 |
+
is_inplace_on_view: bool = False,
|
| 111 |
+
) -> SavedTensor: ...
|
| 112 |
+
def _enable_profiler(
|
| 113 |
+
config: ProfilerConfig,
|
| 114 |
+
activities: set[ProfilerActivity],
|
| 115 |
+
) -> None: ...
|
| 116 |
+
def _prepare_profiler(
|
| 117 |
+
config: ProfilerConfig,
|
| 118 |
+
activities: set[ProfilerActivity],
|
| 119 |
+
activity_filter: dict[ProfilerActivity, set[str]] = ...,
|
| 120 |
+
) -> None: ...
|
| 121 |
+
def _toggle_collection_dynamic(
|
| 122 |
+
enable: bool,
|
| 123 |
+
activities: set[ProfilerActivity],
|
| 124 |
+
) -> None: ...
|
| 125 |
+
def _disable_profiler() -> _ProfilerResult: ...
|
| 126 |
+
def _profiler_enabled() -> bool: ...
|
| 127 |
+
def _add_metadata_json(key: str, value: str) -> None: ...
|
| 128 |
+
def _is_kineto_stopped() -> bool: ...
|
| 129 |
+
def _kineto_step() -> None: ...
|
| 130 |
+
def _get_current_graph_task_keep_graph() -> bool: ...
|
| 131 |
+
def _get_sequence_nr() -> int: ...
|
| 132 |
+
def kineto_available() -> bool: ...
|
| 133 |
+
def _record_function_with_args_enter(name: str, *args) -> torch.Tensor: ...
|
| 134 |
+
def _record_function_with_args_exit(handle: torch.Tensor) -> None: ...
|
| 135 |
+
def _supported_activities() -> set[ProfilerActivity]: ...
|
| 136 |
+
def _enable_record_function(enable: bool) -> None: ...
|
| 137 |
+
def _set_empty_test_observer(is_global: bool, sampling_prob: float) -> None: ...
|
| 138 |
+
def _push_saved_tensors_default_hooks(
|
| 139 |
+
pack_hook: Callable[[torch.Tensor], Any],
|
| 140 |
+
unpack_hook: Callable[[Any], torch.Tensor],
|
| 141 |
+
) -> None: ...
|
| 142 |
+
def _pop_saved_tensors_default_hooks() -> None: ...
|
| 143 |
+
def _push_node_creation_hook(hook: Callable[[Any], None]) -> None: ...
|
| 144 |
+
def _pop_node_creation_hook() -> None: ...
|
| 145 |
+
def _top_saved_tensors_default_hooks(
|
| 146 |
+
ignore_is_tracing: bool,
|
| 147 |
+
) -> tuple[Callable[[torch.Tensor], Any], Callable[[Any], torch.Tensor]]: ...
|
| 148 |
+
def _unsafe_set_version_counter(
|
| 149 |
+
t: tuple[torch.Tensor, ...], prev_version: tuple[int, ...]
|
| 150 |
+
) -> None: ...
|
| 151 |
+
def _enable_profiler_legacy(config: ProfilerConfig) -> None: ...
|
| 152 |
+
def _disable_profiler_legacy() -> list[list[ProfilerEvent]]: ...
|
| 153 |
+
def _profiler_type() -> ActiveProfilerType: ...
|
| 154 |
+
def _saved_tensors_hooks_enable() -> None: ...
|
| 155 |
+
def _saved_tensors_hooks_disable(message: str, fail_if_non_empty=True) -> None: ...
|
| 156 |
+
def _saved_tensors_hooks_get_disabled_error_message() -> str | None: ...
|
| 157 |
+
def _saved_tensors_hooks_set_tracing(is_tracing: bool) -> bool: ...
|
| 158 |
+
|
| 159 |
+
class CreationMeta(Enum):
|
| 160 |
+
DEFAULT = ...
|
| 161 |
+
IN_CUSTOM_FUNCTION = ...
|
| 162 |
+
MULTI_OUTPUT_NODE = ...
|
| 163 |
+
NO_GRAD_MODE = ...
|
| 164 |
+
INFERENCE_MODE = ...
|
| 165 |
+
|
| 166 |
+
def _set_creation_meta(t: torch.Tensor, creation_meta: CreationMeta) -> None: ...
|
| 167 |
+
def _get_creation_meta(t: torch.Tensor) -> CreationMeta: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_cpu.pyi
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any
|
| 2 |
+
|
| 3 |
+
from torch.types import _bool
|
| 4 |
+
|
| 5 |
+
# Defined in torch/csrc/cpu/Module.cpp
|
| 6 |
+
|
| 7 |
+
def _init_amx() -> _bool: ...
|
| 8 |
+
def _get_cpu_capability() -> dict[str, Any]: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_cudnn.pyi
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from enum import IntEnum
|
| 2 |
+
|
| 3 |
+
# Defined in torch/csrc/cuda/shared/cudnn.cpp
|
| 4 |
+
is_cuda: bool
|
| 5 |
+
|
| 6 |
+
def getRuntimeVersion() -> tuple[int, int, int]: ...
|
| 7 |
+
def getCompileVersion() -> tuple[int, int, int]: ...
|
| 8 |
+
def getVersionInt() -> int: ...
|
| 9 |
+
|
| 10 |
+
class RNNMode(IntEnum):
|
| 11 |
+
rnn_relu = ...
|
| 12 |
+
rnn_tanh = ...
|
| 13 |
+
lstm = ...
|
| 14 |
+
gru = ...
|
.venv/lib/python3.12/site-packages/torch/_C/_cusparselt.pyi
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
def getVersionInt() -> int: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_distributed.pyi
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This module is defined in torch/csrc/distributed/python_placement.cpp
|
| 2 |
+
|
| 3 |
+
class Placement:
|
| 4 |
+
def is_partial(self, reduce_op: str | None = None) -> bool: ...
|
| 5 |
+
def is_replicate(self) -> bool: ...
|
| 6 |
+
def is_shard(self, dim: int | None = None) -> bool: ...
|
| 7 |
+
|
| 8 |
+
class Shard(Placement):
|
| 9 |
+
dim: int
|
| 10 |
+
def __init__(self, dim: int): ...
|
| 11 |
+
|
| 12 |
+
class StridedShard(Placement):
|
| 13 |
+
dim: int
|
| 14 |
+
split_factor: int
|
| 15 |
+
def __init__(self, dim: int, *, split_factor: int): ...
|
| 16 |
+
|
| 17 |
+
class Replicate(Placement): ...
|
| 18 |
+
|
| 19 |
+
class Partial(Placement):
|
| 20 |
+
reduce_op: str
|
| 21 |
+
def __init__(self, reduce_op: str | None = None): ...
|
.venv/lib/python3.12/site-packages/torch/_C/_distributed_autograd.pyi
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
# This module is defined in torch/csrc/distributed/autograd/init.cpp
|
| 6 |
+
|
| 7 |
+
class DistAutogradContext:
|
| 8 |
+
def _context_id(self) -> int: ...
|
| 9 |
+
def _recv_functions(self) -> dict[int, Any]: ...
|
| 10 |
+
def _send_functions(self) -> dict[int, Any]: ...
|
| 11 |
+
def _known_worker_ids(self) -> set[int]: ...
|
| 12 |
+
|
| 13 |
+
def _new_context() -> DistAutogradContext: ...
|
| 14 |
+
def _release_context(context_id: int) -> None: ...
|
| 15 |
+
def _get_max_id() -> int: ...
|
| 16 |
+
def _is_valid_context(worker_id: int) -> bool: ...
|
| 17 |
+
def _retrieve_context(context_id: int) -> DistAutogradContext: ...
|
| 18 |
+
def _current_context() -> DistAutogradContext: ...
|
| 19 |
+
def _init(worker_id: int) -> None: ...
|
| 20 |
+
def _get_debug_info() -> dict[str, str]: ...
|
| 21 |
+
def backward(
|
| 22 |
+
context_id: int,
|
| 23 |
+
roots: list[torch.Tensor],
|
| 24 |
+
retain_graph: bool = False,
|
| 25 |
+
) -> None: ...
|
| 26 |
+
def get_gradients(context_id: int) -> dict[torch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|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
# mypy: disable-error-code="type-arg"
|
| 3 |
+
from collections.abc import Callable
|
| 4 |
+
from datetime import timedelta
|
| 5 |
+
from enum import Enum
|
| 6 |
+
from typing import Any, overload
|
| 7 |
+
|
| 8 |
+
import torch
|
| 9 |
+
from torch import Tensor
|
| 10 |
+
from torch._C import ScriptObject
|
| 11 |
+
from torch._C._autograd import DeviceType
|
| 12 |
+
from torch.distributed.distributed_c10d import GroupName
|
| 13 |
+
from torch.futures import Future
|
| 14 |
+
|
| 15 |
+
# This module is defined in torch/csrc/distributed/c10d/init.cpp
|
| 16 |
+
|
| 17 |
+
_DEFAULT_FIRST_BUCKET_BYTES: int
|
| 18 |
+
_DEFAULT_NO_TIMEOUT: timedelta
|
| 19 |
+
_DEFAULT_PG_TIMEOUT: timedelta
|
| 20 |
+
_DEFAULT_PG_NCCL_TIMEOUT: timedelta
|
| 21 |
+
|
| 22 |
+
class BuiltinCommHookType(Enum):
|
| 23 |
+
ALLREDUCE = ...
|
| 24 |
+
FP16_COMPRESS = ...
|
| 25 |
+
|
| 26 |
+
def _register_comm_hook(reducer: Reducer, state: Any, comm_hook: Any): ...
|
| 27 |
+
def _register_builtin_comm_hook(
|
| 28 |
+
reducer: Reducer,
|
| 29 |
+
comm_hook_type: BuiltinCommHookType,
|
| 30 |
+
): ...
|
| 31 |
+
def _set_global_rank(rank: int) -> None: ...
|
| 32 |
+
def _hash_tensors(tensors: list[Tensor]) -> int: ...
|
| 33 |
+
|
| 34 |
+
class GradBucket:
|
| 35 |
+
def index(self) -> int: ...
|
| 36 |
+
def buffer(self) -> Tensor: ...
|
| 37 |
+
def gradients(self) -> list[Tensor]: ...
|
| 38 |
+
def is_last(self) -> bool: ...
|
| 39 |
+
def set_buffer(self, tensor: Tensor) -> None: ...
|
| 40 |
+
def parameters(self) -> list[Tensor]: ...
|
| 41 |
+
|
| 42 |
+
class Reducer:
|
| 43 |
+
def __init__(
|
| 44 |
+
self,
|
| 45 |
+
params: list[Tensor],
|
| 46 |
+
bucket_indices: list[list[int]],
|
| 47 |
+
per_bucket_size_limits: list[int],
|
| 48 |
+
process_group: ProcessGroup,
|
| 49 |
+
expect_sparse_gradients: list[bool] = ...,
|
| 50 |
+
bucket_bytes_cap: int = ..., # kDefaultBucketBytesCap in reducer.hpp
|
| 51 |
+
find_unused_parameters: bool = ...,
|
| 52 |
+
gradient_as_bucket_view: bool = ...,
|
| 53 |
+
param_to_name_mapping: dict[int, str] = ...,
|
| 54 |
+
first_bucket_types_cap: int = ..., # kDefaultFirstBucketBytes in reducer.hpp
|
| 55 |
+
skip_all_reduce_unused_params: bool = ...,
|
| 56 |
+
use_python_reducer: bool = ...,
|
| 57 |
+
bucket_bytes_cap_list: list[int] = ...,
|
| 58 |
+
batched_grad_copy: bool = ...,
|
| 59 |
+
) -> None: ...
|
| 60 |
+
def prepare_for_forward(self) -> None: ...
|
| 61 |
+
def prepare_for_backward(self, output: list[Tensor]) -> None: ...
|
| 62 |
+
def get_backward_stats(self) -> list[int]: ...
|
| 63 |
+
def _install_post_backward_futures(self, futures: list[Future]) -> None: ...
|
| 64 |
+
def _rebuild_buckets(self) -> bool: ...
|
| 65 |
+
def _get_zeros_like_grad_buckets(self) -> list[GradBucket]: ...
|
| 66 |
+
def _push_all_rebuilt_params(self) -> None: ...
|
| 67 |
+
def _set_forward_pass_work_handle(
|
| 68 |
+
self,
|
| 69 |
+
work: Work,
|
| 70 |
+
use_static_world_size: bool,
|
| 71 |
+
): ...
|
| 72 |
+
def _get_local_used_map(self) -> Tensor: ...
|
| 73 |
+
def _set_ddp_runtime_logging_sample_rate(self, sample_rate: int) -> None: ...
|
| 74 |
+
def _set_static_graph(self) -> None: ...
|
| 75 |
+
def _run_comm_hook(self, bucket: GradBucket) -> Future: ...
|
| 76 |
+
def set_logger(self, logger: Logger) -> None: ...
|
| 77 |
+
def _remove_autograd_hooks(self) -> None: ...
|
| 78 |
+
def _check_reducer_finalized(self) -> None: ...
|
| 79 |
+
def _set_sparse_metadata(self, global_unique_ids: dict[str, Tensor]) -> None: ...
|
| 80 |
+
def _reset_state(self) -> None: ...
|
| 81 |
+
def _update_process_group(self, new_process_group: ProcessGroup) -> None: ...
|
| 82 |
+
|
| 83 |
+
class DDPLoggingData:
|
| 84 |
+
strs_map: dict[str, str]
|
| 85 |
+
ints_map: dict[str, int]
|
| 86 |
+
|
| 87 |
+
class Logger:
|
| 88 |
+
def __init__(self, reducer: Reducer) -> None: ...
|
| 89 |
+
def set_construction_data_and_log(
|
| 90 |
+
self,
|
| 91 |
+
module_name: str,
|
| 92 |
+
device_ids: list[int],
|
| 93 |
+
output_device: int,
|
| 94 |
+
broadcast_buffers: bool,
|
| 95 |
+
has_sync_bn: bool,
|
| 96 |
+
static_graph: bool,
|
| 97 |
+
) -> None: ...
|
| 98 |
+
def set_runtime_stats_and_log(self) -> None: ...
|
| 99 |
+
def set_error_and_log(self, error: str) -> None: ...
|
| 100 |
+
def _get_ddp_logging_data(self) -> DDPLoggingData: ...
|
| 101 |
+
def _set_comm_hook_name(self, comm_hook: str) -> None: ...
|
| 102 |
+
def _set_uneven_input_join(self) -> None: ...
|
| 103 |
+
def _set_static_graph(self) -> None: ...
|
| 104 |
+
|
| 105 |
+
class _WorkerServer:
|
| 106 |
+
port: int
|
| 107 |
+
|
| 108 |
+
def __init__(self, host_or_file: str, port: int = ...) -> None: ...
|
| 109 |
+
def shutdown(self) -> None: ...
|
| 110 |
+
|
| 111 |
+
class DebugLevel(Enum):
|
| 112 |
+
OFF = ...
|
| 113 |
+
INFO = ...
|
| 114 |
+
DETAIL = ...
|
| 115 |
+
|
| 116 |
+
def get_debug_level() -> DebugLevel: ...
|
| 117 |
+
def set_debug_level(level: DebugLevel) -> None: ...
|
| 118 |
+
def set_debug_level_from_env() -> None: ...
|
| 119 |
+
|
| 120 |
+
class ReduceOp:
|
| 121 |
+
# pyrefly: ignore # unknown-name
|
| 122 |
+
def __init__(self, op: RedOpType) -> None: ...
|
| 123 |
+
@property
|
| 124 |
+
def factor(self) -> float | Tensor: ...
|
| 125 |
+
|
| 126 |
+
# pyrefly: ignore # unknown-name
|
| 127 |
+
SUM: RedOpType = ...
|
| 128 |
+
# pyrefly: ignore # unknown-name
|
| 129 |
+
AVG: RedOpType = ...
|
| 130 |
+
# pyrefly: ignore # unknown-name
|
| 131 |
+
PRODUCT: RedOpType = ...
|
| 132 |
+
# pyrefly: ignore # unknown-name
|
| 133 |
+
MIN: RedOpType = ...
|
| 134 |
+
# pyrefly: ignore # unknown-name
|
| 135 |
+
MAX: RedOpType = ...
|
| 136 |
+
# pyrefly: ignore # unknown-name
|
| 137 |
+
BAND: RedOpType = ...
|
| 138 |
+
# pyrefly: ignore # unknown-name
|
| 139 |
+
BOR: RedOpType = ...
|
| 140 |
+
# pyrefly: ignore # unknown-name
|
| 141 |
+
BXOR: RedOpType = ...
|
| 142 |
+
# pyrefly: ignore # unknown-name
|
| 143 |
+
PREMUL_SUM: RedOpType = ...
|
| 144 |
+
# pyrefly: ignore # unknown-name
|
| 145 |
+
UNUSED: RedOpType = ...
|
| 146 |
+
|
| 147 |
+
# mypy error being ignored:
|
| 148 |
+
# Detected enum "torch._C._distributed_c10d.ReduceOp.RedOpType" in a type
|
| 149 |
+
# stub with zero members. There is a chance this is due to a recent change
|
| 150 |
+
# in the semantics of enum membership. If so, use `member = value` to mark
|
| 151 |
+
# an enum member, instead of `member: type`
|
| 152 |
+
class RedOpType(Enum):
|
| 153 |
+
def __call__(self, factor: float | int | Tensor) -> ReduceOp:
|
| 154 |
+
"""Create a PREMUL_SUM ReduceOp with the given factor. Only PREMUL_SUM supports this."""
|
| 155 |
+
|
| 156 |
+
class BroadcastOptions:
|
| 157 |
+
rootRank: int
|
| 158 |
+
rootTensor: int
|
| 159 |
+
timeout: timedelta
|
| 160 |
+
asyncOp: bool
|
| 161 |
+
|
| 162 |
+
class AllreduceOptions:
|
| 163 |
+
reduceOp: ReduceOp | ReduceOp.RedOpType
|
| 164 |
+
timeout: timedelta
|
| 165 |
+
asyncOp: bool
|
| 166 |
+
sparseIndices: Tensor | None
|
| 167 |
+
|
| 168 |
+
class AllreduceCoalescedOptions(AllreduceOptions): ...
|
| 169 |
+
|
| 170 |
+
class ReduceOptions:
|
| 171 |
+
reduceOp: ReduceOp | ReduceOp.RedOpType
|
| 172 |
+
rootRank: int
|
| 173 |
+
rootTensor: int
|
| 174 |
+
timeout: timedelta
|
| 175 |
+
asyncOp: bool
|
| 176 |
+
|
| 177 |
+
class AllgatherOptions:
|
| 178 |
+
timeout: timedelta
|
| 179 |
+
asyncOp: bool
|
| 180 |
+
|
| 181 |
+
class GatherOptions:
|
| 182 |
+
rootRank: int
|
| 183 |
+
timeout: timedelta
|
| 184 |
+
asyncOp: bool
|
| 185 |
+
|
| 186 |
+
class ScatterOptions:
|
| 187 |
+
rootRank: int
|
| 188 |
+
timeout: timedelta
|
| 189 |
+
asyncOp: bool
|
| 190 |
+
|
| 191 |
+
class ReduceScatterOptions:
|
| 192 |
+
reduceOp: ReduceOp | ReduceOp.RedOpType
|
| 193 |
+
timeout: timedelta
|
| 194 |
+
asyncOp: bool
|
| 195 |
+
|
| 196 |
+
class BarrierOptions:
|
| 197 |
+
device_ids: list[int]
|
| 198 |
+
device: torch.device
|
| 199 |
+
timeout: timedelta
|
| 200 |
+
asyncOp: bool
|
| 201 |
+
|
| 202 |
+
class AllToAllOptions:
|
| 203 |
+
timeout: timedelta
|
| 204 |
+
asyncOp: bool
|
| 205 |
+
|
| 206 |
+
class ReconfigureOptions:
|
| 207 |
+
uuid: int
|
| 208 |
+
handles: set[str] | list[str]
|
| 209 |
+
timeout: timedelta | None
|
| 210 |
+
hints: dict[str, str]
|
| 211 |
+
|
| 212 |
+
class PutOptions:
|
| 213 |
+
timeout: timedelta
|
| 214 |
+
hints: dict[str, str]
|
| 215 |
+
|
| 216 |
+
class SignalOptions:
|
| 217 |
+
timeout: timedelta
|
| 218 |
+
hints: dict[str, str]
|
| 219 |
+
|
| 220 |
+
class WaitSignalOptions:
|
| 221 |
+
timeout: timedelta
|
| 222 |
+
hints: dict[str, str]
|
| 223 |
+
|
| 224 |
+
class WindowAccessType(Enum):
|
| 225 |
+
UNIFIED = ...
|
| 226 |
+
SEPARATE = ...
|
| 227 |
+
|
| 228 |
+
class WindowAttr:
|
| 229 |
+
access_type: WindowAccessType
|
| 230 |
+
|
| 231 |
+
class Window:
|
| 232 |
+
def tensor_register(self, tensor: Tensor, owning: bool = ...) -> None: ...
|
| 233 |
+
def tensor_deregister(self) -> None: ...
|
| 234 |
+
def put(
|
| 235 |
+
self,
|
| 236 |
+
tensor: Tensor,
|
| 237 |
+
dst_rank: int,
|
| 238 |
+
target_offset_nelems: int,
|
| 239 |
+
async_op: bool,
|
| 240 |
+
opts: PutOptions = ...,
|
| 241 |
+
) -> Work: ...
|
| 242 |
+
def map_remote_tensor(self, rank: int) -> Tensor: ...
|
| 243 |
+
def signal(
|
| 244 |
+
self,
|
| 245 |
+
peer_rank: int,
|
| 246 |
+
async_op: bool,
|
| 247 |
+
opts: SignalOptions = ...,
|
| 248 |
+
) -> Work: ...
|
| 249 |
+
def wait_signal(
|
| 250 |
+
self,
|
| 251 |
+
peer_rank: int,
|
| 252 |
+
async_op: bool,
|
| 253 |
+
opts: WaitSignalOptions = ...,
|
| 254 |
+
) -> Work: ...
|
| 255 |
+
def get_attr(self, peer_rank: int) -> WindowAttr: ...
|
| 256 |
+
|
| 257 |
+
class HookOpName(Enum):
|
| 258 |
+
SEND = ...
|
| 259 |
+
RECV = ...
|
| 260 |
+
BROADCAST = ...
|
| 261 |
+
ALLREDUCE = ...
|
| 262 |
+
REDUCE = ...
|
| 263 |
+
ALLGATHER = ...
|
| 264 |
+
REDUCE_SCATTER = ...
|
| 265 |
+
ALLTOALL = ...
|
| 266 |
+
BARRIER = ...
|
| 267 |
+
SCATTER = ...
|
| 268 |
+
GATHER = ...
|
| 269 |
+
SPLIT = ...
|
| 270 |
+
NEW_WINDOW = ...
|
| 271 |
+
UNKNOWN = ...
|
| 272 |
+
|
| 273 |
+
class PreHookArgs:
|
| 274 |
+
name: HookOpName
|
| 275 |
+
async_op: bool
|
| 276 |
+
input_tensors: list[Tensor]
|
| 277 |
+
output_tensors: list[Tensor]
|
| 278 |
+
root: int
|
| 279 |
+
op_id: int
|
| 280 |
+
|
| 281 |
+
class PostHookArgs:
|
| 282 |
+
name: HookOpName
|
| 283 |
+
async_op: bool
|
| 284 |
+
work: Work | None
|
| 285 |
+
op_id: int
|
| 286 |
+
|
| 287 |
+
class Store:
|
| 288 |
+
def set(self, key: str, value: str) -> None: ...
|
| 289 |
+
def get(self, key: str) -> bytes: ...
|
| 290 |
+
def add(self, key: str, value: int) -> int: ...
|
| 291 |
+
def check(self, keys: list[str]) -> bool: ...
|
| 292 |
+
def compare_set(
|
| 293 |
+
self,
|
| 294 |
+
key: str,
|
| 295 |
+
expected_value: str,
|
| 296 |
+
desired_value: str,
|
| 297 |
+
) -> bytes: ...
|
| 298 |
+
def delete_key(self, key: str) -> bool: ...
|
| 299 |
+
def multi_get(self, keys: list[str]) -> list[bytes]: ...
|
| 300 |
+
def num_keys(self) -> int: ...
|
| 301 |
+
def set_timeout(self, timeout: timedelta) -> None: ...
|
| 302 |
+
@overload
|
| 303 |
+
def wait(self, keys: list[str]) -> None: ...
|
| 304 |
+
@overload
|
| 305 |
+
def wait(self, keys: list[str], timeout: timedelta) -> None: ...
|
| 306 |
+
def queue_pop(self, key: str, block: bool = True) -> bytes: ...
|
| 307 |
+
def queue_push(self, key: str, value: bytes | str) -> None: ...
|
| 308 |
+
def queue_len(self, key: str) -> int: ...
|
| 309 |
+
def list_keys(self) -> list[str]: ...
|
| 310 |
+
def clone(self) -> Store: ...
|
| 311 |
+
|
| 312 |
+
class FileStore(Store):
|
| 313 |
+
def __init__(self, path: str, numWorkers: int = ...) -> None: ...
|
| 314 |
+
|
| 315 |
+
class HashStore(Store):
|
| 316 |
+
def __init__(self) -> None: ...
|
| 317 |
+
|
| 318 |
+
class FakeStore(Store):
|
| 319 |
+
def __init__(self) -> None: ...
|
| 320 |
+
|
| 321 |
+
class TCPStore(Store):
|
| 322 |
+
def __init__(
|
| 323 |
+
self,
|
| 324 |
+
host_name: str,
|
| 325 |
+
port: int,
|
| 326 |
+
world_size: int | None = ...,
|
| 327 |
+
is_master: bool = ...,
|
| 328 |
+
timeout: timedelta = ...,
|
| 329 |
+
wait_for_workers: bool = ...,
|
| 330 |
+
multi_tenant: bool = ...,
|
| 331 |
+
master_listen_fd: int | None = ...,
|
| 332 |
+
use_libuv: bool | None = ...,
|
| 333 |
+
) -> None: ...
|
| 334 |
+
@property
|
| 335 |
+
def host(self) -> str: ...
|
| 336 |
+
@property
|
| 337 |
+
def port(self) -> int: ...
|
| 338 |
+
|
| 339 |
+
class PrefixStore(Store):
|
| 340 |
+
def __init__(self, prefix: str, store: Store) -> None: ...
|
| 341 |
+
@property
|
| 342 |
+
def underlying_store(self) -> Store: ...
|
| 343 |
+
|
| 344 |
+
class _DistributedBackendOptions:
|
| 345 |
+
def __init__(self) -> None: ...
|
| 346 |
+
@property
|
| 347 |
+
def store(self) -> Store: ...
|
| 348 |
+
@store.setter
|
| 349 |
+
def store(self, store: Store) -> None: ...
|
| 350 |
+
@property
|
| 351 |
+
def group_rank(self) -> int: ...
|
| 352 |
+
@group_rank.setter
|
| 353 |
+
def group_rank(self, rank: int) -> None: ...
|
| 354 |
+
@property
|
| 355 |
+
def group_size(self) -> int: ...
|
| 356 |
+
@group_size.setter
|
| 357 |
+
def group_size(self, size: int) -> None: ...
|
| 358 |
+
@property
|
| 359 |
+
def timeout(self) -> timedelta: ...
|
| 360 |
+
@timeout.setter
|
| 361 |
+
def timeout(self, timeout: timedelta) -> None: ...
|
| 362 |
+
@property
|
| 363 |
+
def group_id(self) -> GroupName: ...
|
| 364 |
+
@group_id.setter
|
| 365 |
+
def group_id(self, group_id: GroupName) -> None: ...
|
| 366 |
+
@property
|
| 367 |
+
def global_ranks_in_group(self) -> list[int]: ...
|
| 368 |
+
@global_ranks_in_group.setter
|
| 369 |
+
def global_ranks_in_group(self, ranks: list[int]) -> None: ...
|
| 370 |
+
process_group: ProcessGroup | None
|
| 371 |
+
split_from: Backend | None
|
| 372 |
+
enable_reconfigure: bool
|
| 373 |
+
|
| 374 |
+
class Work:
|
| 375 |
+
def is_completed(self) -> bool: ...
|
| 376 |
+
def is_success(self) -> bool: ...
|
| 377 |
+
def exception(self) -> Any: ...
|
| 378 |
+
def wait(self, timeout: timedelta = ...) -> bool: ...
|
| 379 |
+
def block_current_stream(self) -> None: ...
|
| 380 |
+
def get_future(self) -> Future: ...
|
| 381 |
+
def source_rank(self) -> int: ...
|
| 382 |
+
def _source_rank(self) -> int: ...
|
| 383 |
+
def result(self) -> list[Tensor]: ...
|
| 384 |
+
def synchronize(self) -> None: ...
|
| 385 |
+
def _get_duration(self) -> float: ...
|
| 386 |
+
def _get_sequence_number(self) -> int: ...
|
| 387 |
+
@property
|
| 388 |
+
def timeout(self) -> timedelta: ...
|
| 389 |
+
def boxed(self) -> ScriptObject: ...
|
| 390 |
+
@staticmethod
|
| 391 |
+
def unbox(obj: ScriptObject) -> Work: ...
|
| 392 |
+
|
| 393 |
+
class Backend:
|
| 394 |
+
class Options:
|
| 395 |
+
def __init__(self, backend: str, timeout: timedelta = ...) -> None: ...
|
| 396 |
+
@property
|
| 397 |
+
def backend(self) -> str: ...
|
| 398 |
+
@property
|
| 399 |
+
def _timeout(self) -> timedelta: ...
|
| 400 |
+
@_timeout.setter
|
| 401 |
+
def _timeout(self, val: timedelta) -> None: ...
|
| 402 |
+
global_ranks_in_group: list[int]
|
| 403 |
+
group_name: GroupName
|
| 404 |
+
use_pg_for_symm_mem_rendezvous: bool
|
| 405 |
+
enable_reconfigure: bool
|
| 406 |
+
|
| 407 |
+
def __init__(
|
| 408 |
+
self,
|
| 409 |
+
rank: int,
|
| 410 |
+
size: int,
|
| 411 |
+
) -> None: ...
|
| 412 |
+
@property
|
| 413 |
+
def supports_splitting(self) -> bool: ...
|
| 414 |
+
@property
|
| 415 |
+
def supports_coalescing(self) -> bool: ...
|
| 416 |
+
@property
|
| 417 |
+
def supports_time_estimate(self) -> bool: ...
|
| 418 |
+
@property
|
| 419 |
+
def supports_shrinking(self) -> bool: ...
|
| 420 |
+
def shrink(
|
| 421 |
+
self,
|
| 422 |
+
ranks_to_exclude: list[int],
|
| 423 |
+
shrink_flags: int = ...,
|
| 424 |
+
opts_override: Backend.Options | None = None,
|
| 425 |
+
) -> Backend: ...
|
| 426 |
+
@property
|
| 427 |
+
def supports_reconfigure(self) -> bool: ...
|
| 428 |
+
def get_reconfigure_handle(self) -> str: ...
|
| 429 |
+
def reconfigure(self, opts: ReconfigureOptions) -> Work: ...
|
| 430 |
+
@property
|
| 431 |
+
def supports_window(self) -> bool: ...
|
| 432 |
+
def new_window(self, tensor: Tensor | None = None) -> Window: ...
|
| 433 |
+
def register_abort_hook(self, hook_id: int, hook: Callable[[], None]) -> None: ...
|
| 434 |
+
def unregister_abort_hook(self, hook_id: int) -> None: ...
|
| 435 |
+
def set_timeout(self, timeout: timedelta) -> None: ...
|
| 436 |
+
def _add_ephemeral_timeout(self, timeout: timedelta) -> None: ...
|
| 437 |
+
@property
|
| 438 |
+
def options(self) -> Options: ...
|
| 439 |
+
def rank(self) -> int: ...
|
| 440 |
+
def size(self) -> int: ...
|
| 441 |
+
def name(self) -> str: ...
|
| 442 |
+
def abort(self) -> None: ...
|
| 443 |
+
def shutdown(self) -> None: ...
|
| 444 |
+
def eager_connect_single_device(self, device: torch.device | None) -> None: ...
|
| 445 |
+
def _set_sequence_number_for_group(self) -> None: ...
|
| 446 |
+
def _set_default_timeout(self, timeout: timedelta) -> None: ...
|
| 447 |
+
def get_error(self) -> ErrorType: ...
|
| 448 |
+
def supports_tensor_alloc(self, device: torch.device) -> bool: ...
|
| 449 |
+
def allocate_tensor(
|
| 450 |
+
self,
|
| 451 |
+
size: int,
|
| 452 |
+
*,
|
| 453 |
+
dtype: torch.dtype,
|
| 454 |
+
device: torch.device,
|
| 455 |
+
) -> Tensor: ...
|
| 456 |
+
@property
|
| 457 |
+
def mem_allocator(self) -> Any: ...
|
| 458 |
+
|
| 459 |
+
class ProcessGroup:
|
| 460 |
+
class BackendType(Enum):
|
| 461 |
+
UNDEFINED = ...
|
| 462 |
+
GLOO = ...
|
| 463 |
+
NCCL = ...
|
| 464 |
+
UCC = ...
|
| 465 |
+
MPI = ...
|
| 466 |
+
XCCL = ...
|
| 467 |
+
CUSTOM = ...
|
| 468 |
+
|
| 469 |
+
def __init__(
|
| 470 |
+
self,
|
| 471 |
+
store: Store,
|
| 472 |
+
rank: int,
|
| 473 |
+
size: int,
|
| 474 |
+
) -> None: ...
|
| 475 |
+
def rank(self) -> int: ...
|
| 476 |
+
def size(self) -> int: ...
|
| 477 |
+
def get_group_store(self) -> Store: ...
|
| 478 |
+
def split_group(
|
| 479 |
+
self,
|
| 480 |
+
new_ranks: list[int],
|
| 481 |
+
timeout: timedelta | None = None,
|
| 482 |
+
opts: Backend.Options | None = None,
|
| 483 |
+
group_name: GroupName | None = None,
|
| 484 |
+
group_desc: str | None = None,
|
| 485 |
+
device_types: list[torch.device] | None = None,
|
| 486 |
+
) -> ProcessGroup | None: ...
|
| 487 |
+
def merge_remote_group(
|
| 488 |
+
self,
|
| 489 |
+
store: Store,
|
| 490 |
+
size: int,
|
| 491 |
+
timeout: timedelta,
|
| 492 |
+
group_name: GroupName | None = None,
|
| 493 |
+
group_desc: str | None = None,
|
| 494 |
+
) -> ProcessGroup: ...
|
| 495 |
+
def abort(self) -> None: ...
|
| 496 |
+
def set_timeout(self, timeout: timedelta) -> None: ...
|
| 497 |
+
def _add_ephemeral_timeout(self, timeout: timedelta) -> None: ...
|
| 498 |
+
def shutdown(self) -> None: ...
|
| 499 |
+
@property
|
| 500 |
+
def supports_reconfigure(self) -> bool: ...
|
| 501 |
+
def get_reconfigure_handle(self) -> str: ...
|
| 502 |
+
def reconfigure(self, opts: ReconfigureOptions) -> Work: ...
|
| 503 |
+
@property
|
| 504 |
+
def supports_window(self) -> bool: ...
|
| 505 |
+
def new_window(self, tensor: Tensor | None = None) -> Window: ...
|
| 506 |
+
def register_abort_hook(self, hook_id: int, hook: Callable[[], None]) -> None: ...
|
| 507 |
+
def unregister_abort_hook(self, hook_id: int) -> None: ...
|
| 508 |
+
def register_pre_hook(
|
| 509 |
+
self, hook_id: int, hook: Callable[[PreHookArgs], None]
|
| 510 |
+
) -> None: ...
|
| 511 |
+
def unregister_pre_hook(self, hook_id: int) -> None: ...
|
| 512 |
+
def register_post_hook(
|
| 513 |
+
self, hook_id: int, hook: Callable[[PostHookArgs], None]
|
| 514 |
+
) -> None: ...
|
| 515 |
+
def unregister_post_hook(self, hook_id: int) -> None: ...
|
| 516 |
+
@overload
|
| 517 |
+
def broadcast(
|
| 518 |
+
self,
|
| 519 |
+
tensors: list[Tensor],
|
| 520 |
+
opts=...,
|
| 521 |
+
) -> Work: ...
|
| 522 |
+
@overload
|
| 523 |
+
def broadcast(
|
| 524 |
+
self,
|
| 525 |
+
tensor: Tensor,
|
| 526 |
+
root: int,
|
| 527 |
+
timeout: timedelta | None = None,
|
| 528 |
+
) -> Work: ...
|
| 529 |
+
@overload
|
| 530 |
+
def allreduce(
|
| 531 |
+
self,
|
| 532 |
+
tensors: list[Tensor],
|
| 533 |
+
opts: AllreduceOptions = ...,
|
| 534 |
+
) -> Work: ...
|
| 535 |
+
@overload
|
| 536 |
+
def allreduce(
|
| 537 |
+
self,
|
| 538 |
+
tensors: list[Tensor],
|
| 539 |
+
op=...,
|
| 540 |
+
timeout: timedelta | None = None,
|
| 541 |
+
) -> Work: ...
|
| 542 |
+
@overload
|
| 543 |
+
def allreduce(
|
| 544 |
+
self,
|
| 545 |
+
tensor: Tensor,
|
| 546 |
+
op=...,
|
| 547 |
+
timeout: timedelta | None = None,
|
| 548 |
+
) -> Work: ...
|
| 549 |
+
def allreduce_coalesced(
|
| 550 |
+
self,
|
| 551 |
+
tensors: list[Tensor],
|
| 552 |
+
opts=...,
|
| 553 |
+
) -> Work: ...
|
| 554 |
+
def reduce_scatter_single_coalesced(
|
| 555 |
+
self,
|
| 556 |
+
outputTensors: list[Tensor],
|
| 557 |
+
inputTensors: list[Tensor],
|
| 558 |
+
opts: ReduceScatterOptions | None = None,
|
| 559 |
+
) -> Work: ...
|
| 560 |
+
def reduce_scatter_tensor_coalesced(
|
| 561 |
+
self,
|
| 562 |
+
outputTensors: list[Tensor],
|
| 563 |
+
inputTensors: list[Tensor],
|
| 564 |
+
opts: ReduceScatterOptions | None = None,
|
| 565 |
+
) -> Work: ...
|
| 566 |
+
@overload
|
| 567 |
+
def reduce(
|
| 568 |
+
self,
|
| 569 |
+
tensors: list[Tensor],
|
| 570 |
+
opts=...,
|
| 571 |
+
) -> Work: ...
|
| 572 |
+
@overload
|
| 573 |
+
def reduce(
|
| 574 |
+
self,
|
| 575 |
+
tensor: Tensor,
|
| 576 |
+
root: int,
|
| 577 |
+
op=...,
|
| 578 |
+
timeout: timedelta | None = None,
|
| 579 |
+
) -> Work: ...
|
| 580 |
+
@overload
|
| 581 |
+
def allgather(
|
| 582 |
+
self,
|
| 583 |
+
output_tensors: list[list[Tensor]],
|
| 584 |
+
input_tensors: list[Tensor],
|
| 585 |
+
opts=...,
|
| 586 |
+
) -> Work: ...
|
| 587 |
+
@overload
|
| 588 |
+
def allgather(
|
| 589 |
+
self,
|
| 590 |
+
output_tensors: list[Tensor],
|
| 591 |
+
input_tensor: Tensor,
|
| 592 |
+
timeout: timedelta | None = None,
|
| 593 |
+
) -> Work: ...
|
| 594 |
+
def all_gather_single(
|
| 595 |
+
self,
|
| 596 |
+
output: Tensor,
|
| 597 |
+
input: Tensor,
|
| 598 |
+
opts=...,
|
| 599 |
+
) -> Work: ...
|
| 600 |
+
def _allgather_base(
|
| 601 |
+
self,
|
| 602 |
+
output: Tensor,
|
| 603 |
+
input: Tensor,
|
| 604 |
+
opts=...,
|
| 605 |
+
) -> Work: ...
|
| 606 |
+
def allgather_coalesced(
|
| 607 |
+
self,
|
| 608 |
+
output_lists: list[list[Tensor]],
|
| 609 |
+
input_list: list[Tensor],
|
| 610 |
+
opts=...,
|
| 611 |
+
) -> Work: ...
|
| 612 |
+
def all_gather_single_coalesced(
|
| 613 |
+
self,
|
| 614 |
+
output_lists: list[Tensor],
|
| 615 |
+
input_list: list[Tensor],
|
| 616 |
+
opts=...,
|
| 617 |
+
) -> Work: ...
|
| 618 |
+
def allgather_into_tensor_coalesced(
|
| 619 |
+
self,
|
| 620 |
+
output_lists: list[Tensor],
|
| 621 |
+
input_list: list[Tensor],
|
| 622 |
+
opts=...,
|
| 623 |
+
) -> Work: ...
|
| 624 |
+
@overload
|
| 625 |
+
def gather(
|
| 626 |
+
self,
|
| 627 |
+
output_tensors: list[list[Tensor]],
|
| 628 |
+
input_tensors: list[Tensor],
|
| 629 |
+
opts=...,
|
| 630 |
+
) -> Work: ...
|
| 631 |
+
@overload
|
| 632 |
+
def gather(
|
| 633 |
+
self,
|
| 634 |
+
output_tensors: list[Tensor],
|
| 635 |
+
input_tensor: Tensor,
|
| 636 |
+
root: int,
|
| 637 |
+
timeout: timedelta | None = None,
|
| 638 |
+
) -> Work: ...
|
| 639 |
+
def gather_single(
|
| 640 |
+
self,
|
| 641 |
+
output: Tensor,
|
| 642 |
+
input: Tensor,
|
| 643 |
+
opts=...,
|
| 644 |
+
) -> Work: ...
|
| 645 |
+
def gather_into_tensor(
|
| 646 |
+
self,
|
| 647 |
+
output: Tensor,
|
| 648 |
+
input: Tensor,
|
| 649 |
+
opts=...,
|
| 650 |
+
) -> Work: ...
|
| 651 |
+
@overload
|
| 652 |
+
def scatter(
|
| 653 |
+
self,
|
| 654 |
+
output_tensors: list[Tensor],
|
| 655 |
+
input_tensors: list[list[Tensor]],
|
| 656 |
+
opts=...,
|
| 657 |
+
) -> Work: ...
|
| 658 |
+
@overload
|
| 659 |
+
def scatter(
|
| 660 |
+
self,
|
| 661 |
+
output_tensor: Tensor,
|
| 662 |
+
input_tensors: list[Tensor],
|
| 663 |
+
root: int,
|
| 664 |
+
timeout: timedelta | None = None,
|
| 665 |
+
) -> Work: ...
|
| 666 |
+
@overload
|
| 667 |
+
def reduce_scatter(
|
| 668 |
+
self,
|
| 669 |
+
output_tensors: list[Tensor],
|
| 670 |
+
input_tensors: list[list[Tensor]],
|
| 671 |
+
opts=...,
|
| 672 |
+
) -> Work: ...
|
| 673 |
+
@overload
|
| 674 |
+
def reduce_scatter(
|
| 675 |
+
self,
|
| 676 |
+
output_tensors: Tensor,
|
| 677 |
+
input_tensor: list[Tensor],
|
| 678 |
+
op=...,
|
| 679 |
+
timeout: timedelta | None = None,
|
| 680 |
+
) -> Work: ...
|
| 681 |
+
def reduce_scatter_single(
|
| 682 |
+
self,
|
| 683 |
+
outputTensor: Tensor,
|
| 684 |
+
inputTensor: Tensor,
|
| 685 |
+
opts: ReduceScatterOptions | None,
|
| 686 |
+
) -> Work: ...
|
| 687 |
+
def _reduce_scatter_base(
|
| 688 |
+
self,
|
| 689 |
+
outputTensor: Tensor,
|
| 690 |
+
inputTensor: Tensor,
|
| 691 |
+
opts: ReduceScatterOptions | None,
|
| 692 |
+
) -> Work: ...
|
| 693 |
+
@overload
|
| 694 |
+
def all_to_all_single(
|
| 695 |
+
self,
|
| 696 |
+
output_tensor: Tensor,
|
| 697 |
+
input_tensor: Tensor,
|
| 698 |
+
output_split_sizes: list[int],
|
| 699 |
+
input_split_sizes: list[int],
|
| 700 |
+
opts=...,
|
| 701 |
+
) -> Work: ...
|
| 702 |
+
@overload
|
| 703 |
+
def all_to_all_single(
|
| 704 |
+
self,
|
| 705 |
+
output: Tensor,
|
| 706 |
+
input: Tensor,
|
| 707 |
+
output_split_sizes: list[int],
|
| 708 |
+
input_split_sizes: list[int],
|
| 709 |
+
timeout: timedelta | None = None,
|
| 710 |
+
) -> Work: ...
|
| 711 |
+
@overload
|
| 712 |
+
def alltoall_base(
|
| 713 |
+
self,
|
| 714 |
+
output_tensor: Tensor,
|
| 715 |
+
input_tensor: Tensor,
|
| 716 |
+
output_split_sizes: list[int],
|
| 717 |
+
input_split_sizes: list[int],
|
| 718 |
+
opts=...,
|
| 719 |
+
) -> Work: ...
|
| 720 |
+
@overload
|
| 721 |
+
def alltoall_base(
|
| 722 |
+
self,
|
| 723 |
+
output: Tensor,
|
| 724 |
+
input: Tensor,
|
| 725 |
+
output_split_sizes: list[int],
|
| 726 |
+
input_split_sizes: list[int],
|
| 727 |
+
timeout: timedelta | None = None,
|
| 728 |
+
) -> Work: ...
|
| 729 |
+
@overload
|
| 730 |
+
def alltoall(
|
| 731 |
+
self,
|
| 732 |
+
output_tensor: list[Tensor],
|
| 733 |
+
input_tensor: list[Tensor],
|
| 734 |
+
opts=...,
|
| 735 |
+
) -> Work: ...
|
| 736 |
+
@overload
|
| 737 |
+
def alltoall(
|
| 738 |
+
self,
|
| 739 |
+
output: list[Tensor],
|
| 740 |
+
input: list[Tensor],
|
| 741 |
+
timeout: timedelta | None = None,
|
| 742 |
+
) -> Work: ...
|
| 743 |
+
def send(
|
| 744 |
+
self,
|
| 745 |
+
tensors: list[Tensor],
|
| 746 |
+
dstRank: int,
|
| 747 |
+
tag: int,
|
| 748 |
+
) -> Work: ...
|
| 749 |
+
def recv(
|
| 750 |
+
self,
|
| 751 |
+
tensors: list[Tensor],
|
| 752 |
+
srcRank: int,
|
| 753 |
+
tag: int,
|
| 754 |
+
) -> Work: ...
|
| 755 |
+
def recv_anysource(self, tensors: list[Tensor], tag: int) -> Work: ...
|
| 756 |
+
@overload
|
| 757 |
+
def barrier(self, opts=...) -> Work: ...
|
| 758 |
+
@overload
|
| 759 |
+
def barrier(self, timeout: timedelta | None = None) -> Work: ...
|
| 760 |
+
def boxed(self) -> ScriptObject: ...
|
| 761 |
+
@staticmethod
|
| 762 |
+
def unbox(obj: ScriptObject) -> ProcessGroup: ...
|
| 763 |
+
def _start_coalescing(self, device: torch.device) -> None: ...
|
| 764 |
+
def _end_coalescing(self, device: torch.device) -> Work: ...
|
| 765 |
+
def _get_backend_name(self) -> str: ...
|
| 766 |
+
def _backend_id(self, backend_type: BackendType) -> int: ...
|
| 767 |
+
@property
|
| 768 |
+
def _device_types(self) -> list[torch.device]: ...
|
| 769 |
+
def get_backend(self, device: torch.device) -> Backend: ...
|
| 770 |
+
def _get_backend(self, device: torch.device) -> Backend: ...
|
| 771 |
+
def _set_default_backend(self, backend_type: BackendType) -> None: ...
|
| 772 |
+
def _register_backend(
|
| 773 |
+
self,
|
| 774 |
+
device: torch.device,
|
| 775 |
+
backend_type: BackendType,
|
| 776 |
+
backend: Backend | None,
|
| 777 |
+
) -> None: ...
|
| 778 |
+
def _set_group_name(self, name: GroupName) -> None: ...
|
| 779 |
+
def _set_group_desc(self, desc: str) -> None: ...
|
| 780 |
+
def name(self) -> str: ...
|
| 781 |
+
def _has_hooks(self) -> bool: ...
|
| 782 |
+
def _wait_for_pending_works(self) -> None: ...
|
| 783 |
+
@property
|
| 784 |
+
def bound_device_id(self) -> torch.device | None: ...
|
| 785 |
+
@bound_device_id.setter
|
| 786 |
+
def bound_device_id(self, device: torch.device | None) -> None: ...
|
| 787 |
+
@property
|
| 788 |
+
def use_pg_for_symm_mem_rendezvous(self) -> bool:
|
| 789 |
+
"""When True, symmetric memory rendezvous exchanges metadata via this
|
| 790 |
+
PG's NCCL allgather instead of TCPStore, which gets overloaded at large
|
| 791 |
+
rank counts. This will lazily create the NCCL communicator if it doesn't
|
| 792 |
+
already exist. If this PG is only used for symmetric memory (no regular
|
| 793 |
+
collectives), consider calling ``abort()`` after rendezvous to release
|
| 794 |
+
the communicator."""
|
| 795 |
+
@use_pg_for_symm_mem_rendezvous.setter
|
| 796 |
+
def use_pg_for_symm_mem_rendezvous(self, value: bool) -> None: ...
|
| 797 |
+
@property
|
| 798 |
+
def group_name(self) -> GroupName: ...
|
| 799 |
+
@property
|
| 800 |
+
def group_desc(self) -> str: ...
|
| 801 |
+
|
| 802 |
+
class FakeProcessGroup(Backend):
|
| 803 |
+
@staticmethod
|
| 804 |
+
def _create_internal(rank: int, world_size: int) -> FakeProcessGroup: ...
|
| 805 |
+
|
| 806 |
+
class FakeWork(Work):
|
| 807 |
+
seq_id: int
|
| 808 |
+
def __init__(self) -> None: ...
|
| 809 |
+
def wait(self, timeout: timedelta = ...) -> bool: ...
|
| 810 |
+
def getFuture(self) -> Future: ...
|
| 811 |
+
|
| 812 |
+
class NCCLXStub(Backend):
|
| 813 |
+
def __init__(
|
| 814 |
+
self,
|
| 815 |
+
store: Store,
|
| 816 |
+
rank: int,
|
| 817 |
+
size: int,
|
| 818 |
+
options: ProcessGroupNCCL.Options = ...,
|
| 819 |
+
) -> None: ...
|
| 820 |
+
|
| 821 |
+
class PythonCallbackWork(Work):
|
| 822 |
+
def __init__(self, callback: Callable[[timedelta], bool]) -> None: ...
|
| 823 |
+
def wait(self, timeout: timedelta = ...) -> bool: ...
|
| 824 |
+
def get_future(self) -> Future: ...
|
| 825 |
+
|
| 826 |
+
class ProcessGroupGloo(Backend):
|
| 827 |
+
class Device: ...
|
| 828 |
+
|
| 829 |
+
class Options(Backend.Options):
|
| 830 |
+
devices: list[ProcessGroupGloo.Device]
|
| 831 |
+
threads: int
|
| 832 |
+
|
| 833 |
+
def __init__(self): ...
|
| 834 |
+
|
| 835 |
+
def __init__(
|
| 836 |
+
self,
|
| 837 |
+
store: Store,
|
| 838 |
+
rank: int,
|
| 839 |
+
size: int,
|
| 840 |
+
timeout: timedelta = ...,
|
| 841 |
+
enable_reconfigure: bool = ...,
|
| 842 |
+
) -> None: ...
|
| 843 |
+
@staticmethod
|
| 844 |
+
def create_device(hostname="", interface="", lazy_init=None) -> Device: ...
|
| 845 |
+
@staticmethod
|
| 846 |
+
def create_default_device(lazy_init=None) -> Device: ...
|
| 847 |
+
def _set_default_timeout(self, timeout) -> None: ...
|
| 848 |
+
@property
|
| 849 |
+
def options(self) -> Options: ... # type: ignore[override]
|
| 850 |
+
|
| 851 |
+
class _ProcessGroupWrapper(Backend):
|
| 852 |
+
def __init__(self, pg: Backend, gloo_pg: ProcessGroupGloo) -> None: ...
|
| 853 |
+
wrapped_pg: Backend
|
| 854 |
+
@property
|
| 855 |
+
def options(self) -> Backend.Options: ...
|
| 856 |
+
def get_error(self) -> ErrorType: ...
|
| 857 |
+
|
| 858 |
+
class ErrorType(Enum):
|
| 859 |
+
SUCCESS = ...
|
| 860 |
+
TIMEOUT = ...
|
| 861 |
+
COMM_ERROR = ...
|
| 862 |
+
REMOTE_ERROR = ...
|
| 863 |
+
|
| 864 |
+
class ProcessGroupNCCL(Backend):
|
| 865 |
+
class NCCLConfig:
|
| 866 |
+
blocking: int
|
| 867 |
+
cga_cluster_size: int
|
| 868 |
+
min_ctas: int
|
| 869 |
+
max_ctas: int
|
| 870 |
+
def unsafe_get_ptr(self) -> int: ...
|
| 871 |
+
|
| 872 |
+
class Options(Backend.Options):
|
| 873 |
+
config: ProcessGroupNCCL.NCCLConfig
|
| 874 |
+
is_high_priority_stream: bool
|
| 875 |
+
split_from: ProcessGroupNCCL
|
| 876 |
+
split_color: int
|
| 877 |
+
|
| 878 |
+
def __init__(self, is_high_priority_stream: bool = False): ...
|
| 879 |
+
|
| 880 |
+
def __init__(
|
| 881 |
+
self,
|
| 882 |
+
store: Store,
|
| 883 |
+
rank: int,
|
| 884 |
+
size: int,
|
| 885 |
+
options: Options,
|
| 886 |
+
) -> None: ...
|
| 887 |
+
def _group_start(self) -> None: ...
|
| 888 |
+
def _group_end(self) -> None: ...
|
| 889 |
+
def _start_time_estimate(self) -> None: ...
|
| 890 |
+
def _end_time_estimate(self) -> float: ...
|
| 891 |
+
def _set_default_timeout(self, timeout) -> None: ...
|
| 892 |
+
def perform_nocolor_split(self, device: torch.device) -> None: ...
|
| 893 |
+
def register_mem_pool(
|
| 894 |
+
self, pool: torch.cuda.MemPool, symm: bool = False
|
| 895 |
+
) -> None: ...
|
| 896 |
+
def deregister_mem_pool(self, pool: torch.cuda.MemPool) -> None: ...
|
| 897 |
+
def comm_split_count(self) -> int: ...
|
| 898 |
+
def abort(self) -> None: ...
|
| 899 |
+
def _is_initialized(self) -> bool: ...
|
| 900 |
+
@property
|
| 901 |
+
def uid(self) -> int: ...
|
| 902 |
+
@property
|
| 903 |
+
def options(self) -> Options: ... # type: ignore[override]
|
| 904 |
+
@staticmethod
|
| 905 |
+
def get_build_nccl_version(self) -> tuple[int, int, int]: ...
|
| 906 |
+
@staticmethod
|
| 907 |
+
def get_runtime_nccl_version(self) -> tuple[int, int, int]: ...
|
| 908 |
+
|
| 909 |
+
class ProcessGroupUCC(Backend):
|
| 910 |
+
def __init__(
|
| 911 |
+
self,
|
| 912 |
+
store: Store,
|
| 913 |
+
rank: int,
|
| 914 |
+
size: int,
|
| 915 |
+
timeout: timedelta,
|
| 916 |
+
) -> None: ...
|
| 917 |
+
|
| 918 |
+
class ProcessGroupMPI(Backend):
|
| 919 |
+
def __init__(
|
| 920 |
+
self,
|
| 921 |
+
rank: int,
|
| 922 |
+
size: int,
|
| 923 |
+
pgComm: int,
|
| 924 |
+
) -> None: ...
|
| 925 |
+
@staticmethod
|
| 926 |
+
def create(ranks: list[int]) -> ProcessGroupMPI: ...
|
| 927 |
+
|
| 928 |
+
def _compute_bucket_assignment_by_size(
|
| 929 |
+
tensors: list[Tensor],
|
| 930 |
+
bucket_size_limits: list[int],
|
| 931 |
+
expect_sparse_gradient: list[bool] = ...,
|
| 932 |
+
tensor_indices: list[int] = ...,
|
| 933 |
+
) -> tuple[list[list[int]], list[int]]: ...
|
| 934 |
+
def _broadcast_coalesced(
|
| 935 |
+
process_group: ProcessGroup,
|
| 936 |
+
tensors: list[Tensor],
|
| 937 |
+
buffer_size: int,
|
| 938 |
+
src: int,
|
| 939 |
+
): ...
|
| 940 |
+
def _test_python_store(store: Store): ...
|
| 941 |
+
def _verify_params_across_processes(
|
| 942 |
+
process_group: ProcessGroup,
|
| 943 |
+
params: list[Tensor],
|
| 944 |
+
logger: Logger | None,
|
| 945 |
+
): ...
|
| 946 |
+
def _make_nccl_premul_sum(factor: float | Tensor) -> ReduceOp: ...
|
| 947 |
+
def _register_process_group(
|
| 948 |
+
group_name: GroupName,
|
| 949 |
+
process_group: ProcessGroup,
|
| 950 |
+
) -> None: ...
|
| 951 |
+
def _resolve_process_group(group_name: GroupName) -> ProcessGroup: ...
|
| 952 |
+
def _create_work_from_future(future: Future) -> Work: ...
|
| 953 |
+
def _register_work(tensor: torch.Tensor, work: Work) -> ProcessGroup: ...
|
| 954 |
+
def _get_work_registry_size() -> int: ...
|
| 955 |
+
def _set_allow_inflight_collective_as_graph_input(
|
| 956 |
+
value: bool,
|
| 957 |
+
) -> None: ...
|
| 958 |
+
def _allow_inflight_collective_as_graph_input() -> bool: ...
|
| 959 |
+
def _unregister_all_process_groups() -> None: ...
|
| 960 |
+
def _unregister_process_group(group_name: GroupName) -> None: ...
|
| 961 |
+
|
| 962 |
+
# Initializes the device state in CUmodule so that it's able to perform NVSHMEM
|
| 963 |
+
# operations. CUmodule is a pointer to a CUDA module, carried by a int64 in
|
| 964 |
+
# Python. At C++ interface, it is converted to a uintptr_t.
|
| 965 |
+
def _nvshmemx_cumodule_init(module: int) -> None: ...
|
| 966 |
+
|
| 967 |
+
# Check if NVSHMEM is available on current system.
|
| 968 |
+
def _is_nvshmem_available() -> bool: ...
|
| 969 |
+
def _register_external_nccl_comm(
|
| 970 |
+
group_name: str, comm_ptr: int, device: torch.device
|
| 971 |
+
) -> None: ...
|
| 972 |
+
def _unregister_external_nccl_comm(group_name: str, device: torch.device) -> None: ...
|
| 973 |
+
|
| 974 |
+
# NCCL EP (contrib/nccl_ep) bindings; only registered in USE_C10D_NCCL builds.
|
| 975 |
+
class _NcclEpGroup:
|
| 976 |
+
@staticmethod
|
| 977 |
+
def create(
|
| 978 |
+
pg: ProcessGroup,
|
| 979 |
+
num_experts: int,
|
| 980 |
+
max_dispatch_tokens_per_rank: int,
|
| 981 |
+
max_recv_tokens_per_rank: int,
|
| 982 |
+
max_token_bytes: int,
|
| 983 |
+
) -> _NcclEpGroup: ...
|
| 984 |
+
|
| 985 |
+
class _NcclEpHandle:
|
| 986 |
+
@staticmethod
|
| 987 |
+
def create(
|
| 988 |
+
group: _NcclEpGroup,
|
| 989 |
+
topk_idx: Tensor,
|
| 990 |
+
recv_expert_counter: Tensor | None = None,
|
| 991 |
+
) -> _NcclEpHandle: ...
|
| 992 |
+
def get_num_recv_tokens(self) -> int: ...
|
| 993 |
+
|
| 994 |
+
# handle is Any: the Python layer (torch.distributed._token_switch.Routing)
|
| 995 |
+
# holds it opaquely as `object`, so callers don't carry the concrete type.
|
| 996 |
+
def _nccl_ep_dispatch(
|
| 997 |
+
handle: Any,
|
| 998 |
+
tokens: Tensor,
|
| 999 |
+
topk_weights: Tensor,
|
| 1000 |
+
out_tokens: Tensor,
|
| 1001 |
+
out_topk_weights: Tensor,
|
| 1002 |
+
out_topk_idx: Tensor,
|
| 1003 |
+
) -> None: ...
|
| 1004 |
+
def _nccl_ep_combine(
|
| 1005 |
+
handle: Any,
|
| 1006 |
+
expert_tokens: Tensor,
|
| 1007 |
+
out_tokens: Tensor,
|
| 1008 |
+
) -> None: ...
|
| 1009 |
+
|
| 1010 |
+
class _SymmetricMemory:
|
| 1011 |
+
@staticmethod
|
| 1012 |
+
def set_group_info(
|
| 1013 |
+
group_name: str,
|
| 1014 |
+
rank: int,
|
| 1015 |
+
world_size: int,
|
| 1016 |
+
store: Store,
|
| 1017 |
+
) -> None: ...
|
| 1018 |
+
@staticmethod
|
| 1019 |
+
def empty_strided_p2p(
|
| 1020 |
+
size: torch.types._size,
|
| 1021 |
+
stride: torch.types._size,
|
| 1022 |
+
dtype: torch.dtype,
|
| 1023 |
+
device: torch.device,
|
| 1024 |
+
group_name: str | None = None,
|
| 1025 |
+
alloc_id: int | None = None,
|
| 1026 |
+
) -> torch.Tensor: ...
|
| 1027 |
+
@staticmethod
|
| 1028 |
+
def has_multicast_support(
|
| 1029 |
+
device_type: DeviceType,
|
| 1030 |
+
device_idx: int,
|
| 1031 |
+
) -> bool: ...
|
| 1032 |
+
# Set Symmetric Memory allocation backend.
|
| 1033 |
+
@staticmethod
|
| 1034 |
+
def set_backend(name: str) -> None: ...
|
| 1035 |
+
@staticmethod
|
| 1036 |
+
def get_backend(device: torch.device) -> str | None: ...
|
| 1037 |
+
@staticmethod
|
| 1038 |
+
def is_symm_mem_tensor(tensor: torch.Tensor) -> bool: ...
|
| 1039 |
+
@staticmethod
|
| 1040 |
+
def get_mempool_allocator(device: torch.device) -> Any: ...
|
| 1041 |
+
signal_pad_size: int
|
| 1042 |
+
@property
|
| 1043 |
+
def rank(self) -> int: ...
|
| 1044 |
+
@property
|
| 1045 |
+
def world_size(self) -> int: ...
|
| 1046 |
+
@staticmethod
|
| 1047 |
+
def rendezvous(
|
| 1048 |
+
tensor: torch.Tensor, group_name: str | None = None
|
| 1049 |
+
) -> _SymmetricMemory: ...
|
| 1050 |
+
def boxed(self) -> ScriptObject: ...
|
| 1051 |
+
def get_buffer(
|
| 1052 |
+
self,
|
| 1053 |
+
rank: int,
|
| 1054 |
+
sizes: torch.types._size,
|
| 1055 |
+
dtype: torch.dtype,
|
| 1056 |
+
storage_offset: int | None = 0,
|
| 1057 |
+
) -> torch.Tensor: ...
|
| 1058 |
+
def get_signal_pad(
|
| 1059 |
+
self,
|
| 1060 |
+
rank: int,
|
| 1061 |
+
sizes: torch.types._size = [],
|
| 1062 |
+
dtype: torch.dtype | None = None,
|
| 1063 |
+
storage_offset: int | None = 0,
|
| 1064 |
+
) -> torch.Tensor: ...
|
| 1065 |
+
def barrier(self, channel: int = 0, timeout_ms: int = 0) -> None: ...
|
| 1066 |
+
def put_signal(
|
| 1067 |
+
self,
|
| 1068 |
+
dst_rank: int,
|
| 1069 |
+
channel: int = 0,
|
| 1070 |
+
timeout_ms: int = 0,
|
| 1071 |
+
) -> None: ...
|
| 1072 |
+
def wait_signal(
|
| 1073 |
+
self,
|
| 1074 |
+
src_rank: int,
|
| 1075 |
+
channel: int = 0,
|
| 1076 |
+
timeout_ms: int = 0,
|
| 1077 |
+
) -> None: ...
|
| 1078 |
+
def get_remote_tensor(
|
| 1079 |
+
self,
|
| 1080 |
+
peer: int,
|
| 1081 |
+
sizes: torch.types._size,
|
| 1082 |
+
dtype: torch.dtype,
|
| 1083 |
+
) -> torch.Tensor: ...
|
| 1084 |
+
@staticmethod
|
| 1085 |
+
def memset32(
|
| 1086 |
+
tensor: torch.Tensor, offset: int, val: int, count: int = 1
|
| 1087 |
+
) -> torch.Tensor: ...
|
| 1088 |
+
@staticmethod
|
| 1089 |
+
def stream_write_value32(
|
| 1090 |
+
tensor: torch.Tensor, offset: int, val: int
|
| 1091 |
+
) -> torch.Tensor: ...
|
| 1092 |
+
@property
|
| 1093 |
+
def buffer_ptrs(self) -> list[int]: ...
|
| 1094 |
+
@property
|
| 1095 |
+
def buffer_ptrs_dev(self) -> int: ...
|
| 1096 |
+
@property
|
| 1097 |
+
def signal_pad_ptrs(self) -> list[int]: ...
|
| 1098 |
+
@property
|
| 1099 |
+
def signal_pad_ptrs_dev(self) -> int: ...
|
| 1100 |
+
@property
|
| 1101 |
+
def multicast_ptr(self) -> int: ...
|
| 1102 |
+
@property
|
| 1103 |
+
def buffer_size(self) -> int: ...
|
| 1104 |
+
@property
|
| 1105 |
+
def offset(self) -> int: ...
|
| 1106 |
+
@property
|
| 1107 |
+
def device(self) -> torch.device: ...
|
| 1108 |
+
|
| 1109 |
+
class ProcessGroupXCCL(Backend):
|
| 1110 |
+
class Options(Backend.Options):
|
| 1111 |
+
is_high_priority_stream: bool
|
| 1112 |
+
|
| 1113 |
+
def __init__(self, is_high_priority_stream: bool = False): ...
|
| 1114 |
+
|
| 1115 |
+
def __init__(
|
| 1116 |
+
self,
|
| 1117 |
+
store: Store,
|
| 1118 |
+
rank: int,
|
| 1119 |
+
size: int,
|
| 1120 |
+
options: Options,
|
| 1121 |
+
) -> None: ...
|
| 1122 |
+
@property
|
| 1123 |
+
def options(self) -> Options: ... # type: ignore[override]
|
| 1124 |
+
@property
|
| 1125 |
+
def uid(self) -> int: ...
|
| 1126 |
+
def _is_initialized(self) -> bool: ...
|
| 1127 |
+
def _set_enable_nan_check(self, enable_nan_check: bool) -> None: ...
|
| 1128 |
+
def _set_default_timeout(self, timeout) -> None: ...
|
| 1129 |
+
def _dump_xccl_trace_json(
|
| 1130 |
+
self, includeCollectives: bool = False, onlyActive: bool = False
|
| 1131 |
+
) -> str: ...
|
| 1132 |
+
def _reset_fr_recording_xccl(self) -> None: ...
|
| 1133 |
+
|
| 1134 |
+
class ProcessGroupNCCL2(Backend):
|
| 1135 |
+
Options = ProcessGroupNCCL.Options
|
| 1136 |
+
|
| 1137 |
+
def __init__(
|
| 1138 |
+
self,
|
| 1139 |
+
store: Store,
|
| 1140 |
+
rank: int,
|
| 1141 |
+
size: int,
|
| 1142 |
+
options: ProcessGroupNCCL.Options,
|
| 1143 |
+
) -> None: ...
|
| 1144 |
+
def get_error(self) -> ErrorType: ...
|
| 1145 |
+
@property
|
| 1146 |
+
def options(self) -> ProcessGroupNCCL.Options: ...
|
| 1147 |
+
|
| 1148 |
+
class ProcessGroupNCCLLazy(Backend):
|
| 1149 |
+
def __init__(
|
| 1150 |
+
self,
|
| 1151 |
+
store: Store,
|
| 1152 |
+
rank: int,
|
| 1153 |
+
size: int,
|
| 1154 |
+
options: ProcessGroupNCCL.Options,
|
| 1155 |
+
) -> None: ...
|
| 1156 |
+
def get_error(self) -> ErrorType: ...
|
| 1157 |
+
def _num_active_channels(self) -> int: ...
|
| 1158 |
+
|
| 1159 |
+
class FlightRecorderHook:
|
| 1160 |
+
@staticmethod
|
| 1161 |
+
def attach(pg: ProcessGroup) -> FlightRecorderHook: ...
|
| 1162 |
+
def remove(self) -> None: ...
|
| 1163 |
+
|
| 1164 |
+
class NanCheckHook:
|
| 1165 |
+
@staticmethod
|
| 1166 |
+
def attach(pg: ProcessGroup) -> NanCheckHook: ...
|
| 1167 |
+
def remove(self) -> None: ...
|
| 1168 |
+
|
| 1169 |
+
def _set_process_group(pg: ProcessGroup) -> None: ...
|
| 1170 |
+
def _current_process_group() -> ProcessGroup: ...
|
| 1171 |
+
|
| 1172 |
+
class _Request:
|
| 1173 |
+
def body(self) -> bytes: ...
|
| 1174 |
+
def get_param(self, str) -> str: ...
|
| 1175 |
+
|
| 1176 |
+
class _Response:
|
| 1177 |
+
def set_content(self, content: str | bytes, content_type: str) -> None: ...
|
| 1178 |
+
def set_status(self, status: int) -> None: ...
|
| 1179 |
+
|
| 1180 |
+
def _register_handler(
|
| 1181 |
+
name: str, handler: Callable[[_Request, _Response], None]
|
| 1182 |
+
) -> None: ...
|
| 1183 |
+
def _set_comm_profiling_name(name: str) -> None: ...
|
| 1184 |
+
def _get_comm_profiling_name() -> str: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_distributed_rpc.pyi
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
# mypy: disable-error-code="type-arg"
|
| 3 |
+
from datetime import timedelta
|
| 4 |
+
from typing import Any, Generic, overload, TypeVar
|
| 5 |
+
|
| 6 |
+
import torch
|
| 7 |
+
from torch._C import Future
|
| 8 |
+
from torch._C._autograd import ProfilerEvent
|
| 9 |
+
from torch._C._distributed_c10d import Store
|
| 10 |
+
from torch._C._profiler import ProfilerConfig
|
| 11 |
+
|
| 12 |
+
# This module is defined in torch/csrc/distributed/rpc/init.cpp
|
| 13 |
+
|
| 14 |
+
_DEFAULT_INIT_METHOD: str
|
| 15 |
+
_DEFAULT_NUM_WORKER_THREADS: int
|
| 16 |
+
_UNSET_RPC_TIMEOUT: float
|
| 17 |
+
_DEFAULT_RPC_TIMEOUT_SEC: float
|
| 18 |
+
|
| 19 |
+
_T = TypeVar("_T")
|
| 20 |
+
|
| 21 |
+
class RpcBackendOptions:
|
| 22 |
+
rpc_timeout: float
|
| 23 |
+
init_method: str
|
| 24 |
+
def __init__(
|
| 25 |
+
self,
|
| 26 |
+
rpc_timeout: float = ...,
|
| 27 |
+
init_method: str = ...,
|
| 28 |
+
) -> None: ...
|
| 29 |
+
|
| 30 |
+
class WorkerInfo:
|
| 31 |
+
def __init__(self, name: str, worker_id: int) -> None: ...
|
| 32 |
+
@property
|
| 33 |
+
def name(self) -> str: ...
|
| 34 |
+
@property
|
| 35 |
+
def id(self) -> int: ...
|
| 36 |
+
def __eq__(self, other: object) -> bool: ...
|
| 37 |
+
|
| 38 |
+
class RpcAgent:
|
| 39 |
+
def join(self, shutdown: bool = False, timeout: float = 0): ...
|
| 40 |
+
def sync(self): ...
|
| 41 |
+
def shutdown(self): ...
|
| 42 |
+
@overload
|
| 43 |
+
def get_worker_info(self) -> WorkerInfo: ...
|
| 44 |
+
@overload
|
| 45 |
+
def get_worker_info(self, workerName: str) -> WorkerInfo: ...
|
| 46 |
+
def get_worker_infos(self) -> list[WorkerInfo]: ...
|
| 47 |
+
def _get_device_map(self, dst: WorkerInfo) -> dict[torch.device, torch.device]: ...
|
| 48 |
+
def get_debug_info(self) -> dict[str, str]: ...
|
| 49 |
+
def get_metrics(self) -> dict[str, str]: ...
|
| 50 |
+
|
| 51 |
+
class PyRRef(Generic[_T]):
|
| 52 |
+
def __init__(self, value: _T, type_hint: Any = None) -> None: ...
|
| 53 |
+
def is_owner(self) -> bool: ...
|
| 54 |
+
def confirmed_by_owner(self) -> bool: ...
|
| 55 |
+
def owner(self) -> WorkerInfo: ...
|
| 56 |
+
def owner_name(self) -> str: ...
|
| 57 |
+
def to_here(self, timeout: float = ...) -> _T: ...
|
| 58 |
+
def local_value(self) -> Any: ...
|
| 59 |
+
def rpc_sync(self, timeout: float = ...) -> Any: ...
|
| 60 |
+
def rpc_async(self, timeout: float = ...) -> Any: ...
|
| 61 |
+
def remote(self, timeout: float = ...) -> Any: ...
|
| 62 |
+
def _serialize(self) -> tuple: ...
|
| 63 |
+
@staticmethod
|
| 64 |
+
def _deserialize(tp: tuple) -> PyRRef: ...
|
| 65 |
+
def _get_type(self) -> type[_T]: ...
|
| 66 |
+
def _get_future(self) -> Future[_T]: ...
|
| 67 |
+
def _get_profiling_future(self) -> Future[_T]: ...
|
| 68 |
+
def _set_profiling_future(self, profilingFuture: Future[_T]): ...
|
| 69 |
+
|
| 70 |
+
class _TensorPipeRpcBackendOptionsBase(RpcBackendOptions):
|
| 71 |
+
num_worker_threads: int
|
| 72 |
+
device_maps: dict[str, dict[torch.device, torch.device]]
|
| 73 |
+
devices: list[torch.device]
|
| 74 |
+
def __init__(
|
| 75 |
+
self,
|
| 76 |
+
num_worker_threads: int,
|
| 77 |
+
_transports: list | None,
|
| 78 |
+
_channels: list | None,
|
| 79 |
+
rpc_timeout: float = ...,
|
| 80 |
+
init_method: str = ...,
|
| 81 |
+
device_maps: dict[str, dict[torch.device, torch.device]] = {},
|
| 82 |
+
devices: list[torch.device] = [],
|
| 83 |
+
) -> None: ...
|
| 84 |
+
def _set_device_map(
|
| 85 |
+
self,
|
| 86 |
+
to: str,
|
| 87 |
+
device_map: dict[torch.device, torch.device],
|
| 88 |
+
): ...
|
| 89 |
+
|
| 90 |
+
class TensorPipeAgent(RpcAgent):
|
| 91 |
+
def __init__(
|
| 92 |
+
self,
|
| 93 |
+
store: Store,
|
| 94 |
+
name: str,
|
| 95 |
+
worker_id: int,
|
| 96 |
+
world_size: int | None,
|
| 97 |
+
opts: _TensorPipeRpcBackendOptionsBase,
|
| 98 |
+
reverse_device_maps: dict[str, dict[torch.device, torch.device]],
|
| 99 |
+
devices: list[torch.device],
|
| 100 |
+
) -> None: ...
|
| 101 |
+
def join(self, shutdown: bool = False, timeout: float = 0): ...
|
| 102 |
+
def shutdown(self): ...
|
| 103 |
+
@overload
|
| 104 |
+
def get_worker_info(self) -> WorkerInfo: ...
|
| 105 |
+
@overload
|
| 106 |
+
def get_worker_info(self, workerName: str) -> WorkerInfo: ...
|
| 107 |
+
@overload
|
| 108 |
+
def get_worker_info(self, id: int) -> WorkerInfo: ...
|
| 109 |
+
def get_worker_infos(self) -> list[WorkerInfo]: ...
|
| 110 |
+
def _get_device_map(self, dst: WorkerInfo) -> dict[torch.device, torch.device]: ...
|
| 111 |
+
def _update_group_membership(
|
| 112 |
+
self,
|
| 113 |
+
worker_info: WorkerInfo,
|
| 114 |
+
my_devices: list[torch.device],
|
| 115 |
+
reverse_device_map: dict[str, dict[torch.device, torch.device]],
|
| 116 |
+
is_join: bool,
|
| 117 |
+
): ...
|
| 118 |
+
def _get_backend_options(self) -> _TensorPipeRpcBackendOptionsBase: ...
|
| 119 |
+
@property
|
| 120 |
+
def is_static_group(self) -> bool: ...
|
| 121 |
+
@property
|
| 122 |
+
def store(self) -> Store: ...
|
| 123 |
+
|
| 124 |
+
def _is_current_rpc_agent_set() -> bool: ...
|
| 125 |
+
def _get_current_rpc_agent() -> RpcAgent: ...
|
| 126 |
+
def _set_and_start_rpc_agent(agent: RpcAgent): ...
|
| 127 |
+
def _reset_current_rpc_agent(): ...
|
| 128 |
+
def _delete_all_user_and_unforked_owner_rrefs(timeout: timedelta = ...): ...
|
| 129 |
+
def _destroy_rref_context(ignoreRRefLeak: bool): ...
|
| 130 |
+
def _rref_context_get_debug_info() -> dict[str, str]: ...
|
| 131 |
+
def _cleanup_python_rpc_handler(): ...
|
| 132 |
+
def _invoke_rpc_builtin(
|
| 133 |
+
dst: WorkerInfo,
|
| 134 |
+
opName: str,
|
| 135 |
+
rpcTimeoutSeconds: float,
|
| 136 |
+
*args: Any,
|
| 137 |
+
**kwargs: Any,
|
| 138 |
+
): ...
|
| 139 |
+
def _invoke_rpc_python_udf(
|
| 140 |
+
dst: WorkerInfo,
|
| 141 |
+
pickledPythonUDF: str,
|
| 142 |
+
tensors: list[torch.Tensor],
|
| 143 |
+
rpcTimeoutSeconds: float,
|
| 144 |
+
isAsyncExecution: bool,
|
| 145 |
+
): ...
|
| 146 |
+
def _invoke_rpc_torchscript(
|
| 147 |
+
dstWorkerName: str,
|
| 148 |
+
qualifiedNameStr: str,
|
| 149 |
+
argsTuple: tuple,
|
| 150 |
+
kwargsDict: dict,
|
| 151 |
+
rpcTimeoutSeconds: float,
|
| 152 |
+
isAsyncExecution: bool,
|
| 153 |
+
): ...
|
| 154 |
+
def _invoke_remote_builtin(
|
| 155 |
+
dst: WorkerInfo,
|
| 156 |
+
opName: str,
|
| 157 |
+
rpcTimeoutSeconds: float,
|
| 158 |
+
*args: Any,
|
| 159 |
+
**kwargs: Any,
|
| 160 |
+
): ...
|
| 161 |
+
def _invoke_remote_python_udf(
|
| 162 |
+
dst: WorkerInfo,
|
| 163 |
+
pickledPythonUDF: str,
|
| 164 |
+
tensors: list[torch.Tensor],
|
| 165 |
+
rpcTimeoutSeconds: float,
|
| 166 |
+
isAsyncExecution: bool,
|
| 167 |
+
): ...
|
| 168 |
+
def _invoke_remote_torchscript(
|
| 169 |
+
dstWorkerName: WorkerInfo,
|
| 170 |
+
qualifiedNameStr: str,
|
| 171 |
+
rpcTimeoutSeconds: float,
|
| 172 |
+
isAsyncExecution: bool,
|
| 173 |
+
*args: Any,
|
| 174 |
+
**kwargs: Any,
|
| 175 |
+
): ...
|
| 176 |
+
def get_rpc_timeout() -> float: ...
|
| 177 |
+
def enable_gil_profiling(flag: bool): ...
|
| 178 |
+
def _set_rpc_timeout(rpcTimeoutSeconds: float): ...
|
| 179 |
+
|
| 180 |
+
class RemoteProfilerManager:
|
| 181 |
+
@staticmethod
|
| 182 |
+
def set_current_profiling_key(key: str): ...
|
| 183 |
+
|
| 184 |
+
def _enable_server_process_global_profiler(new_config: ProfilerConfig): ...
|
| 185 |
+
def _disable_server_process_global_profiler() -> list[list[list[ProfilerEvent]]]: ...
|
| 186 |
+
def _set_profiler_node_id(default_node_id: int): ...
|
| 187 |
+
def _enable_jit_rref_pickle(): ...
|
| 188 |
+
def _disable_jit_rref_pickle(): ...
|
.venv/lib/python3.12/site-packages/torch/_C/_distributed_rpc_testing.pyi
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from torch._C._distributed_c10d import Store
|
| 3 |
+
from torch._C._distributed_rpc import _TensorPipeRpcBackendOptionsBase, TensorPipeAgent
|
| 4 |
+
|
| 5 |
+
# This module is defined in torch/csrc/distributed/rpc/testing/init.cpp
|
| 6 |
+
|
| 7 |
+
class FaultyTensorPipeRpcBackendOptions(_TensorPipeRpcBackendOptionsBase):
|
| 8 |
+
def __init__(
|
| 9 |
+
self,
|
| 10 |
+
num_worker_threads: int,
|
| 11 |
+
rpc_timeout: float,
|
| 12 |
+
init_method: str,
|
| 13 |
+
messages_to_fail: list[str],
|
| 14 |
+
messages_to_delay: dict[str, float],
|
| 15 |
+
num_fail_sends: int,
|
| 16 |
+
) -> None: ...
|
| 17 |
+
num_send_recv_threads: int
|
| 18 |
+
messages_to_fail: list[str]
|
| 19 |
+
messages_to_delay: dict[str, float]
|
| 20 |
+
num_fail_sends: int
|
| 21 |
+
|
| 22 |
+
class FaultyTensorPipeAgent(TensorPipeAgent):
|
| 23 |
+
def __init__(
|
| 24 |
+
self,
|
| 25 |
+
store: Store,
|
| 26 |
+
name: str,
|
| 27 |
+
rank: int,
|
| 28 |
+
world_size: int,
|
| 29 |
+
options: FaultyTensorPipeRpcBackendOptions,
|
| 30 |
+
reverse_device_maps: dict[str, dict[torch.device, torch.device]],
|
| 31 |
+
devices: list[torch.device],
|
| 32 |
+
) -> None: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_dynamo/__init__.pyi
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from . import compiled_autograd, eval_frame, guards # noqa: F401
|
| 2 |
+
|
| 3 |
+
def strip_function_call(name: str) -> str: ...
|
| 4 |
+
def is_valid_var_name(name: str) -> bool | int: ...
|
| 5 |
+
def get_type_slots(obj: type | object) -> tuple[int, int, int, int]: ...
|
| 6 |
+
def has_slot(slots: int, slot_bit: int) -> bool: ...
|
| 7 |
+
|
| 8 |
+
class PySequenceSlots:
|
| 9 |
+
SQ_LENGTH: int
|
| 10 |
+
SQ_CONCAT: int
|
| 11 |
+
SQ_REPEAT: int
|
| 12 |
+
SQ_ITEM: int
|
| 13 |
+
SQ_CONTAINS: int
|
| 14 |
+
SQ_ASS_ITEM: int
|
| 15 |
+
SQ_INPLACE_CONCAT: int
|
| 16 |
+
SQ_INPLACE_REPEAT: int
|
| 17 |
+
|
| 18 |
+
class PyMappingSlots:
|
| 19 |
+
MP_LENGTH: int
|
| 20 |
+
MP_SUBSCRIPT: int
|
| 21 |
+
MP_ASS_SUBSCRIPT: int
|
| 22 |
+
|
| 23 |
+
class PyNumberSlots:
|
| 24 |
+
NB_ADD: int
|
| 25 |
+
NB_SUBTRACT: int
|
| 26 |
+
NB_MULTIPLY: int
|
| 27 |
+
NB_REMAINDER: int
|
| 28 |
+
NB_POWER: int
|
| 29 |
+
NB_NEGATIVE: int
|
| 30 |
+
NB_POSITIVE: int
|
| 31 |
+
NB_ABSOLUTE: int
|
| 32 |
+
NB_BOOL: int
|
| 33 |
+
NB_INVERT: int
|
| 34 |
+
NB_LSHIFT: int
|
| 35 |
+
NB_RSHIFT: int
|
| 36 |
+
NB_AND: int
|
| 37 |
+
NB_XOR: int
|
| 38 |
+
NB_OR: int
|
| 39 |
+
NB_INT: int
|
| 40 |
+
NB_FLOAT: int
|
| 41 |
+
NB_INPLACE_ADD: int
|
| 42 |
+
NB_INPLACE_SUBTRACT: int
|
| 43 |
+
NB_INPLACE_MULTIPLY: int
|
| 44 |
+
NB_INPLACE_REMAINDER: int
|
| 45 |
+
NB_INPLACE_POWER: int
|
| 46 |
+
NB_INPLACE_LSHIFT: int
|
| 47 |
+
NB_INPLACE_RSHIFT: int
|
| 48 |
+
NB_INPLACE_AND: int
|
| 49 |
+
NB_INPLACE_XOR: int
|
| 50 |
+
NB_INPLACE_OR: int
|
| 51 |
+
NB_FLOOR_DIVIDE: int
|
| 52 |
+
NB_TRUE_DIVIDE: int
|
| 53 |
+
NB_INPLACE_FLOOR_DIVIDE: int
|
| 54 |
+
NB_INPLACE_TRUE_DIVIDE: int
|
| 55 |
+
NB_INDEX: int
|
| 56 |
+
NB_MATRIX_MULTIPLY: int
|
| 57 |
+
NB_INPLACE_MATRIX_MULTIPLY: int
|
| 58 |
+
NB_DIVMOD: int
|
| 59 |
+
|
| 60 |
+
class PyTypeSlots:
|
| 61 |
+
TP_HASH: int
|
| 62 |
+
TP_ITER: int
|
| 63 |
+
TP_ITERNEXT: int
|
| 64 |
+
TP_CALL: int
|
| 65 |
+
TP_REPR: int
|
| 66 |
+
TP_RICHCOMPARE: int
|
| 67 |
+
TP_GETATTRO: int
|
| 68 |
+
TP_SETATTRO: int
|
| 69 |
+
TP_DESCR_GET: int
|
| 70 |
+
TP_DESCR_SET: int
|
| 71 |
+
TP_STR: int
|
| 72 |
+
TP_INIT: int
|
.venv/lib/python3.12/site-packages/torch/_C/_dynamo/compiled_autograd.pyi
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Callable
|
| 2 |
+
|
| 3 |
+
from torch import Tensor
|
| 4 |
+
from torch._dynamo.compiled_autograd import AutogradCompilerInstance
|
| 5 |
+
|
| 6 |
+
def set_autograd_compiler(
|
| 7 |
+
autograd_compiler: Callable[[], AutogradCompilerInstance] | None,
|
| 8 |
+
dynamic: bool,
|
| 9 |
+
) -> tuple[Callable[[], AutogradCompilerInstance] | None, bool]: ...
|
| 10 |
+
def clear_cache() -> None: ...
|
| 11 |
+
def is_cache_empty() -> bool: ...
|
| 12 |
+
def set_verbose_logger(fn: Callable[[str], None] | None) -> bool: ...
|
| 13 |
+
def call_cpp_tensor_pre_hooks(idx: int, grad: Tensor) -> Tensor: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_dynamo/eval_frame.pyi
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import enum
|
| 2 |
+
import types
|
| 3 |
+
from collections.abc import Callable
|
| 4 |
+
from typing import overload
|
| 5 |
+
|
| 6 |
+
from torch._dynamo.guards import GuardManagerWrapper
|
| 7 |
+
from torch._dynamo.types import DynamoCallback, DynamoGuardCompleteHook, DynamoGuardHook
|
| 8 |
+
from torch._guards import CompileId
|
| 9 |
+
|
| 10 |
+
def set_eval_frame(callback: DynamoCallback) -> DynamoCallback: ...
|
| 11 |
+
def set_skip_guard_eval_unsafe(value: bool) -> bool: ...
|
| 12 |
+
def get_eval_frame_callback() -> DynamoCallback: ...
|
| 13 |
+
def reset_code(code: types.CodeType) -> None: ...
|
| 14 |
+
def unsupported(obj1: object, obj2: object) -> object: ...
|
| 15 |
+
def set_code_exec_strategy(
|
| 16 |
+
code: types.CodeType, strategy: _FrameExecStrategy
|
| 17 |
+
) -> None: ...
|
| 18 |
+
def set_guard_error_hook(hook: DynamoGuardHook) -> None: ...
|
| 19 |
+
def set_guard_complete_hook(
|
| 20 |
+
hook: DynamoGuardCompleteHook | None,
|
| 21 |
+
) -> DynamoGuardCompleteHook | None: ...
|
| 22 |
+
def raise_sigtrap() -> None: ...
|
| 23 |
+
def get_method_ml_flags(fn: object) -> int | None: ...
|
| 24 |
+
def set_c_recursion_limit(limit: int) -> None: ...
|
| 25 |
+
def get_c_recursion_limit() -> int: ...
|
| 26 |
+
|
| 27 |
+
class _CacheEntry:
|
| 28 |
+
def check_fn(self, *args: object, **kwargs: object) -> bool: ...
|
| 29 |
+
def update_diff_guard_root_manager(self) -> None: ...
|
| 30 |
+
code: types.CodeType
|
| 31 |
+
compile_id: CompileId
|
| 32 |
+
# If we run into circular issues, just use object
|
| 33 |
+
guard_manager: GuardManagerWrapper
|
| 34 |
+
backend: Callable
|
| 35 |
+
isolate_recompiles_id: int
|
| 36 |
+
|
| 37 |
+
class _PrecompileEntry:
|
| 38 |
+
guard_manager: GuardManagerWrapper
|
| 39 |
+
|
| 40 |
+
class _ExtraState:
|
| 41 |
+
def invalidate(
|
| 42 |
+
self, cache_entry: _CacheEntry, guard_manager: GuardManagerWrapper
|
| 43 |
+
) -> None: ...
|
| 44 |
+
|
| 45 |
+
class _FrameAction(enum.IntEnum):
|
| 46 |
+
DEFAULT = 0
|
| 47 |
+
SKIP = 1
|
| 48 |
+
RUN_ONLY = 2
|
| 49 |
+
|
| 50 |
+
class _FrameExecStrategy:
|
| 51 |
+
cur_action: _FrameAction
|
| 52 |
+
recursive_action: _FrameAction
|
| 53 |
+
|
| 54 |
+
@overload
|
| 55 |
+
def __init__(self) -> None: ...
|
| 56 |
+
@overload
|
| 57 |
+
def __init__(
|
| 58 |
+
self, cur_action: _FrameAction, recursive_action: _FrameAction
|
| 59 |
+
) -> None: ...
|
| 60 |
+
|
| 61 |
+
# This is an object that encapsulates the Python FrameType, and exposes
|
| 62 |
+
# properties Dynamo cares about for a frame.
|
| 63 |
+
class _PyInterpreterFrame:
|
| 64 |
+
f_code: types.CodeType
|
| 65 |
+
f_locals: dict[str, object]
|
| 66 |
+
f_globals: dict[str, object]
|
| 67 |
+
f_builtins: dict[str, object]
|
| 68 |
+
f_lasti: int
|
| 69 |
+
f_lineno: int
|
| 70 |
+
f_back: types.FrameType
|
| 71 |
+
# A tuple containing cell objects captured by this frame.
|
| 72 |
+
closure: tuple[types.CellType]
|
| 73 |
+
|
| 74 |
+
def _debug_get_cache_entry_list(code: types.CodeType) -> list[_CacheEntry]: ...
|
| 75 |
+
def _get_cache_entries_for_region(
|
| 76 |
+
code: types.CodeType, isolate_recompiles_id: int
|
| 77 |
+
) -> list[_CacheEntry]: ...
|
| 78 |
+
def _get_total_cache_entry_count(code: types.CodeType) -> int: ...
|
| 79 |
+
def _get_frame_value_stack_with_depth(
|
| 80 |
+
frame: types.FrameType, depth: int
|
| 81 |
+
) -> list[object]: ...
|
| 82 |
+
def set_bytecode_debugger_callback(
|
| 83 |
+
callback: Callable[[types.CodeType], None] | None,
|
| 84 |
+
) -> None: ...
|
| 85 |
+
def get_bytecode_debugger_callback() -> Callable[[types.CodeType], None] | None: ...
|
| 86 |
+
def register_breakpoint_code(code: types.CodeType) -> None: ...
|
| 87 |
+
|
| 88 |
+
# Sentinel for NULL stack values returned by _get_frame_value_stack_at_depth
|
| 89 |
+
class NullStackValue: ...
|
| 90 |
+
|
| 91 |
+
NULL_STACK_VALUE: NullStackValue
|
| 92 |
+
|
| 93 |
+
py_opcode_caches: list[int]
|
| 94 |
+
|
| 95 |
+
def code_framelocals_names(code: types.CodeType) -> tuple[str, ...]: ...
|
| 96 |
+
def _load_precompile_entry(
|
| 97 |
+
code: types.CodeType,
|
| 98 |
+
guard_manager: GuardManagerWrapper,
|
| 99 |
+
dynamo_code: types.CodeType,
|
| 100 |
+
) -> None: ...
|
| 101 |
+
def _reset_precompile_entries(code: types.CodeType) -> None: ...
|
| 102 |
+
def _debug_get_precompile_entries(code: types.CodeType) -> list[_PrecompileEntry]: ...
|
| 103 |
+
def set_fullgraph_compiled_frame_count(value: int) -> int: ...
|
| 104 |
+
def set_fullgraph_error_on_nested_compile(value: bool) -> bool: ...
|
| 105 |
+
def set_eval_frame_isolate_recompiles_id(isolate_recompiles_id: int) -> int: ...
|
| 106 |
+
def get_eval_frame_isolate_recompiles_id() -> int: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_dynamo/guards.pyi
ADDED
|
@@ -0,0 +1,519 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import enum
|
| 2 |
+
import traceback
|
| 3 |
+
from collections.abc import Callable, Sequence
|
| 4 |
+
from typing import Any, TypeAlias
|
| 5 |
+
|
| 6 |
+
import torch
|
| 7 |
+
|
| 8 |
+
# TODO: We should move the `GuardManagerType`
|
| 9 |
+
# defined in `guards.py` here and update other
|
| 10 |
+
# imports
|
| 11 |
+
GuardManagerType: TypeAlias = enum.Enum
|
| 12 |
+
|
| 13 |
+
class GlobalStateGuard:
|
| 14 |
+
def check(self) -> bool: ...
|
| 15 |
+
def reason(self) -> str: ...
|
| 16 |
+
|
| 17 |
+
class LeafGuard:
|
| 18 |
+
def verbose_code_parts(self) -> list[str]: ...
|
| 19 |
+
|
| 20 |
+
class RelationalGuard: ...
|
| 21 |
+
|
| 22 |
+
class GuardDebugInfo:
|
| 23 |
+
verbose_code_parts: list[str]
|
| 24 |
+
result: bool
|
| 25 |
+
num_guards_executed: int
|
| 26 |
+
user_stack: traceback.StackSummary | None
|
| 27 |
+
|
| 28 |
+
class LocalState: ...
|
| 29 |
+
|
| 30 |
+
class GuardManager:
|
| 31 |
+
def check(self, value: Any) -> bool: ...
|
| 32 |
+
def check_verbose(self, value: Any) -> GuardDebugInfo: ...
|
| 33 |
+
|
| 34 |
+
# Accessors
|
| 35 |
+
def globals_dict_manager(
|
| 36 |
+
self,
|
| 37 |
+
f_globals: dict[str, Any],
|
| 38 |
+
source: str,
|
| 39 |
+
example_value: Any,
|
| 40 |
+
guard_manager_enum: GuardManagerType,
|
| 41 |
+
) -> GuardManager: ...
|
| 42 |
+
def framelocals_manager(
|
| 43 |
+
self,
|
| 44 |
+
key: tuple[str, int],
|
| 45 |
+
source: str,
|
| 46 |
+
example_value: Any,
|
| 47 |
+
guard_manager_enum: GuardManagerType,
|
| 48 |
+
) -> GuardManager: ...
|
| 49 |
+
def dict_getitem_manager(
|
| 50 |
+
self,
|
| 51 |
+
key: Any,
|
| 52 |
+
source: str,
|
| 53 |
+
example_value: Any,
|
| 54 |
+
guard_manager_enum: GuardManagerType,
|
| 55 |
+
) -> GuardManager: ...
|
| 56 |
+
def grad_manager(
|
| 57 |
+
self,
|
| 58 |
+
source: str,
|
| 59 |
+
example_value: Any,
|
| 60 |
+
guard_manager_enum: GuardManagerType,
|
| 61 |
+
) -> GuardManager: ...
|
| 62 |
+
def generic_getattr_manager(
|
| 63 |
+
self,
|
| 64 |
+
attr: str,
|
| 65 |
+
source: str,
|
| 66 |
+
example_value: Any,
|
| 67 |
+
guard_manager_enum: GuardManagerType,
|
| 68 |
+
) -> GuardManager: ...
|
| 69 |
+
def getitem_manager(
|
| 70 |
+
self,
|
| 71 |
+
key: Any,
|
| 72 |
+
source: str,
|
| 73 |
+
example_value: Any,
|
| 74 |
+
guard_manager_enum: GuardManagerType,
|
| 75 |
+
) -> GuardManager: ...
|
| 76 |
+
def get_generic_dict_manager(
|
| 77 |
+
self,
|
| 78 |
+
source: str,
|
| 79 |
+
example_value: Any,
|
| 80 |
+
guard_manager_enum: GuardManagerType,
|
| 81 |
+
) -> GuardManager: ...
|
| 82 |
+
def list_getitem_manager(
|
| 83 |
+
self,
|
| 84 |
+
key: Any,
|
| 85 |
+
source: str,
|
| 86 |
+
example_value: Any,
|
| 87 |
+
guard_manager_enum: GuardManagerType,
|
| 88 |
+
) -> GuardManager: ...
|
| 89 |
+
def tuple_getitem_manager(
|
| 90 |
+
self,
|
| 91 |
+
key: Any,
|
| 92 |
+
source: str,
|
| 93 |
+
example_value: Any,
|
| 94 |
+
guard_manager_enum: GuardManagerType,
|
| 95 |
+
) -> GuardManager: ...
|
| 96 |
+
def set_getitem_manager(
|
| 97 |
+
self,
|
| 98 |
+
index: Any,
|
| 99 |
+
source: str,
|
| 100 |
+
example_value: Any,
|
| 101 |
+
guard_manager_enum: GuardManagerType,
|
| 102 |
+
) -> GuardManager: ...
|
| 103 |
+
def func_defaults_manager(
|
| 104 |
+
self,
|
| 105 |
+
source: str,
|
| 106 |
+
example_value: Any,
|
| 107 |
+
guard_manager_enum: GuardManagerType,
|
| 108 |
+
) -> GuardManager: ...
|
| 109 |
+
def func_kwdefaults_manager(
|
| 110 |
+
self,
|
| 111 |
+
source: str,
|
| 112 |
+
example_value: Any,
|
| 113 |
+
guard_manager_enum: GuardManagerType,
|
| 114 |
+
) -> GuardManager: ...
|
| 115 |
+
def tuple_iterator_getitem_manager(
|
| 116 |
+
self,
|
| 117 |
+
index: Any,
|
| 118 |
+
source: str,
|
| 119 |
+
example_value: Any,
|
| 120 |
+
guard_manager_enum: GuardManagerType,
|
| 121 |
+
) -> GuardManager: ...
|
| 122 |
+
def weakref_call_manager(
|
| 123 |
+
self,
|
| 124 |
+
source: str,
|
| 125 |
+
example_value: Any,
|
| 126 |
+
guard_manager_enum: GuardManagerType,
|
| 127 |
+
) -> GuardManager: ...
|
| 128 |
+
def call_function_no_args_manager(
|
| 129 |
+
self,
|
| 130 |
+
source: str,
|
| 131 |
+
example_value: Any,
|
| 132 |
+
guard_manager_enum: GuardManagerType,
|
| 133 |
+
) -> GuardManager: ...
|
| 134 |
+
def global_weakref_manager(
|
| 135 |
+
self,
|
| 136 |
+
global_name: str,
|
| 137 |
+
source: str,
|
| 138 |
+
example_value: Any,
|
| 139 |
+
guard_manager_enum: GuardManagerType,
|
| 140 |
+
) -> GuardManager: ...
|
| 141 |
+
def type_manager(
|
| 142 |
+
self,
|
| 143 |
+
source: str,
|
| 144 |
+
example_value: Any,
|
| 145 |
+
guard_manager_enum: GuardManagerType,
|
| 146 |
+
) -> GuardManager: ...
|
| 147 |
+
def getattr_manager(
|
| 148 |
+
self,
|
| 149 |
+
attr: str,
|
| 150 |
+
source: str,
|
| 151 |
+
example_value: Any,
|
| 152 |
+
guard_manager_enum: GuardManagerType,
|
| 153 |
+
) -> GuardManager: ...
|
| 154 |
+
def tensor_property_size_manager(
|
| 155 |
+
self,
|
| 156 |
+
idx: int,
|
| 157 |
+
source: str,
|
| 158 |
+
example_value: Any,
|
| 159 |
+
guard_manager_enum: GuardManagerType,
|
| 160 |
+
) -> GuardManager: ...
|
| 161 |
+
def tensor_property_shape_manager(
|
| 162 |
+
self,
|
| 163 |
+
idx: int,
|
| 164 |
+
source: str,
|
| 165 |
+
example_value: Any,
|
| 166 |
+
guard_manager_enum: GuardManagerType,
|
| 167 |
+
) -> GuardManager: ...
|
| 168 |
+
def tensor_property_storage_offset_manager(
|
| 169 |
+
self,
|
| 170 |
+
idx: int,
|
| 171 |
+
source: str,
|
| 172 |
+
example_value: Any,
|
| 173 |
+
guard_manager_enum: GuardManagerType,
|
| 174 |
+
) -> GuardManager: ...
|
| 175 |
+
def indexed_manager(
|
| 176 |
+
self,
|
| 177 |
+
idx: int,
|
| 178 |
+
source: str,
|
| 179 |
+
example_value: Any,
|
| 180 |
+
guard_manager_enum: GuardManagerType,
|
| 181 |
+
) -> GuardManager: ...
|
| 182 |
+
def lambda_manager(
|
| 183 |
+
self,
|
| 184 |
+
python_lambda: Callable[..., Any],
|
| 185 |
+
source: str,
|
| 186 |
+
example_value: Any,
|
| 187 |
+
guard_manager_enum: GuardManagerType,
|
| 188 |
+
) -> GuardManager: ...
|
| 189 |
+
def get_root(self) -> RootGuardManager: ...
|
| 190 |
+
def get_source(self) -> str: ...
|
| 191 |
+
def fail_count(self) -> int: ...
|
| 192 |
+
def get_child_managers(self) -> list[GuardManager]: ...
|
| 193 |
+
def repr(self) -> str: ...
|
| 194 |
+
def type_of_guarded_value(self) -> str: ...
|
| 195 |
+
def get_leaf_guards(self) -> list[LeafGuard]: ...
|
| 196 |
+
def get_accessors(self) -> list[GuardManager]: ...
|
| 197 |
+
def is_guarded_value_immutable(self) -> bool: ...
|
| 198 |
+
def is_tag_safe(self) -> bool: ...
|
| 199 |
+
def is_tag_safe_root(self) -> bool: ...
|
| 200 |
+
def has_no_accessors(self) -> bool: ...
|
| 201 |
+
def has_object_aliasing_guard(self) -> bool: ...
|
| 202 |
+
def get_type_of_guarded_value(self) -> type: ...
|
| 203 |
+
def type_dict_manager(
|
| 204 |
+
self,
|
| 205 |
+
source: str,
|
| 206 |
+
example_value: Any,
|
| 207 |
+
guard_manager_enum: GuardManagerType,
|
| 208 |
+
) -> GuardManager: ...
|
| 209 |
+
def type_mro_manager(
|
| 210 |
+
self,
|
| 211 |
+
source: str,
|
| 212 |
+
example_value: Any,
|
| 213 |
+
guard_manager_enum: GuardManagerType,
|
| 214 |
+
) -> GuardManager: ...
|
| 215 |
+
def code_manager(
|
| 216 |
+
self,
|
| 217 |
+
source: str,
|
| 218 |
+
example_value: Any,
|
| 219 |
+
guard_manager_enum: GuardManagerType,
|
| 220 |
+
) -> GuardManager: ...
|
| 221 |
+
def closure_manager(
|
| 222 |
+
self,
|
| 223 |
+
source: str,
|
| 224 |
+
example_value: Any,
|
| 225 |
+
guard_manager_enum: GuardManagerType,
|
| 226 |
+
) -> GuardManager: ...
|
| 227 |
+
# Leaf guards
|
| 228 |
+
def add_lambda_guard(
|
| 229 |
+
self,
|
| 230 |
+
user_lambda: Callable[..., Any],
|
| 231 |
+
verbose_code_parts: list[str],
|
| 232 |
+
user_stack: traceback.StackSummary | None,
|
| 233 |
+
) -> None: ...
|
| 234 |
+
def add_id_match_guard(
|
| 235 |
+
self,
|
| 236 |
+
id_val: int,
|
| 237 |
+
verbose_code_parts: list[str],
|
| 238 |
+
user_stack: traceback.StackSummary | None,
|
| 239 |
+
) -> None: ...
|
| 240 |
+
def add_equals_match_guard(
|
| 241 |
+
self,
|
| 242 |
+
equals_val: Any,
|
| 243 |
+
verbose_code_parts: list[str],
|
| 244 |
+
user_stack: traceback.StackSummary | None,
|
| 245 |
+
) -> None: ...
|
| 246 |
+
def add_global_state_guard(
|
| 247 |
+
self,
|
| 248 |
+
initial_state: Any,
|
| 249 |
+
verbose_code_parts: list[str],
|
| 250 |
+
user_stack: traceback.StackSummary | None,
|
| 251 |
+
) -> None: ...
|
| 252 |
+
def add_torch_function_mode_stack_guard(
|
| 253 |
+
self,
|
| 254 |
+
initial_stack: list[Any],
|
| 255 |
+
verbose_code_parts: list[str],
|
| 256 |
+
user_stack: traceback.StackSummary | None,
|
| 257 |
+
) -> None: ...
|
| 258 |
+
def add_mapping_keys_guard(
|
| 259 |
+
self,
|
| 260 |
+
value: Any,
|
| 261 |
+
verbose_code_parts: list[str],
|
| 262 |
+
user_stack: traceback.StackSummary | None,
|
| 263 |
+
) -> None: ...
|
| 264 |
+
def add_dict_length_check_guard(
|
| 265 |
+
self,
|
| 266 |
+
value: int,
|
| 267 |
+
verbose_code_parts: list[str],
|
| 268 |
+
user_stack: traceback.StackSummary | None,
|
| 269 |
+
) -> None: ...
|
| 270 |
+
def add_length_check_guard(
|
| 271 |
+
self,
|
| 272 |
+
value: int,
|
| 273 |
+
verbose_code_parts: list[str],
|
| 274 |
+
user_stack: traceback.StackSummary | None,
|
| 275 |
+
) -> None: ...
|
| 276 |
+
def add_true_match_guard(
|
| 277 |
+
self,
|
| 278 |
+
verbose_code_parts: list[str],
|
| 279 |
+
user_stack: traceback.StackSummary | None,
|
| 280 |
+
) -> None: ...
|
| 281 |
+
def add_false_match_guard(
|
| 282 |
+
self,
|
| 283 |
+
verbose_code_parts: list[str],
|
| 284 |
+
user_stack: traceback.StackSummary | None,
|
| 285 |
+
) -> None: ...
|
| 286 |
+
def add_none_match_guard(
|
| 287 |
+
self,
|
| 288 |
+
verbose_code_parts: list[str],
|
| 289 |
+
user_stack: traceback.StackSummary | None,
|
| 290 |
+
) -> None: ...
|
| 291 |
+
def add_not_none_guard(
|
| 292 |
+
self,
|
| 293 |
+
verbose_code_parts: list[str],
|
| 294 |
+
user_stack: traceback.StackSummary | None,
|
| 295 |
+
) -> None: ...
|
| 296 |
+
def add_dispatch_key_set_guard(
|
| 297 |
+
self,
|
| 298 |
+
dispatch_key: Any,
|
| 299 |
+
verbose_code_parts: list[str],
|
| 300 |
+
user_stack: traceback.StackSummary | None,
|
| 301 |
+
) -> None: ...
|
| 302 |
+
def add_tensor_match_guard(
|
| 303 |
+
self,
|
| 304 |
+
value: Any,
|
| 305 |
+
sizes: list[int],
|
| 306 |
+
strides: list[int],
|
| 307 |
+
tensor_name: str,
|
| 308 |
+
verbose_code_parts: list[str],
|
| 309 |
+
user_stack: traceback.StackSummary | None,
|
| 310 |
+
ptype: Any,
|
| 311 |
+
dispatch_keys: Any,
|
| 312 |
+
) -> None: ...
|
| 313 |
+
def add_dimension_marking_guard(
|
| 314 |
+
self,
|
| 315 |
+
expected_attrs: dict[str, set[int]],
|
| 316 |
+
absent_attrs: list[str],
|
| 317 |
+
dependent_attrs: dict[str, tuple[dict[int, Any] | None, str]],
|
| 318 |
+
verbose_code_parts: list[str],
|
| 319 |
+
user_stack: traceback.StackSummary | None,
|
| 320 |
+
) -> None: ...
|
| 321 |
+
def add_no_hasattr_guard(
|
| 322 |
+
self,
|
| 323 |
+
attr_name: str,
|
| 324 |
+
verbose_code_parts: list[str],
|
| 325 |
+
user_stack: traceback.StackSummary | None,
|
| 326 |
+
) -> None: ...
|
| 327 |
+
def add_dict_contains_guard(
|
| 328 |
+
self,
|
| 329 |
+
contains: bool,
|
| 330 |
+
key: Any,
|
| 331 |
+
verbose_code_parts: list[str],
|
| 332 |
+
user_stack: traceback.StackSummary | None,
|
| 333 |
+
) -> None: ...
|
| 334 |
+
def add_type_match_guard(
|
| 335 |
+
self,
|
| 336 |
+
value: int,
|
| 337 |
+
verbose_code_parts: list[str],
|
| 338 |
+
user_stack: traceback.StackSummary | None,
|
| 339 |
+
) -> None: ...
|
| 340 |
+
def add_fake_script_type_match_guard(
|
| 341 |
+
self,
|
| 342 |
+
fake_script_object_type: type,
|
| 343 |
+
type_id: int,
|
| 344 |
+
verbose_code_parts: list[str],
|
| 345 |
+
user_stack: traceback.StackSummary | None,
|
| 346 |
+
) -> None: ...
|
| 347 |
+
def add_dict_version_guard(
|
| 348 |
+
self,
|
| 349 |
+
value: Any,
|
| 350 |
+
verbose_code_parts: list[str],
|
| 351 |
+
user_stack: traceback.StackSummary | None,
|
| 352 |
+
) -> None: ...
|
| 353 |
+
def add_set_contains_guard(
|
| 354 |
+
self,
|
| 355 |
+
contains: bool,
|
| 356 |
+
item: Any,
|
| 357 |
+
verbose_code_parts: list[str],
|
| 358 |
+
user_stack: traceback.StackSummary | None,
|
| 359 |
+
) -> None: ...
|
| 360 |
+
def add_dual_level_match_guard(
|
| 361 |
+
self,
|
| 362 |
+
level: int,
|
| 363 |
+
verbose_code_parts: list[str],
|
| 364 |
+
user_stack: traceback.StackSummary | None,
|
| 365 |
+
) -> None: ...
|
| 366 |
+
def add_float_is_nan_guard(
|
| 367 |
+
self,
|
| 368 |
+
verbose_code_parts: list[str],
|
| 369 |
+
user_stack: traceback.StackSummary | None,
|
| 370 |
+
) -> None: ...
|
| 371 |
+
def add_complex_is_nan_guard(
|
| 372 |
+
self,
|
| 373 |
+
verbose_code_parts: list[str],
|
| 374 |
+
user_stack: traceback.StackSummary | None,
|
| 375 |
+
) -> None: ...
|
| 376 |
+
def add_tuple_iterator_length_guard(
|
| 377 |
+
self,
|
| 378 |
+
length: int,
|
| 379 |
+
type_id: int,
|
| 380 |
+
verbose_code_parts: list[str],
|
| 381 |
+
user_stack: traceback.StackSummary | None,
|
| 382 |
+
) -> None: ...
|
| 383 |
+
def add_range_iterator_match_guard(
|
| 384 |
+
self,
|
| 385 |
+
start: int,
|
| 386 |
+
stop: int,
|
| 387 |
+
step: int,
|
| 388 |
+
type_id: int,
|
| 389 |
+
verbose_code_parts: list[str],
|
| 390 |
+
user_stack: traceback.StackSummary | None,
|
| 391 |
+
) -> None: ...
|
| 392 |
+
def add_default_device_guard(
|
| 393 |
+
self,
|
| 394 |
+
verbose_code_parts: list[str],
|
| 395 |
+
user_stack: traceback.StackSummary | None,
|
| 396 |
+
) -> None: ...
|
| 397 |
+
def mark_tag_safe(self) -> None: ...
|
| 398 |
+
def mark_tag_safe_root(self) -> None: ...
|
| 399 |
+
|
| 400 |
+
class RootGuardManager(GuardManager):
|
| 401 |
+
def get_epilogue_lambda_guards(self) -> list[LeafGuard]: ...
|
| 402 |
+
def add_epilogue_lambda_guard(
|
| 403 |
+
self,
|
| 404 |
+
guard: LeafGuard,
|
| 405 |
+
verbose_code_parts: list[str],
|
| 406 |
+
user_stack: traceback.StackSummary | None,
|
| 407 |
+
) -> None: ...
|
| 408 |
+
def clone_manager(
|
| 409 |
+
self, clone_filter_fn: Callable[[GuardManager], bool]
|
| 410 |
+
) -> RootGuardManager: ...
|
| 411 |
+
def attach_compile_id(self, compile_id: str) -> None: ...
|
| 412 |
+
def get_local_state(self) -> LocalState: ...
|
| 413 |
+
def set_local_state(self, local_state: LocalState) -> None: ...
|
| 414 |
+
|
| 415 |
+
class DictGuardManager(GuardManager):
|
| 416 |
+
def get_key_manager(
|
| 417 |
+
self,
|
| 418 |
+
index: int,
|
| 419 |
+
source: str,
|
| 420 |
+
example_value: Any,
|
| 421 |
+
guard_manager_enum: GuardManagerType,
|
| 422 |
+
) -> GuardManager: ...
|
| 423 |
+
def get_value_manager(
|
| 424 |
+
self,
|
| 425 |
+
index: int,
|
| 426 |
+
source: str,
|
| 427 |
+
example_value: Any,
|
| 428 |
+
guard_manager_enum: GuardManagerType,
|
| 429 |
+
) -> GuardManager: ...
|
| 430 |
+
def get_key_value_managers(
|
| 431 |
+
self,
|
| 432 |
+
) -> dict[int, tuple[GuardManager, GuardManager]]: ...
|
| 433 |
+
|
| 434 |
+
# Guard accessor stubs
|
| 435 |
+
class GuardAccessor: ...
|
| 436 |
+
class DictGetItemGuardAccessor(GuardAccessor): ...
|
| 437 |
+
class GetGenericDictGuardAccessor(GuardAccessor): ...
|
| 438 |
+
class TypeDictGuardAccessor(GuardAccessor): ...
|
| 439 |
+
class TypeMROGuardAccessor(GuardAccessor): ...
|
| 440 |
+
class ClosureGuardAccessor(GuardAccessor): ...
|
| 441 |
+
class TupleGetItemGuardAccessor(GuardAccessor): ...
|
| 442 |
+
class TypeGuardAccessor(GuardAccessor): ...
|
| 443 |
+
class CodeGuardAccessor(GuardAccessor): ...
|
| 444 |
+
class FuncDefaultsGuardAccessor(GuardAccessor): ...
|
| 445 |
+
class FuncKwDefaultsGuardAccessor(GuardAccessor): ...
|
| 446 |
+
|
| 447 |
+
class GetAttrGuardAccessor(GuardAccessor):
|
| 448 |
+
def get_attr_name(self) -> str: ...
|
| 449 |
+
|
| 450 |
+
def install_object_aliasing_guard(
|
| 451 |
+
x: GuardManager,
|
| 452 |
+
y: GuardManager,
|
| 453 |
+
verbose_code_parts: list[str],
|
| 454 |
+
user_stack: traceback.StackSummary | None,
|
| 455 |
+
) -> None: ...
|
| 456 |
+
def install_no_tensor_aliasing_guard(
|
| 457 |
+
guard_managers: list[GuardManager],
|
| 458 |
+
tensor_names: list[str],
|
| 459 |
+
verbose_code_parts: list[str],
|
| 460 |
+
user_stack: traceback.StackSummary | None,
|
| 461 |
+
) -> None: ...
|
| 462 |
+
def install_storage_overlapping_guard(
|
| 463 |
+
overlapping_guard_managers: list[GuardManager],
|
| 464 |
+
non_overlapping_guard_managers: list[GuardManager],
|
| 465 |
+
verbose_code_parts: list[str],
|
| 466 |
+
user_stack: traceback.StackSummary | None,
|
| 467 |
+
) -> None: ...
|
| 468 |
+
def install_symbolic_shape_guard(
|
| 469 |
+
guard_managers: list[GuardManager],
|
| 470 |
+
nargs_int: int,
|
| 471 |
+
nargs_float: int,
|
| 472 |
+
py_addr: int,
|
| 473 |
+
py_addr_keep_alive: Any,
|
| 474 |
+
verbose_code_parts: list[str],
|
| 475 |
+
user_stack: traceback.StackSummary | None,
|
| 476 |
+
) -> None: ...
|
| 477 |
+
def profile_guard_manager(
|
| 478 |
+
guard_manager: GuardManager,
|
| 479 |
+
f_locals: dict[str, Any],
|
| 480 |
+
n_iters: int,
|
| 481 |
+
) -> float: ...
|
| 482 |
+
|
| 483 |
+
class TensorGuards:
|
| 484 |
+
def __init__(
|
| 485 |
+
self,
|
| 486 |
+
*,
|
| 487 |
+
dynamic_dims_sizes: list[torch.SymInt | None] | None = None,
|
| 488 |
+
dynamic_dims_strides: list[torch.SymInt | None] | None = None,
|
| 489 |
+
) -> None: ...
|
| 490 |
+
def check(self, *args: Any) -> bool: ...
|
| 491 |
+
def check_verbose(
|
| 492 |
+
self, *args: Any, tensor_check_names: list[str] | None = None
|
| 493 |
+
) -> bool | str: ...
|
| 494 |
+
|
| 495 |
+
def assert_size_stride(
|
| 496 |
+
item: torch.Tensor,
|
| 497 |
+
size: torch.types._size,
|
| 498 |
+
stride: torch.types._size,
|
| 499 |
+
op_name: str | None = None,
|
| 500 |
+
) -> None: ...
|
| 501 |
+
def assert_size_stride_grouped(
|
| 502 |
+
items: Sequence[torch.Tensor],
|
| 503 |
+
sizes: Sequence[torch.types._size],
|
| 504 |
+
strides: Sequence[torch.types._size],
|
| 505 |
+
op_name: str | None = None,
|
| 506 |
+
) -> None: ...
|
| 507 |
+
def assert_alignment(
|
| 508 |
+
item: torch.Tensor,
|
| 509 |
+
alignment: int,
|
| 510 |
+
op_name: str | None = None,
|
| 511 |
+
) -> None: ...
|
| 512 |
+
def copy_if_misaligned(item: torch.Tensor) -> torch.Tensor: ...
|
| 513 |
+
def check_obj_id(obj: object, expected: int) -> bool: ...
|
| 514 |
+
def check_type_id(obj: object, expected: int) -> bool: ...
|
| 515 |
+
def dict_version(d: dict[Any, Any]) -> int: ...
|
| 516 |
+
def compute_overlapping_tensors(
|
| 517 |
+
tensors: list[torch.Tensor], symbolic: bool = True
|
| 518 |
+
) -> set[int]: ...
|
| 519 |
+
def set_is_in_mode_without_ignore_compile_internals(value: bool) -> None: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_export/__init__.pyi
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Defined in torch/csrc/export/pybind.cpp
|
| 2 |
+
class CppExportedProgram: ...
|
| 3 |
+
|
| 4 |
+
def deserialize_exported_program(
|
| 5 |
+
serialized_program: str,
|
| 6 |
+
) -> CppExportedProgram: ...
|
| 7 |
+
def serialize_exported_program(
|
| 8 |
+
cpp_exported_program: CppExportedProgram,
|
| 9 |
+
) -> str: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_export/pt2_archive_constants.pyi
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Defined in torch/csrc/export/pt2_archive_constants.h
|
| 2 |
+
|
| 3 |
+
ARCHIVE_ROOT_NAME: str = ...
|
| 4 |
+
ARCHIVE_FORMAT_PATH: str = ...
|
| 5 |
+
ARCHIVE_FORMAT_VALUE: str = ...
|
| 6 |
+
ARCHIVE_VERSION_PATH: str = ...
|
| 7 |
+
ARCHIVE_VERSION_VALUE: str = ...
|
| 8 |
+
MODELS_DIR: str = ...
|
| 9 |
+
MODELS_FILENAME_FORMAT: str = ...
|
| 10 |
+
AOTINDUCTOR_DIR: str = ...
|
| 11 |
+
MTIA_DIR: str = ...
|
| 12 |
+
WEIGHTS_DIR: str = ...
|
| 13 |
+
WEIGHTS_CONFIG_FILENAME_FORMAT: str = ...
|
| 14 |
+
WEIGHT_FILENAME_PREFIX: str = ...
|
| 15 |
+
CONSTANTS_DIR: str = ...
|
| 16 |
+
CONSTANTS_CONFIG_FILENAME_FORMAT: str = ...
|
| 17 |
+
TENSOR_CONSTANT_FILENAME_PREFIX: str = ...
|
| 18 |
+
CUSTOM_OBJ_FILENAME_PREFIX: str = ...
|
| 19 |
+
OPAQUE_OBJ_FILENAME_PREFIX: str = ...
|
| 20 |
+
SAMPLE_INPUTS_DIR: str = ...
|
| 21 |
+
SAMPLE_INPUTS_FILENAME_FORMAT: str = ...
|
| 22 |
+
EXECUTORCH_DIR: str = ...
|
| 23 |
+
EXTRA_DIR: str = ...
|
| 24 |
+
MODULE_INFO_PATH: str = ...
|
| 25 |
+
XL_MODEL_WEIGHTS_DIR: str = ...
|
| 26 |
+
XL_MODEL_WEIGHTS_PARAM_CONFIG_PATH: str = ...
|
.venv/lib/python3.12/site-packages/torch/_C/_functionalization.pyi
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from torch import Tensor
|
| 2 |
+
from torch.types import _bool
|
| 3 |
+
|
| 4 |
+
# Defined in torch/csrc/functionalization/Module.cpp
|
| 5 |
+
|
| 6 |
+
class ViewMeta:
|
| 7 |
+
has_symbolic_inputs: _bool
|
| 8 |
+
|
| 9 |
+
# Returns the list of ViewMeta instances of the given functional tensor.
|
| 10 |
+
#
|
| 11 |
+
# Although we do have python bindings for their types, we won't
|
| 12 |
+
# expose them here, since they should not be used by users.
|
| 13 |
+
def get_view_meta_sequence(tensor: Tensor) -> list[ViewMeta]: ...
|
| 14 |
+
|
| 15 |
+
# Applies the ViewMeta sequence on top of the given base.
|
| 16 |
+
def apply_view_meta_sequence(base: Tensor, sequence: list[ViewMeta]) -> Tensor: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_functions.pyi
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import AnyStr, overload
|
| 2 |
+
|
| 3 |
+
from torch import Tensor
|
| 4 |
+
|
| 5 |
+
class AccumulateGrad:
|
| 6 |
+
variable: Tensor
|
| 7 |
+
|
| 8 |
+
class UndefinedGrad:
|
| 9 |
+
def __init__(self) -> None: ...
|
| 10 |
+
def __call__(self, *inputs: Tensor) -> list[Tensor]: ...
|
| 11 |
+
|
| 12 |
+
class DelayedError:
|
| 13 |
+
def __init__(self, msg: AnyStr, num_inputs: int) -> None: ...
|
| 14 |
+
|
| 15 |
+
# __call__ should really be a higher-kinded type:
|
| 16 |
+
# def __call__(self, arg: Tensor) -> Tensor: ...
|
| 17 |
+
# def __call__(self, *args: Tensor * num_inputs) -> Tuple[Tensor * num_inputs]: ...
|
| 18 |
+
|
| 19 |
+
@overload
|
| 20 |
+
def __call__(self, i0: Tensor) -> Tensor: ...
|
| 21 |
+
@overload
|
| 22 |
+
def __call__(self, *args: Tensor) -> tuple[Tensor, ...]: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_functorch.pyi
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
from enum import Enum
|
| 3 |
+
from typing import Any
|
| 4 |
+
|
| 5 |
+
from torch import Tensor
|
| 6 |
+
|
| 7 |
+
# Defined in torch/csrc/functorch/init.cpp
|
| 8 |
+
|
| 9 |
+
def _assert_wrapped_functional(
|
| 10 |
+
input_tensor: Tensor, wrapped_tensor: Tensor
|
| 11 |
+
) -> None: ...
|
| 12 |
+
def _func_decrement_nesting() -> int: ...
|
| 13 |
+
def _func_increment_nesting(reapply_views: bool) -> int: ...
|
| 14 |
+
def _propagate_functional_input_mutation(
|
| 15 |
+
input_tensor: Tensor, wrapped_tensor: Tensor
|
| 16 |
+
) -> None: ...
|
| 17 |
+
def set_inplace_requires_grad_allowed(allowed: bool) -> None: ...
|
| 18 |
+
def get_inplace_requires_grad_allowed() -> bool: ...
|
| 19 |
+
def _set_dynamic_layer_keys_included(included: bool) -> None: ...
|
| 20 |
+
def get_unwrapped(tensor: Tensor) -> Tensor: ...
|
| 21 |
+
def is_batchedtensor(tensor: Tensor) -> bool: ...
|
| 22 |
+
def is_functionaltensor(tensor: Tensor) -> bool: ...
|
| 23 |
+
def is_functorch_wrapped_tensor(tensor: Tensor) -> bool: ...
|
| 24 |
+
def is_gradtrackingtensor(tensor: Tensor) -> bool: ...
|
| 25 |
+
def is_legacy_batchedtensor(tensor: Tensor) -> bool: ...
|
| 26 |
+
def maybe_get_bdim(tensor: Tensor) -> int: ...
|
| 27 |
+
def maybe_get_level(tensor: Tensor) -> int: ...
|
| 28 |
+
def maybe_current_level() -> int | None: ...
|
| 29 |
+
def unwrap_dead_wrappers(args: tuple[Any, ...]) -> tuple[Any, ...]: ...
|
| 30 |
+
def unwrap_if_dead(tensor: Tensor) -> Tensor: ...
|
| 31 |
+
def _unwrap_for_grad(tensor: Tensor, level: int) -> Tensor: ...
|
| 32 |
+
def _wrap_for_grad(tensor: Tensor, level: int) -> Tensor: ...
|
| 33 |
+
def _unwrap_batched(tensor: Tensor, level: int) -> tuple[Tensor, int | None]: ...
|
| 34 |
+
def current_level() -> int: ...
|
| 35 |
+
def count_jvp_interpreters() -> int: ...
|
| 36 |
+
def _add_batch_dim(tensor: Tensor, bdim: int, level: int) -> Tensor: ...
|
| 37 |
+
def _remove_batch_dim(
|
| 38 |
+
tensor: Tensor, level: int, batch_size: int, out_dim: int
|
| 39 |
+
) -> Tensor: ...
|
| 40 |
+
def _maybe_unsafe_set_level(tensor: Tensor, level: int) -> None: ...
|
| 41 |
+
def set_single_level_autograd_function_allowed(allowed: bool) -> None: ...
|
| 42 |
+
def get_single_level_autograd_function_allowed() -> bool: ...
|
| 43 |
+
def _unwrap_functional_tensor(tensor: Tensor, reapply_views: bool) -> Tensor: ...
|
| 44 |
+
def _wrap_functional_tensor(tensor: Tensor, level: int) -> Tensor: ...
|
| 45 |
+
def _vmap_increment_nesting(batch_size: int, randomness: str) -> int: ...
|
| 46 |
+
def _vmap_decrement_nesting() -> int: ...
|
| 47 |
+
def _grad_increment_nesting() -> int: ...
|
| 48 |
+
def _grad_decrement_nesting() -> int: ...
|
| 49 |
+
def _jvp_increment_nesting() -> int: ...
|
| 50 |
+
def _jvp_decrement_nesting() -> int: ...
|
| 51 |
+
|
| 52 |
+
# Defined in aten/src/ATen/functorch/Interpreter.h
|
| 53 |
+
class TransformType(Enum):
|
| 54 |
+
Torch = ...
|
| 55 |
+
Vmap = ...
|
| 56 |
+
Grad = ...
|
| 57 |
+
Jvp = ...
|
| 58 |
+
Functionalize = ...
|
| 59 |
+
|
| 60 |
+
class RandomnessType(Enum):
|
| 61 |
+
Error = ...
|
| 62 |
+
Same = ...
|
| 63 |
+
Different = ...
|
| 64 |
+
|
| 65 |
+
class CInterpreter:
|
| 66 |
+
def key(self) -> TransformType: ...
|
| 67 |
+
def level(self) -> int: ...
|
| 68 |
+
def serialize(self) -> bytes: ...
|
| 69 |
+
@staticmethod
|
| 70 |
+
def deserialize(bytes) -> CInterpreter: ...
|
| 71 |
+
|
| 72 |
+
class CGradInterpreterPtr:
|
| 73 |
+
def __init__(self, interpreter: CInterpreter) -> None: ...
|
| 74 |
+
def lift(self, Tensor) -> Tensor: ...
|
| 75 |
+
def prevGradMode(self) -> bool: ...
|
| 76 |
+
|
| 77 |
+
class CJvpInterpreterPtr:
|
| 78 |
+
def __init__(self, interpreter: CInterpreter) -> None: ...
|
| 79 |
+
def lift(self, Tensor) -> Tensor: ...
|
| 80 |
+
def prevFwdGradMode(self) -> bool: ...
|
| 81 |
+
|
| 82 |
+
class CFunctionalizeInterpreterPtr:
|
| 83 |
+
def __init__(self, interpreter: CInterpreter) -> None: ...
|
| 84 |
+
def key(self) -> TransformType: ...
|
| 85 |
+
def level(self) -> int: ...
|
| 86 |
+
def functionalizeAddBackViews(self) -> bool: ...
|
| 87 |
+
|
| 88 |
+
class CVmapInterpreterPtr:
|
| 89 |
+
def __init__(self, interpreter: CInterpreter) -> None: ...
|
| 90 |
+
def key(self) -> TransformType: ...
|
| 91 |
+
def level(self) -> int: ...
|
| 92 |
+
def batchSize(self) -> int: ...
|
| 93 |
+
def randomness(self) -> RandomnessType: ...
|
| 94 |
+
|
| 95 |
+
class DynamicLayer: ...
|
| 96 |
+
|
| 97 |
+
def get_dynamic_layer_stack_depth() -> int: ...
|
| 98 |
+
def get_interpreter_stack() -> list[CInterpreter]: ...
|
| 99 |
+
def peek_interpreter_stack() -> CInterpreter: ...
|
| 100 |
+
def pop_dynamic_layer_stack() -> DynamicLayer: ...
|
| 101 |
+
def pop_dynamic_layer_stack_and_undo_to_depth(int) -> None: ...
|
| 102 |
+
def push_dynamic_layer_stack(dl: DynamicLayer) -> int: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_instruction_counter.pyi
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Defined in torch/csrc/instruction_counter/Module.cpp
|
| 2 |
+
|
| 3 |
+
def start() -> int: ...
|
| 4 |
+
def end(id: int) -> int: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_itt.pyi
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Defined in torch/csrc/itt.cpp
|
| 2 |
+
def is_available() -> None: ...
|
| 3 |
+
def rangePush(message: str) -> None: ...
|
| 4 |
+
def rangePop() -> None: ...
|
| 5 |
+
def mark(message: str) -> None: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_jit_tree_views.pyi
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any
|
| 2 |
+
|
| 3 |
+
# Defined in torch/csrc/jit/python/python_tree_views.cpp
|
| 4 |
+
|
| 5 |
+
class SourceRange:
|
| 6 |
+
def highlight(self) -> str: ...
|
| 7 |
+
@property
|
| 8 |
+
def start(self) -> int: ...
|
| 9 |
+
@property
|
| 10 |
+
def end(self) -> int: ...
|
| 11 |
+
|
| 12 |
+
class SourceRangeFactory:
|
| 13 |
+
def __init__(
|
| 14 |
+
self,
|
| 15 |
+
text: str,
|
| 16 |
+
filename: Any,
|
| 17 |
+
file_lineno: int,
|
| 18 |
+
leading_whitespace_chars: int,
|
| 19 |
+
) -> None: ...
|
| 20 |
+
def make_range(self, line: int, start_col: int, end_col: int) -> SourceRange: ...
|
| 21 |
+
def make_raw_range(self, start: int, end: int) -> SourceRange: ...
|
| 22 |
+
@property
|
| 23 |
+
def source(self) -> str: ...
|
| 24 |
+
|
| 25 |
+
class TreeView:
|
| 26 |
+
def range(self) -> SourceRange: ...
|
| 27 |
+
def dump(self) -> None: ...
|
| 28 |
+
|
| 29 |
+
class Ident(TreeView):
|
| 30 |
+
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
| 31 |
+
@property
|
| 32 |
+
def name(self) -> str: ...
|
| 33 |
+
|
| 34 |
+
class Param(TreeView):
|
| 35 |
+
def __init__(self, type: Any | None, name: Ident, kwarg_only: bool) -> None: ...
|
| 36 |
+
|
| 37 |
+
class Attribute(TreeView):
|
| 38 |
+
def __init__(self, name: Ident, value: Any) -> None: ...
|
| 39 |
+
|
| 40 |
+
# Literals
|
| 41 |
+
def TrueLiteral(range: SourceRange) -> Any: ...
|
| 42 |
+
def FalseLiteral(range: SourceRange) -> Any: ...
|
| 43 |
+
def NoneLiteral(range: SourceRange) -> Any: ...
|
| 44 |
+
|
| 45 |
+
# Tree nodes
|
| 46 |
+
class Stmt(TreeView):
|
| 47 |
+
def __init__(self, thing: TreeView) -> None: ...
|
| 48 |
+
|
| 49 |
+
class Expr(TreeView): ...
|
| 50 |
+
|
| 51 |
+
class Def(TreeView):
|
| 52 |
+
def __init__(self, name: Ident, decl: Any, body: list[Stmt]) -> None: ...
|
| 53 |
+
def decl(self) -> Any: ...
|
| 54 |
+
def name(self) -> Ident: ...
|
| 55 |
+
|
| 56 |
+
class Property(TreeView):
|
| 57 |
+
def __init__(
|
| 58 |
+
self, r: SourceRange, name: Ident, getter: Def, setter: Def | None
|
| 59 |
+
) -> None: ...
|
| 60 |
+
def name(self) -> Ident: ...
|
| 61 |
+
def getter_name(self) -> str: ...
|
| 62 |
+
def setter_name(self) -> Ident | None: ...
|
| 63 |
+
|
| 64 |
+
class ClassDef(TreeView):
|
| 65 |
+
def __init__(
|
| 66 |
+
self, name: Ident, body: list[Stmt], props: list[Property], assigns: list[Any]
|
| 67 |
+
) -> None: ...
|
| 68 |
+
|
| 69 |
+
class Decl(TreeView):
|
| 70 |
+
def __init__(
|
| 71 |
+
self, r: SourceRange, params: list[Param], return_type: Expr | None
|
| 72 |
+
) -> None: ...
|
| 73 |
+
|
| 74 |
+
class Delete(Stmt):
|
| 75 |
+
def __init__(self, range: SourceRange, targets: list[Expr]) -> None: ...
|
| 76 |
+
|
| 77 |
+
class WithItem(Expr):
|
| 78 |
+
def __init__(self, range: SourceRange, target: Expr, var: Any | None) -> None: ...
|
| 79 |
+
|
| 80 |
+
class Assign(Stmt):
|
| 81 |
+
def __init__(
|
| 82 |
+
self, lhs: list[Expr], rhs: Expr, type: Expr | None = None
|
| 83 |
+
) -> None: ...
|
| 84 |
+
|
| 85 |
+
class AugAssign(Stmt):
|
| 86 |
+
def __init__(self, lhs: Expr, kind_str: str, rhs: Expr) -> None: ...
|
| 87 |
+
|
| 88 |
+
class Return(Stmt):
|
| 89 |
+
def __init__(self, range: SourceRange, value: Expr | None) -> None: ...
|
| 90 |
+
|
| 91 |
+
class Raise(Stmt):
|
| 92 |
+
def __init__(self, range: SourceRange, expr: Expr) -> None: ...
|
| 93 |
+
|
| 94 |
+
class Assert(Stmt):
|
| 95 |
+
def __init__(self, range: SourceRange, test: Expr, msg: Expr | None) -> None: ...
|
| 96 |
+
|
| 97 |
+
class Pass(Stmt):
|
| 98 |
+
def __init__(self, range: SourceRange) -> None: ...
|
| 99 |
+
|
| 100 |
+
class Break(Stmt): ...
|
| 101 |
+
class Continue(Stmt): ...
|
| 102 |
+
|
| 103 |
+
class Dots(Expr, TreeView):
|
| 104 |
+
def __init__(self, range: SourceRange) -> None: ...
|
| 105 |
+
|
| 106 |
+
class If(Stmt):
|
| 107 |
+
def __init__(
|
| 108 |
+
self,
|
| 109 |
+
range: SourceRange,
|
| 110 |
+
cond: Expr,
|
| 111 |
+
true_branch: list[Stmt],
|
| 112 |
+
false_branch: list[Stmt],
|
| 113 |
+
) -> None: ...
|
| 114 |
+
|
| 115 |
+
class While(Stmt):
|
| 116 |
+
def __init__(self, range: SourceRange, cond: Expr, body: list[Stmt]) -> None: ...
|
| 117 |
+
|
| 118 |
+
class With(Stmt):
|
| 119 |
+
def __init__(
|
| 120 |
+
self, range: SourceRange, targets: list[WithItem], body: list[Stmt]
|
| 121 |
+
) -> None: ...
|
| 122 |
+
|
| 123 |
+
class For(Stmt):
|
| 124 |
+
def __init__(
|
| 125 |
+
self,
|
| 126 |
+
range: SourceRange,
|
| 127 |
+
targets: list[Expr],
|
| 128 |
+
itrs: list[Expr],
|
| 129 |
+
body: list[Stmt],
|
| 130 |
+
) -> None: ...
|
| 131 |
+
|
| 132 |
+
class ExprStmt(Stmt):
|
| 133 |
+
def __init__(self, expr: Expr) -> None: ...
|
| 134 |
+
|
| 135 |
+
class Var(Expr):
|
| 136 |
+
def __init__(self, name: Ident) -> None: ...
|
| 137 |
+
@property
|
| 138 |
+
def name(self) -> str: ...
|
| 139 |
+
|
| 140 |
+
class BinOp(Expr):
|
| 141 |
+
def __init__(self, kind: str, lhs: Expr, rhs: Expr) -> None: ...
|
| 142 |
+
|
| 143 |
+
class UnaryOp(Expr):
|
| 144 |
+
def __init__(self, range: SourceRange, kind: str, expr: Expr) -> None: ...
|
| 145 |
+
|
| 146 |
+
class Const(Expr):
|
| 147 |
+
def __init__(self, range: SourceRange, value: str) -> None: ...
|
| 148 |
+
|
| 149 |
+
class StringLiteral(Expr):
|
| 150 |
+
def __init__(self, range: SourceRange, value: str) -> None: ...
|
| 151 |
+
|
| 152 |
+
class Apply(Expr):
|
| 153 |
+
def __init__(
|
| 154 |
+
self, expr: Expr, args: list[Expr], kwargs: list[Attribute]
|
| 155 |
+
) -> None: ...
|
| 156 |
+
|
| 157 |
+
class Select(Expr):
|
| 158 |
+
def __init__(self, expr: Expr, field: Ident) -> None: ...
|
| 159 |
+
|
| 160 |
+
class TernaryIf(Expr):
|
| 161 |
+
def __init__(self, cond: Expr, true_expr: Expr, false_expr: Expr) -> None: ...
|
| 162 |
+
|
| 163 |
+
class ListComp(Expr):
|
| 164 |
+
def __init__(
|
| 165 |
+
self, range: SourceRange, elt: Expr, target: Expr, iter: Expr
|
| 166 |
+
) -> None: ...
|
| 167 |
+
|
| 168 |
+
class DictComp(Expr):
|
| 169 |
+
def __init__(
|
| 170 |
+
self, range: SourceRange, key: Expr, value: Expr, target: Expr, iter: Expr
|
| 171 |
+
) -> None: ...
|
| 172 |
+
|
| 173 |
+
class ListLiteral(Expr):
|
| 174 |
+
def __init__(self, range: SourceRange, args: list[Expr]) -> None: ...
|
| 175 |
+
|
| 176 |
+
class TupleLiteral(Expr):
|
| 177 |
+
def __init__(self, range: SourceRange, args: list[Expr]) -> None: ...
|
| 178 |
+
|
| 179 |
+
class DictLiteral(Expr):
|
| 180 |
+
def __init__(
|
| 181 |
+
self, range: SourceRange, keys: list[Expr], values: list[Expr]
|
| 182 |
+
) -> None: ...
|
| 183 |
+
|
| 184 |
+
class Subscript(Expr):
|
| 185 |
+
def __init__(self, base: Expr, subscript_exprs: list[Expr]) -> None: ...
|
| 186 |
+
|
| 187 |
+
class SliceExpr(Expr):
|
| 188 |
+
def __init__(
|
| 189 |
+
self,
|
| 190 |
+
range: SourceRange,
|
| 191 |
+
lower: Expr | None,
|
| 192 |
+
upper: Expr | None,
|
| 193 |
+
step: Expr | None,
|
| 194 |
+
) -> None: ...
|
| 195 |
+
|
| 196 |
+
class Starred(Expr):
|
| 197 |
+
def __init__(self, range: SourceRange, expr: Expr) -> None: ...
|
| 198 |
+
|
| 199 |
+
class EmptyTypeAnnotation(TreeView):
|
| 200 |
+
def __init__(self, range: SourceRange) -> None: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_lazy.pyi
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from torch import Tensor
|
| 2 |
+
|
| 3 |
+
# defined in torch/csrc/lazy/python/init.cpp
|
| 4 |
+
def _mark_step(device: str, devices: list[str], wait: bool) -> None: ...
|
| 5 |
+
def _wait_device_ops(devices: list[str]) -> None: ...
|
| 6 |
+
def _reset_metrics() -> None: ...
|
| 7 |
+
def _counter_names() -> list[str]: ...
|
| 8 |
+
def _counter_value(name: str) -> int: ...
|
| 9 |
+
def _metrics_report() -> str: ...
|
| 10 |
+
def _get_graph_hash(tensors: list[Tensor]) -> str: ...
|
| 11 |
+
def _sync_multi(
|
| 12 |
+
tensors: list[Tensor],
|
| 13 |
+
devices: list[str],
|
| 14 |
+
wait: bool = True,
|
| 15 |
+
sync_ltc_data: bool = True,
|
| 16 |
+
) -> None: ...
|
| 17 |
+
def _get_tensor_id(tensor: Tensor) -> int: ...
|
| 18 |
+
def _get_tensors_text(tensors: list[Tensor]) -> str: ...
|
| 19 |
+
def _get_tensors_dot(tensors: list[Tensor]) -> str: ...
|
| 20 |
+
def _get_tensors_backend(tensors: list[Tensor]) -> str: ...
|
| 21 |
+
def _get_force_fallback() -> str: ...
|
| 22 |
+
def _set_force_fallback(newval: str) -> None: ...
|
| 23 |
+
def _clear_ir_cache() -> None: ...
|
| 24 |
+
def _dump_ir_cache(filename: str) -> None: ...
|
| 25 |
+
def _set_reuse_ir(val: bool) -> None: ...
|
| 26 |
+
def _get_default_device_type() -> str: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_lazy_ts_backend.pyi
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
# defined in torch/csrc/lazy/python/init.cpp
|
| 3 |
+
|
| 4 |
+
from typing import Any
|
| 5 |
+
|
| 6 |
+
from torch import Tensor
|
| 7 |
+
|
| 8 |
+
def _init(): ...
|
| 9 |
+
def _get_tensors_ts_device_data_node(
|
| 10 |
+
tensors: list[Tensor],
|
| 11 |
+
) -> tuple[list[int], list[Any]]: ...
|
| 12 |
+
def _run_cached_graph(hash_str: str, graph_inputs: list[Any]) -> list[Tensor]: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_monitor.pyi
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Defined in torch/csrc/monitor/python_init.cpp
|
| 2 |
+
|
| 3 |
+
import datetime
|
| 4 |
+
from collections.abc import Callable
|
| 5 |
+
from enum import Enum
|
| 6 |
+
from types import TracebackType
|
| 7 |
+
|
| 8 |
+
class Aggregation(Enum):
|
| 9 |
+
VALUE = ...
|
| 10 |
+
MEAN = ...
|
| 11 |
+
COUNT = ...
|
| 12 |
+
SUM = ...
|
| 13 |
+
MAX = ...
|
| 14 |
+
MIN = ...
|
| 15 |
+
|
| 16 |
+
class Stat:
|
| 17 |
+
name: str
|
| 18 |
+
count: int
|
| 19 |
+
def __init__(
|
| 20 |
+
self,
|
| 21 |
+
name: str,
|
| 22 |
+
aggregations: list[Aggregation],
|
| 23 |
+
window_size: int,
|
| 24 |
+
max_samples: int = -1,
|
| 25 |
+
) -> None: ...
|
| 26 |
+
def add(self, v: float) -> None: ...
|
| 27 |
+
def get(self) -> dict[Aggregation, float]: ...
|
| 28 |
+
|
| 29 |
+
class Event:
|
| 30 |
+
name: str
|
| 31 |
+
timestamp: datetime.datetime
|
| 32 |
+
data: dict[str, int | float | bool | str]
|
| 33 |
+
def __init__(
|
| 34 |
+
self,
|
| 35 |
+
name: str,
|
| 36 |
+
timestamp: datetime.datetime,
|
| 37 |
+
data: dict[str, int | float | bool | str],
|
| 38 |
+
) -> None: ...
|
| 39 |
+
|
| 40 |
+
def log_event(e: Event) -> None: ...
|
| 41 |
+
|
| 42 |
+
class EventHandlerHandle: ...
|
| 43 |
+
|
| 44 |
+
def register_event_handler(handler: Callable[[Event], None]) -> EventHandlerHandle: ...
|
| 45 |
+
def unregister_event_handler(handle: EventHandlerHandle) -> None: ...
|
| 46 |
+
|
| 47 |
+
class _WaitCounterTracker:
|
| 48 |
+
def __enter__(self) -> None: ...
|
| 49 |
+
def __exit__(
|
| 50 |
+
self,
|
| 51 |
+
exc_type: type[BaseException] | None = None,
|
| 52 |
+
exc_value: BaseException | None = None,
|
| 53 |
+
traceback: TracebackType | None = None,
|
| 54 |
+
) -> None: ...
|
| 55 |
+
|
| 56 |
+
class _WaitCounter:
|
| 57 |
+
def __init__(self, key: str) -> None: ...
|
| 58 |
+
def guard(self) -> _WaitCounterTracker: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_nn.pyi
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @generated by tools/pyi/gen_pyi.py from torch/_C/_nn.pyi.in
|
| 2 |
+
# mypy: disable-error-code="type-arg"
|
| 3 |
+
|
| 4 |
+
from collections.abc import Sequence
|
| 5 |
+
from typing import Literal, overload
|
| 6 |
+
|
| 7 |
+
from torch import memory_format, Tensor
|
| 8 |
+
from torch.types import _bool, _device, _dtype, _int, _size
|
| 9 |
+
|
| 10 |
+
# Defined in tools/autograd/templates/python_nn_functions.cpp
|
| 11 |
+
|
| 12 |
+
def adaptive_avg_pool2d(input: Tensor, output_size: _int | _size) -> Tensor: ...
|
| 13 |
+
def adaptive_avg_pool3d(input: Tensor, output_size: _int | _size) -> Tensor: ...
|
| 14 |
+
def adaptive_max_pool2d(
|
| 15 |
+
input: Tensor,
|
| 16 |
+
output_size: _int | _size,
|
| 17 |
+
) -> tuple[Tensor, Tensor]: ...
|
| 18 |
+
def adaptive_max_pool3d(
|
| 19 |
+
input: Tensor,
|
| 20 |
+
output_size: _int | _size,
|
| 21 |
+
) -> tuple[Tensor, Tensor]: ...
|
| 22 |
+
def avg_pool2d(
|
| 23 |
+
input: Tensor,
|
| 24 |
+
kernel_size: _int | _size,
|
| 25 |
+
stride: _int | _size | None = None,
|
| 26 |
+
padding: _int | _size = 0,
|
| 27 |
+
ceil_mode: bool = False,
|
| 28 |
+
count_include_pad: bool = True,
|
| 29 |
+
divisor_override: int | None = None,
|
| 30 |
+
) -> Tensor: ...
|
| 31 |
+
def avg_pool3d(
|
| 32 |
+
input: Tensor,
|
| 33 |
+
kernel_size: _int | _size,
|
| 34 |
+
stride: _int | _size | None = None,
|
| 35 |
+
padding: _int | _size = 0,
|
| 36 |
+
ceil_mode: bool = False,
|
| 37 |
+
count_include_pad: bool = True,
|
| 38 |
+
divisor_override: int | None = None,
|
| 39 |
+
) -> Tensor: ...
|
| 40 |
+
def binary_cross_entropy(
|
| 41 |
+
input: Tensor,
|
| 42 |
+
target: Tensor,
|
| 43 |
+
weight: Tensor | None = None,
|
| 44 |
+
reduction: str = ...,
|
| 45 |
+
) -> Tensor: ...
|
| 46 |
+
def col2im(
|
| 47 |
+
input: Tensor,
|
| 48 |
+
output_size: _int | _size,
|
| 49 |
+
kernel_size: _int | _size,
|
| 50 |
+
dilation: _int | _size,
|
| 51 |
+
stride: _int | _size | None = None,
|
| 52 |
+
padding: _int | _size = 0,
|
| 53 |
+
) -> Tensor: ...
|
| 54 |
+
def cross_entropy_loss(
|
| 55 |
+
input: Tensor,
|
| 56 |
+
target: Tensor,
|
| 57 |
+
weight: Tensor | None = None,
|
| 58 |
+
reduction: str = ...,
|
| 59 |
+
ignore_index: int = -100,
|
| 60 |
+
label_smoothing: float = 0.0,
|
| 61 |
+
) -> Tensor: ...
|
| 62 |
+
def elu(
|
| 63 |
+
input: Tensor,
|
| 64 |
+
alpha: float = 1.0,
|
| 65 |
+
scale: float = 1.0,
|
| 66 |
+
input_scale: float = 1.0,
|
| 67 |
+
) -> Tensor: ...
|
| 68 |
+
def elu_(input: Tensor, alpha: float = ...) -> Tensor: ...
|
| 69 |
+
def fractional_max_pool2d(
|
| 70 |
+
input: Tensor,
|
| 71 |
+
kernel_size: _int | _size,
|
| 72 |
+
output_size: _int | _size,
|
| 73 |
+
_random_samples: Tensor,
|
| 74 |
+
) -> tuple[Tensor, Tensor]: ...
|
| 75 |
+
def fractional_max_pool3d(
|
| 76 |
+
input: Tensor,
|
| 77 |
+
kernel_size: _int | _size,
|
| 78 |
+
output_size: _int | _size,
|
| 79 |
+
_random_samples: Tensor,
|
| 80 |
+
) -> tuple[Tensor, Tensor]: ...
|
| 81 |
+
def gelu(input: Tensor, approximate: str = ...) -> Tensor: ...
|
| 82 |
+
def glu(input: Tensor, dim: int = -1) -> Tensor: ...
|
| 83 |
+
def hardsigmoid(input: Tensor, *, out: Tensor | None = None) -> Tensor: ...
|
| 84 |
+
def hardsigmoid_(input: Tensor) -> Tensor: ...
|
| 85 |
+
def hardswish(input: Tensor) -> Tensor: ...
|
| 86 |
+
def hardswish_(input: Tensor) -> Tensor: ...
|
| 87 |
+
def hardtanh(
|
| 88 |
+
input: Tensor,
|
| 89 |
+
min_val: float = ...,
|
| 90 |
+
max_val: float = ...,
|
| 91 |
+
*,
|
| 92 |
+
out: Tensor | None = None,
|
| 93 |
+
) -> Tensor: ...
|
| 94 |
+
def hardtanh_(
|
| 95 |
+
input: Tensor,
|
| 96 |
+
min_val: float = ...,
|
| 97 |
+
max_val: float = ...,
|
| 98 |
+
) -> Tensor: ...
|
| 99 |
+
def huber_loss(
|
| 100 |
+
input: Tensor,
|
| 101 |
+
target: Tensor,
|
| 102 |
+
reduction: str = ...,
|
| 103 |
+
delta: float = 1.0,
|
| 104 |
+
) -> Tensor: ...
|
| 105 |
+
def im2col(
|
| 106 |
+
input: Tensor,
|
| 107 |
+
kernel_size: _int | _size,
|
| 108 |
+
dilation: _int | _size,
|
| 109 |
+
padding: _int | _size,
|
| 110 |
+
stride: _int | _size,
|
| 111 |
+
) -> Tensor: ...
|
| 112 |
+
def l1_loss(input: Tensor, target: Tensor, reduction: str = ...) -> Tensor: ...
|
| 113 |
+
def leaky_relu(
|
| 114 |
+
input: Tensor,
|
| 115 |
+
negative_slope: float = ...,
|
| 116 |
+
*,
|
| 117 |
+
out: Tensor | None = None,
|
| 118 |
+
) -> Tensor: ...
|
| 119 |
+
def leaky_relu_(input: Tensor, negative_slope: float = ...) -> Tensor: ...
|
| 120 |
+
def linear(
|
| 121 |
+
input: Tensor,
|
| 122 |
+
weight: Tensor,
|
| 123 |
+
bias: Tensor | None = None,
|
| 124 |
+
) -> Tensor: ...
|
| 125 |
+
def log_sigmoid(input: Tensor) -> Tensor: ...
|
| 126 |
+
def max_pool2d_with_indices(
|
| 127 |
+
input: Tensor,
|
| 128 |
+
kernel_size: _int | _size,
|
| 129 |
+
stride: _int | _size | None = None,
|
| 130 |
+
padding: _int | _size = 0,
|
| 131 |
+
dilation: _int | _size = 1,
|
| 132 |
+
ceil_mode: bool = False,
|
| 133 |
+
) -> tuple[Tensor, Tensor]: ...
|
| 134 |
+
def max_pool3d_with_indices(
|
| 135 |
+
input: Tensor,
|
| 136 |
+
kernel_size: _int | _size,
|
| 137 |
+
stride: _int | _size | None = None,
|
| 138 |
+
padding: _int | _size = 0,
|
| 139 |
+
dilation: _int | _size = 1,
|
| 140 |
+
ceil_mode: bool = False,
|
| 141 |
+
) -> tuple[Tensor, Tensor]: ...
|
| 142 |
+
def max_unpool2d(
|
| 143 |
+
input: Tensor,
|
| 144 |
+
indices: Tensor,
|
| 145 |
+
output_size: Sequence[int] | None,
|
| 146 |
+
) -> Tensor: ...
|
| 147 |
+
def max_unpool3d(
|
| 148 |
+
input: Tensor,
|
| 149 |
+
indices: Tensor,
|
| 150 |
+
output_size: Sequence[int] | None,
|
| 151 |
+
stride: _int | _size,
|
| 152 |
+
padding: _int | _size,
|
| 153 |
+
) -> Tensor: ...
|
| 154 |
+
def mish(input: Tensor) -> Tensor: ...
|
| 155 |
+
def mish_(input: Tensor) -> Tensor: ...
|
| 156 |
+
def mse_loss(input: Tensor, target: Tensor, reduction: str = ...) -> Tensor: ...
|
| 157 |
+
def multi_margin_loss(
|
| 158 |
+
input: Tensor,
|
| 159 |
+
target: Tensor,
|
| 160 |
+
p: float = 1.0,
|
| 161 |
+
margin: float = 1.0,
|
| 162 |
+
weight: Tensor | None = None,
|
| 163 |
+
reduction: str = ...,
|
| 164 |
+
) -> Tensor: ...
|
| 165 |
+
def multilabel_margin_loss(
|
| 166 |
+
input: Tensor,
|
| 167 |
+
target: Tensor,
|
| 168 |
+
reduction: str = ...,
|
| 169 |
+
) -> Tensor: ...
|
| 170 |
+
def nll_loss_nd(
|
| 171 |
+
input: Tensor,
|
| 172 |
+
target: Tensor,
|
| 173 |
+
weight: Tensor | None = None,
|
| 174 |
+
reduction: str = ...,
|
| 175 |
+
ignore_index: int = -100,
|
| 176 |
+
) -> Tensor: ...
|
| 177 |
+
def one_hot(tensor: Tensor, num_classes: int = ...) -> Tensor: ...
|
| 178 |
+
def pad(
|
| 179 |
+
input: Tensor,
|
| 180 |
+
pad: Sequence[int],
|
| 181 |
+
mode: str = ...,
|
| 182 |
+
value: float | None = None,
|
| 183 |
+
) -> Tensor: ...
|
| 184 |
+
def relu6(input: Tensor) -> Tensor: ...
|
| 185 |
+
def relu6_(input: Tensor) -> Tensor: ...
|
| 186 |
+
def scaled_dot_product_attention(
|
| 187 |
+
query: Tensor,
|
| 188 |
+
key: Tensor,
|
| 189 |
+
value: Tensor,
|
| 190 |
+
attn_mask: Tensor | None = None,
|
| 191 |
+
dropout_p: float = 0.0,
|
| 192 |
+
is_causal: bool = False,
|
| 193 |
+
scale: float | None = None,
|
| 194 |
+
enable_gqa: bool = False,
|
| 195 |
+
) -> Tensor: ...
|
| 196 |
+
def silu(input: Tensor) -> Tensor: ...
|
| 197 |
+
def silu_(input: Tensor) -> Tensor: ...
|
| 198 |
+
def smooth_l1_loss(
|
| 199 |
+
input: Tensor,
|
| 200 |
+
target: Tensor,
|
| 201 |
+
reduction: str = ...,
|
| 202 |
+
beta: float = 1.0,
|
| 203 |
+
) -> Tensor: ...
|
| 204 |
+
def soft_margin_loss(
|
| 205 |
+
input: Tensor,
|
| 206 |
+
target: Tensor,
|
| 207 |
+
reduction: str = ...,
|
| 208 |
+
) -> Tensor: ...
|
| 209 |
+
def softplus(
|
| 210 |
+
input: Tensor,
|
| 211 |
+
beta: float = ...,
|
| 212 |
+
threshold: float = ...,
|
| 213 |
+
) -> Tensor: ...
|
| 214 |
+
def softshrink(input: Tensor, lambd: float = ...) -> Tensor: ...
|
| 215 |
+
|
| 216 |
+
# Defined in aten/src/ATen/native/mkldnn/Linear.cpp
|
| 217 |
+
def mkldnn_linear(input: Tensor, weight: Tensor, bias: Tensor | None) -> Tensor: ...
|
| 218 |
+
|
| 219 |
+
# Defined at aten/src/ATen/native/mkldnn/MKLDNNConversions.cpp
|
| 220 |
+
def mkldnn_reorder_conv2d_weight(
|
| 221 |
+
self: Tensor,
|
| 222 |
+
padding: list,
|
| 223 |
+
stride: list,
|
| 224 |
+
dilatation: list,
|
| 225 |
+
groups: int,
|
| 226 |
+
) -> Tensor: ...
|
| 227 |
+
def mkldnn_reorder_conv3d_weight(
|
| 228 |
+
self: Tensor,
|
| 229 |
+
padding: list,
|
| 230 |
+
stride: list,
|
| 231 |
+
dilatation: list,
|
| 232 |
+
groups: int,
|
| 233 |
+
) -> Tensor: ...
|
| 234 |
+
|
| 235 |
+
# Defined in aten/src/ATen/native/mkldnn/Prelu.cpp
|
| 236 |
+
def mkldnn_prelu(input: Tensor, weight: Tensor) -> Tensor: ...
|
| 237 |
+
|
| 238 |
+
# Defined at tools/autograd/templates/python_nn_functions.cpp
|
| 239 |
+
@overload
|
| 240 |
+
def _parse_to(
|
| 241 |
+
device: _device,
|
| 242 |
+
dtype: _dtype,
|
| 243 |
+
non_blocking: _bool,
|
| 244 |
+
copy: _bool,
|
| 245 |
+
*,
|
| 246 |
+
memory_format: memory_format,
|
| 247 |
+
) -> tuple[_device, _dtype, _bool, memory_format]: ...
|
| 248 |
+
@overload
|
| 249 |
+
def _parse_to(
|
| 250 |
+
dtype: _dtype,
|
| 251 |
+
non_blocking: _bool,
|
| 252 |
+
copy: _bool,
|
| 253 |
+
*,
|
| 254 |
+
memory_format: memory_format,
|
| 255 |
+
) -> tuple[_device, _dtype, _bool, memory_format]: ...
|
| 256 |
+
@overload
|
| 257 |
+
def _parse_to(
|
| 258 |
+
tensor: Tensor,
|
| 259 |
+
non_blocking: _bool,
|
| 260 |
+
copy: _bool,
|
| 261 |
+
*,
|
| 262 |
+
memory_format: memory_format,
|
| 263 |
+
) -> tuple[_device, _dtype, _bool, memory_format]: ...
|
| 264 |
+
|
| 265 |
+
# Defined in aten/src/ATen/native/PackedSequence.cpp
|
| 266 |
+
def pad_sequence(
|
| 267 |
+
sequences: list[Tensor] | tuple[Tensor, ...],
|
| 268 |
+
batch_first: bool = False,
|
| 269 |
+
padding_value: float = 0.0,
|
| 270 |
+
padding_side: Literal["left", "right"] = "right",
|
| 271 |
+
) -> Tensor: ...
|
| 272 |
+
|
| 273 |
+
# Upsample functions used by torch.nn.functional.interpolate
|
| 274 |
+
def upsample_nearest1d(
|
| 275 |
+
input: Tensor,
|
| 276 |
+
output_size: Sequence[int] | None,
|
| 277 |
+
scale_factors: Sequence[float] | None,
|
| 278 |
+
) -> Tensor: ...
|
| 279 |
+
def upsample_nearest2d(
|
| 280 |
+
input: Tensor,
|
| 281 |
+
output_size: Sequence[int] | None,
|
| 282 |
+
scale_factors: Sequence[float] | None,
|
| 283 |
+
) -> Tensor: ...
|
| 284 |
+
def upsample_nearest3d(
|
| 285 |
+
input: Tensor,
|
| 286 |
+
output_size: Sequence[int] | None,
|
| 287 |
+
scale_factors: Sequence[float] | None,
|
| 288 |
+
) -> Tensor: ...
|
| 289 |
+
def _upsample_nearest_exact1d(
|
| 290 |
+
input: Tensor,
|
| 291 |
+
output_size: Sequence[int] | None,
|
| 292 |
+
scale_factors: Sequence[float] | None,
|
| 293 |
+
) -> Tensor: ...
|
| 294 |
+
def _upsample_nearest_exact2d(
|
| 295 |
+
input: Tensor,
|
| 296 |
+
output_size: Sequence[int] | None,
|
| 297 |
+
scale_factors: Sequence[float] | None,
|
| 298 |
+
) -> Tensor: ...
|
| 299 |
+
def _upsample_nearest_exact3d(
|
| 300 |
+
input: Tensor,
|
| 301 |
+
output_size: Sequence[int] | None,
|
| 302 |
+
scale_factors: Sequence[float] | None,
|
| 303 |
+
) -> Tensor: ...
|
| 304 |
+
def upsample_linear1d(
|
| 305 |
+
input: Tensor,
|
| 306 |
+
output_size: Sequence[int] | None,
|
| 307 |
+
align_corners: bool,
|
| 308 |
+
scale_factors: Sequence[float] | None,
|
| 309 |
+
) -> Tensor: ...
|
| 310 |
+
def _upsample_bilinear2d_aa(
|
| 311 |
+
input: Tensor,
|
| 312 |
+
output_size: Sequence[int] | None,
|
| 313 |
+
align_corners: bool,
|
| 314 |
+
scale_factors: Sequence[float] | None,
|
| 315 |
+
) -> Tensor: ...
|
| 316 |
+
def upsample_bilinear2d(
|
| 317 |
+
input: Tensor,
|
| 318 |
+
output_size: Sequence[int] | None,
|
| 319 |
+
align_corners: bool,
|
| 320 |
+
scale_factors: Sequence[float] | None,
|
| 321 |
+
) -> Tensor: ...
|
| 322 |
+
def upsample_trilinear3d(
|
| 323 |
+
input: Tensor,
|
| 324 |
+
output_size: Sequence[int] | None,
|
| 325 |
+
align_corners: bool,
|
| 326 |
+
scale_factors: Sequence[float] | None,
|
| 327 |
+
) -> Tensor: ...
|
| 328 |
+
def _upsample_bicubic2d_aa(
|
| 329 |
+
input: Tensor,
|
| 330 |
+
output_size: Sequence[int] | None,
|
| 331 |
+
align_corners: bool,
|
| 332 |
+
scale_factors: Sequence[float] | None,
|
| 333 |
+
) -> Tensor: ...
|
| 334 |
+
def _upsample_lanczos2d_aa(
|
| 335 |
+
input: Tensor,
|
| 336 |
+
output_size: Sequence[int] | None,
|
| 337 |
+
align_corners: bool,
|
| 338 |
+
scale_factors: Sequence[float] | None,
|
| 339 |
+
) -> Tensor: ...
|
| 340 |
+
def upsample_bicubic2d(
|
| 341 |
+
input: Tensor,
|
| 342 |
+
output_size: Sequence[int] | None,
|
| 343 |
+
align_corners: bool,
|
| 344 |
+
scale_factors: Sequence[float] | None,
|
| 345 |
+
) -> Tensor: ...
|
| 346 |
+
def flatten_dense_tensors(tensors: list[Tensor]) -> Tensor: ...
|
| 347 |
+
def unflatten_dense_tensors(flat: Tensor, tensors: list[Tensor]) -> list[Tensor]: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_nvtx.pyi
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
# Defined in torch/csrc/cuda/shared/nvtx.cpp
|
| 3 |
+
def rangePushA(message: str) -> int: ...
|
| 4 |
+
def rangePop() -> int: ...
|
| 5 |
+
def rangeStartA(message: str) -> int: ...
|
| 6 |
+
def rangeEnd(int) -> None: ...
|
| 7 |
+
def markA(message: str) -> None: ...
|
| 8 |
+
def deviceRangeStart(message: str, stream: int) -> object: ...
|
| 9 |
+
def deviceRangeEnd(range_handle: object, stream: int) -> None: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_onnx.pyi
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Defined in torch/csrc/onnx/init.cpp
|
| 2 |
+
|
| 3 |
+
from enum import Enum
|
| 4 |
+
|
| 5 |
+
PRODUCER_VERSION: str
|
| 6 |
+
|
| 7 |
+
class TensorProtoDataType(Enum):
|
| 8 |
+
UNDEFINED = ...
|
| 9 |
+
FLOAT = ...
|
| 10 |
+
UINT8 = ...
|
| 11 |
+
INT8 = ...
|
| 12 |
+
UINT16 = ...
|
| 13 |
+
INT16 = ...
|
| 14 |
+
INT32 = ...
|
| 15 |
+
INT64 = ...
|
| 16 |
+
STRING = ...
|
| 17 |
+
BOOL = ...
|
| 18 |
+
FLOAT16 = ...
|
| 19 |
+
DOUBLE = ...
|
| 20 |
+
UINT32 = ...
|
| 21 |
+
UINT64 = ...
|
| 22 |
+
COMPLEX64 = ...
|
| 23 |
+
COMPLEX128 = ...
|
| 24 |
+
BFLOAT16 = ...
|
| 25 |
+
FLOAT8E5M2 = ...
|
| 26 |
+
FLOAT8E4M3FN = ...
|
| 27 |
+
FLOAT8E5M2FNUZ = ...
|
| 28 |
+
FLOAT8E4M3FNUZ = ...
|
| 29 |
+
|
| 30 |
+
class OperatorExportTypes(Enum):
|
| 31 |
+
ONNX = ...
|
| 32 |
+
ONNX_ATEN = ...
|
| 33 |
+
ONNX_ATEN_FALLBACK = ...
|
| 34 |
+
ONNX_FALLTHROUGH = ...
|
| 35 |
+
|
| 36 |
+
class TrainingMode(Enum):
|
| 37 |
+
EVAL = ...
|
| 38 |
+
PRESERVE = ...
|
| 39 |
+
TRAINING = ...
|
.venv/lib/python3.12/site-packages/torch/_C/_profiler.pyi
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
from torch._C import device, dtype, layout
|
| 5 |
+
|
| 6 |
+
# defined in torch/csrc/profiler/python/init.cpp
|
| 7 |
+
|
| 8 |
+
class RecordScope(Enum):
|
| 9 |
+
FUNCTION = ...
|
| 10 |
+
BACKWARD_FUNCTION = ...
|
| 11 |
+
TORCHSCRIPT_FUNCTION = ...
|
| 12 |
+
KERNEL_FUNCTION_DTYPE = ...
|
| 13 |
+
CUSTOM_CLASS = ...
|
| 14 |
+
BUILD_FEATURE = ...
|
| 15 |
+
LITE_INTERPRETER = ...
|
| 16 |
+
USER_SCOPE = ...
|
| 17 |
+
STATIC_RUNTIME_OP = ...
|
| 18 |
+
STATIC_RUNTIME_MODEL = ...
|
| 19 |
+
|
| 20 |
+
class ProfilerState(Enum):
|
| 21 |
+
Disabled = ...
|
| 22 |
+
CPU = ...
|
| 23 |
+
CUDA = ...
|
| 24 |
+
NVTX = ...
|
| 25 |
+
ITT = ...
|
| 26 |
+
PRIVATEUSE1 = ...
|
| 27 |
+
KINETO = ...
|
| 28 |
+
KINETO_GPU_FALLBACK = ...
|
| 29 |
+
KINETO_PRIVATEUSE1_FALLBACK = ...
|
| 30 |
+
KINETO_PRIVATEUSE1 = ...
|
| 31 |
+
|
| 32 |
+
class ActiveProfilerType(Enum):
|
| 33 |
+
NONE = ...
|
| 34 |
+
LEGACY = ...
|
| 35 |
+
KINETO = ...
|
| 36 |
+
NVTX = ...
|
| 37 |
+
ITT = ...
|
| 38 |
+
PRIVATEUSE1 = ...
|
| 39 |
+
|
| 40 |
+
class ProfilerActivity(Enum):
|
| 41 |
+
CPU = ...
|
| 42 |
+
CUDA = ...
|
| 43 |
+
XPU = ...
|
| 44 |
+
MTIA = ...
|
| 45 |
+
HPU = ...
|
| 46 |
+
PrivateUse1 = ...
|
| 47 |
+
|
| 48 |
+
class _EventType(Enum):
|
| 49 |
+
TorchOp = ...
|
| 50 |
+
Backend = ...
|
| 51 |
+
Allocation = ...
|
| 52 |
+
OutOfMemory = ...
|
| 53 |
+
PyCall = ...
|
| 54 |
+
PyCCall = ...
|
| 55 |
+
Kineto = ...
|
| 56 |
+
|
| 57 |
+
class _ExperimentalConfig:
|
| 58 |
+
def __init__(
|
| 59 |
+
self,
|
| 60 |
+
profiler_metrics: list[str] = ...,
|
| 61 |
+
profiler_measure_per_kernel: bool = ...,
|
| 62 |
+
verbose: bool = ...,
|
| 63 |
+
performance_events: list[str] = ...,
|
| 64 |
+
enable_cuda_sync_events: bool = ...,
|
| 65 |
+
adjust_profiler_step: bool = ...,
|
| 66 |
+
disable_external_correlation: bool = ...,
|
| 67 |
+
profile_all_threads: bool = ...,
|
| 68 |
+
capture_overload_names: bool = ...,
|
| 69 |
+
record_python_gc_info: bool = ...,
|
| 70 |
+
expose_kineto_event_metadata: bool = ...,
|
| 71 |
+
custom_profiler_config: str = ...,
|
| 72 |
+
adjust_timestamps: bool = ...,
|
| 73 |
+
trace_only: bool = ...,
|
| 74 |
+
) -> None: ...
|
| 75 |
+
trace_only: bool
|
| 76 |
+
# Deprecated no-ops; retained only so the Python layer can detect and warn.
|
| 77 |
+
profiler_metrics: list[str]
|
| 78 |
+
profiler_measure_per_kernel: bool
|
| 79 |
+
|
| 80 |
+
class ProfilerConfig:
|
| 81 |
+
def __init__(
|
| 82 |
+
self,
|
| 83 |
+
state: ProfilerState,
|
| 84 |
+
report_input_shapes: bool,
|
| 85 |
+
profile_memory: bool,
|
| 86 |
+
with_stack: bool,
|
| 87 |
+
with_flops: bool,
|
| 88 |
+
with_modules: bool,
|
| 89 |
+
experimental_config: _ExperimentalConfig,
|
| 90 |
+
trace_id: str | None = None,
|
| 91 |
+
) -> None: ...
|
| 92 |
+
|
| 93 |
+
class _ProfilerEvent:
|
| 94 |
+
start_tid: int
|
| 95 |
+
start_time_ns: int
|
| 96 |
+
children: list[_ProfilerEvent]
|
| 97 |
+
|
| 98 |
+
# TODO(robieta): remove in favor of `self.typed`
|
| 99 |
+
extra_fields: (
|
| 100 |
+
_ExtraFields_TorchOp
|
| 101 |
+
| _ExtraFields_Backend
|
| 102 |
+
| _ExtraFields_Allocation
|
| 103 |
+
| _ExtraFields_OutOfMemory
|
| 104 |
+
| _ExtraFields_PyCall
|
| 105 |
+
| _ExtraFields_PyCCall
|
| 106 |
+
| _ExtraFields_Kineto
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
@property
|
| 110 |
+
def typed(
|
| 111 |
+
self,
|
| 112 |
+
) -> (
|
| 113 |
+
tuple[Literal[_EventType.TorchOp], _ExtraFields_TorchOp]
|
| 114 |
+
| tuple[Literal[_EventType.Backend], _ExtraFields_Backend]
|
| 115 |
+
| tuple[Literal[_EventType.Allocation], _ExtraFields_Allocation]
|
| 116 |
+
| tuple[Literal[_EventType.OutOfMemory], _ExtraFields_OutOfMemory]
|
| 117 |
+
| tuple[Literal[_EventType.PyCall], _ExtraFields_PyCall]
|
| 118 |
+
| tuple[Literal[_EventType.PyCCall], _ExtraFields_PyCCall]
|
| 119 |
+
| tuple[Literal[_EventType.Kineto], _ExtraFields_Kineto]
|
| 120 |
+
): ...
|
| 121 |
+
@property
|
| 122 |
+
def name(self) -> str: ...
|
| 123 |
+
@property
|
| 124 |
+
def overload_name(self) -> str: ...
|
| 125 |
+
@property
|
| 126 |
+
def tag(self) -> _EventType: ...
|
| 127 |
+
@property
|
| 128 |
+
def id(self) -> int: ...
|
| 129 |
+
@property
|
| 130 |
+
def parent(self) -> _ProfilerEvent | None: ...
|
| 131 |
+
@property
|
| 132 |
+
def correlation_id(self) -> int: ...
|
| 133 |
+
@property
|
| 134 |
+
def end_time_ns(self) -> int: ...
|
| 135 |
+
@property
|
| 136 |
+
def duration_time_ns(self) -> int: ...
|
| 137 |
+
|
| 138 |
+
class _TensorMetadata:
|
| 139 |
+
impl_ptr: int | None
|
| 140 |
+
storage_data_ptr: int | None
|
| 141 |
+
id: int | None
|
| 142 |
+
|
| 143 |
+
@property
|
| 144 |
+
def allocation_id(self) -> int | None: ...
|
| 145 |
+
@property
|
| 146 |
+
def layout(self) -> layout: ...
|
| 147 |
+
@property
|
| 148 |
+
def device(self) -> device: ...
|
| 149 |
+
@property
|
| 150 |
+
def dtype(self) -> dtype: ...
|
| 151 |
+
@property
|
| 152 |
+
def sizes(self) -> list[int]: ...
|
| 153 |
+
@property
|
| 154 |
+
def strides(self) -> list[int]: ...
|
| 155 |
+
|
| 156 |
+
Scalar: TypeAlias = int | float | bool | complex
|
| 157 |
+
Input: TypeAlias = _TensorMetadata | list[_TensorMetadata] | Scalar | None
|
| 158 |
+
|
| 159 |
+
class _ExtraFields_TorchOp:
|
| 160 |
+
name: str
|
| 161 |
+
sequence_number: int
|
| 162 |
+
allow_tf32_cublas: bool
|
| 163 |
+
|
| 164 |
+
@property
|
| 165 |
+
def inputs(self) -> list[Input]: ...
|
| 166 |
+
@property
|
| 167 |
+
def scope(self) -> RecordScope: ...
|
| 168 |
+
|
| 169 |
+
class _ExtraFields_Backend: ...
|
| 170 |
+
|
| 171 |
+
class _ExtraFields_Allocation:
|
| 172 |
+
ptr: int
|
| 173 |
+
id: int | None
|
| 174 |
+
alloc_size: int
|
| 175 |
+
total_allocated: int
|
| 176 |
+
total_reserved: int
|
| 177 |
+
|
| 178 |
+
@property
|
| 179 |
+
def allocation_id(self) -> int | None: ...
|
| 180 |
+
@property
|
| 181 |
+
def device(self) -> device: ...
|
| 182 |
+
|
| 183 |
+
class _ExtraFields_OutOfMemory: ...
|
| 184 |
+
|
| 185 |
+
class _PyFrameState:
|
| 186 |
+
line_number: int
|
| 187 |
+
function_name: str
|
| 188 |
+
|
| 189 |
+
@property
|
| 190 |
+
def file_name(self) -> str: ...
|
| 191 |
+
|
| 192 |
+
class _NNModuleInfo:
|
| 193 |
+
@property
|
| 194 |
+
def self_ptr(self) -> int: ...
|
| 195 |
+
@property
|
| 196 |
+
def cls_ptr(self) -> int: ...
|
| 197 |
+
@property
|
| 198 |
+
def cls_name(self) -> str: ...
|
| 199 |
+
@property
|
| 200 |
+
def parameters(
|
| 201 |
+
self,
|
| 202 |
+
) -> list[tuple[str, _TensorMetadata, _TensorMetadata | None]]: ...
|
| 203 |
+
|
| 204 |
+
class _OptimizerInfo:
|
| 205 |
+
@property
|
| 206 |
+
def parameters(
|
| 207 |
+
self,
|
| 208 |
+
) -> list[
|
| 209 |
+
tuple[
|
| 210 |
+
# Parameter
|
| 211 |
+
_TensorMetadata,
|
| 212 |
+
#
|
| 213 |
+
# Gradient (if present during optimizer.step())
|
| 214 |
+
_TensorMetadata | None,
|
| 215 |
+
#
|
| 216 |
+
# Optimizer state for Parameter as (name, tensor) pairs
|
| 217 |
+
list[tuple[str, _TensorMetadata]],
|
| 218 |
+
]
|
| 219 |
+
]: ...
|
| 220 |
+
|
| 221 |
+
class _ExtraFields_PyCCall:
|
| 222 |
+
@property
|
| 223 |
+
def caller(self) -> _PyFrameState: ...
|
| 224 |
+
|
| 225 |
+
class _ExtraFields_PyCall:
|
| 226 |
+
@property
|
| 227 |
+
def callsite(self) -> _PyFrameState: ...
|
| 228 |
+
@property
|
| 229 |
+
def caller(self) -> _PyFrameState: ...
|
| 230 |
+
@property
|
| 231 |
+
def module(self) -> _NNModuleInfo | None: ...
|
| 232 |
+
@property
|
| 233 |
+
def optimizer(self) -> _OptimizerInfo | None: ...
|
| 234 |
+
|
| 235 |
+
class _ExtraFields_Kineto: ...
|
| 236 |
+
|
| 237 |
+
def _add_execution_trace_observer(output_file_path: str) -> bool: ...
|
| 238 |
+
def _remove_execution_trace_observer() -> None: ...
|
| 239 |
+
def _enable_execution_trace_observer() -> None: ...
|
| 240 |
+
def _disable_execution_trace_observer() -> None: ...
|
| 241 |
+
def _set_record_concrete_inputs_enabled_val(val: bool) -> None: ...
|
| 242 |
+
def _set_fwd_bwd_enabled_val(val: bool) -> None: ...
|
| 243 |
+
def _set_cuda_sync_enabled_val(val: bool) -> None: ...
|
| 244 |
+
|
| 245 |
+
# Approximate-clock helpers used by the experimental CUPTI monitor.
|
| 246 |
+
class _ApproximateClockToUnixTimeConverter:
|
| 247 |
+
def __init__(self) -> None: ...
|
| 248 |
+
def to_unix_ns(self, t: int) -> int: ...
|
| 249 |
+
|
| 250 |
+
def _get_approximate_time() -> int: ...
|
| 251 |
+
|
| 252 |
+
# GIL-free CUPTI monitor buffer pool (torch/csrc/profiler/cupti/monitor_native).
|
| 253 |
+
# Exposed as the torch._C._profiler._cupti_monitor submodule.
|
| 254 |
+
class _CuptiMonitorModule:
|
| 255 |
+
@staticmethod
|
| 256 |
+
def approximate_time_callback_address() -> int: ...
|
| 257 |
+
@staticmethod
|
| 258 |
+
def configure_buffers(buffer_size: int) -> None: ...
|
| 259 |
+
@staticmethod
|
| 260 |
+
def buffer_request_callback_address() -> int: ...
|
| 261 |
+
@staticmethod
|
| 262 |
+
def buffer_complete_callback_address() -> int: ...
|
| 263 |
+
@staticmethod
|
| 264 |
+
def get_completed() -> (
|
| 265 |
+
tuple[int, int, int, int, list[tuple[int, int, list[tuple[int, int, int]]]]]
|
| 266 |
+
| None
|
| 267 |
+
): ...
|
| 268 |
+
@staticmethod
|
| 269 |
+
def return_buffer(ptr: int) -> None: ...
|
| 270 |
+
@staticmethod
|
| 271 |
+
def pending_buffers() -> int: ...
|
| 272 |
+
@staticmethod
|
| 273 |
+
def allocated_buffers() -> int: ...
|
| 274 |
+
@staticmethod
|
| 275 |
+
def shutdown_buffers() -> None: ...
|
| 276 |
+
@staticmethod
|
| 277 |
+
def reset_buffers() -> None: ...
|
| 278 |
+
@staticmethod
|
| 279 |
+
def configure_decoder(
|
| 280 |
+
subscriber: int,
|
| 281 |
+
get_next_record_fn: int,
|
| 282 |
+
fence_kind: int = 0,
|
| 283 |
+
fence_end_field: int = -1,
|
| 284 |
+
self_flush: bool = False,
|
| 285 |
+
flush_period_ns: int = 0,
|
| 286 |
+
flush_fn: int = 0,
|
| 287 |
+
) -> None: ...
|
| 288 |
+
@staticmethod
|
| 289 |
+
def start_decoder() -> None: ...
|
| 290 |
+
@staticmethod
|
| 291 |
+
def stop_decoder() -> None: ...
|
| 292 |
+
@staticmethod
|
| 293 |
+
def decoder_max_sync_ns() -> int: ...
|
| 294 |
+
@staticmethod
|
| 295 |
+
def decoder_buffers_decoded() -> int: ...
|
| 296 |
+
@staticmethod
|
| 297 |
+
def decoder_valid_bytes() -> int: ...
|
| 298 |
+
@staticmethod
|
| 299 |
+
def drain_decoded() -> tuple[list, dict[int, str]]: ...
|
| 300 |
+
@staticmethod
|
| 301 |
+
def bench_decode(
|
| 302 |
+
buffer_addr: int,
|
| 303 |
+
valid_size: int,
|
| 304 |
+
record_layouts: list[tuple[int, int, list[tuple[int, int, int]]]],
|
| 305 |
+
iters: int,
|
| 306 |
+
) -> float: ...
|
| 307 |
+
@staticmethod
|
| 308 |
+
def note_external_push(external_id: int) -> None: ...
|
| 309 |
+
@staticmethod
|
| 310 |
+
def note_external_pop() -> int: ...
|
| 311 |
+
@staticmethod
|
| 312 |
+
def current_external_id() -> int: ...
|
| 313 |
+
@staticmethod
|
| 314 |
+
def metadata_put_external(blob: str, external_id: int = 0) -> None: ...
|
| 315 |
+
# groups: each a tuple (ts, end, track_uuid, name_iid, int_annos, str_annos,
|
| 316 |
+
# arr_annos, json_annos, flow, gpu_corr, cat_iid) where gpu_corr is a
|
| 317 |
+
# (int32_offsets, int64_ids) CSR of per-slice render-stage event_ids or None.
|
| 318 |
+
# render: (gpu_specs, gfx_contexts, stage_cols, extra, launch, tables, const_extra)
|
| 319 |
+
# where stage_cols = (ts, dur, event_id, gpu_id, hw_queue_iid, stage_iid,
|
| 320 |
+
# context, name_iid, event_wait) and event_wait is a (int32_offsets, uint64_ids)
|
| 321 |
+
# CSR of per-stage event_wait_ids (graph node->node dependency arrows).
|
| 322 |
+
@staticmethod
|
| 323 |
+
def encode_pftrace(
|
| 324 |
+
base_ns: int,
|
| 325 |
+
tracks: list[tuple[int, int, bool, int, int, str]],
|
| 326 |
+
name_table: list[str],
|
| 327 |
+
category_table: list[str],
|
| 328 |
+
groups: list[tuple],
|
| 329 |
+
render: tuple | None = None,
|
| 330 |
+
counters: tuple | None = None,
|
| 331 |
+
compression_level: int = 1,
|
| 332 |
+
) -> bytes: ...
|
| 333 |
+
|
| 334 |
+
_cupti_monitor: _CuptiMonitorModule
|
| 335 |
+
|
| 336 |
+
class CapturedTraceback: ...
|
| 337 |
+
|
| 338 |
+
def gather_traceback(python: bool, script: bool, cpp: bool) -> CapturedTraceback: ...
|
| 339 |
+
|
| 340 |
+
# The Dict has name, filename, line
|
| 341 |
+
def symbolize_tracebacks(
|
| 342 |
+
to_symbolize: list[CapturedTraceback],
|
| 343 |
+
) -> list[list[dict[str, str]]]: ...
|
| 344 |
+
|
| 345 |
+
class _RecordFunctionFast:
|
| 346 |
+
def __init__(
|
| 347 |
+
self,
|
| 348 |
+
name: str,
|
| 349 |
+
input_values: list | tuple | None = None,
|
| 350 |
+
keyword_values: dict | None = None,
|
| 351 |
+
) -> None: ...
|
| 352 |
+
def __enter__(self) -> None: ...
|
| 353 |
+
def __exit__(self, *exc_info: object) -> None: ...
|
.venv/lib/python3.12/site-packages/torch/_C/_verbose.pyi
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Defined in torch/csrc/utils/verbose.cpp
|
| 2 |
+
def mkl_set_verbose(enable: int) -> int: ...
|
| 3 |
+
def mkldnn_set_verbose(level: int) -> int: ...
|
.venv/lib/python3.12/site-packages/torch/_C_flatbuffer/__init__.pyi
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: allow-untyped-defs
|
| 2 |
+
from torch._C import LiteScriptModule, ScriptModule
|
| 3 |
+
|
| 4 |
+
def _load_mobile_module_from_file(filename: str): ...
|
| 5 |
+
def _load_mobile_module_from_bytes(bytes_: bytes): ...
|
| 6 |
+
def _load_jit_module_from_file(filename: str): ...
|
| 7 |
+
def _load_jit_module_from_bytes(bytes_: bytes): ...
|
| 8 |
+
def _save_mobile_module(m: LiteScriptModule, filename: str): ...
|
| 9 |
+
def _save_jit_module(m: ScriptModule, filename: str): ...
|
| 10 |
+
def _save_mobile_module_to_bytes(m: LiteScriptModule) -> bytes: ...
|
| 11 |
+
def _save_jit_module_to_bytes(m: ScriptModule) -> bytes: ...
|
.venv/lib/python3.12/site-packages/torch/_VF.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
This makes the functions in torch._C._VariableFunctions available as
|
| 3 |
+
torch._VF.<funcname>
|
| 4 |
+
without mypy being able to find them.
|
| 5 |
+
|
| 6 |
+
A subset of those functions are mapped to ATen functions in
|
| 7 |
+
torch/jit/_builtins.py
|
| 8 |
+
|
| 9 |
+
See https://github.com/pytorch/pytorch/issues/21478 for the reason for
|
| 10 |
+
introducing torch._VF
|
| 11 |
+
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
import sys
|
| 15 |
+
import types
|
| 16 |
+
|
| 17 |
+
import torch
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class VFModule(types.ModuleType):
|
| 21 |
+
vf: types.ModuleType
|
| 22 |
+
|
| 23 |
+
def __init__(self, name: str):
|
| 24 |
+
super().__init__(name)
|
| 25 |
+
self.vf = torch._C._VariableFunctions
|
| 26 |
+
|
| 27 |
+
def __getattr__(self, name: str) -> object:
|
| 28 |
+
return getattr(self.vf, name)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
sys.modules[__name__] = VFModule(__name__)
|
.venv/lib/python3.12/site-packages/torch/_VF.pyi
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
.venv/lib/python3.12/site-packages/torch/__config__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def show() -> str:
|
| 5 |
+
"""
|
| 6 |
+
Return a human-readable string with descriptions of the
|
| 7 |
+
configuration of PyTorch.
|
| 8 |
+
"""
|
| 9 |
+
return torch._C._show_config()
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
# TODO: In principle, we could provide more structured version/config
|
| 13 |
+
# information here. For now only CXX_FLAGS is exposed, as Timer
|
| 14 |
+
# uses them.
|
| 15 |
+
def _cxx_flags() -> str:
|
| 16 |
+
"""Returns the CXX_FLAGS used when building PyTorch."""
|
| 17 |
+
return torch._C._cxx_flags()
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def parallel_info() -> str:
|
| 21 |
+
r"""Returns detailed string with parallelization settings"""
|
| 22 |
+
return torch._C._parallel_info()
|
.venv/lib/python3.12/site-packages/torch/__future__.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_overwrite_module_params_on_conversion: bool = False
|
| 2 |
+
_swap_module_params_on_conversion: bool = False
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def set_overwrite_module_params_on_conversion(value: bool) -> None:
|
| 6 |
+
"""
|
| 7 |
+
Sets whether to assign new tensors to the parameters instead of changing the
|
| 8 |
+
existing parameters in-place when converting an ``nn.Module``.
|
| 9 |
+
|
| 10 |
+
When enabled, the following methods will assign new parameters to the module:
|
| 11 |
+
|
| 12 |
+
#. ``module.{device}()`` (e.g. :meth:`nn.Module.cuda()`) for moving a module between devices
|
| 13 |
+
#. ``module.{dtype}()`` (e.g. :meth:`nn.Module.float()`) for converting a module to a different dtype
|
| 14 |
+
#. :meth:`nn.Module.to`
|
| 15 |
+
#. :meth:`nn.Module.to_empty`
|
| 16 |
+
|
| 17 |
+
Args:
|
| 18 |
+
value (bool): Whether to assign new tensors or not.
|
| 19 |
+
|
| 20 |
+
"""
|
| 21 |
+
global _overwrite_module_params_on_conversion
|
| 22 |
+
_overwrite_module_params_on_conversion = value
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def get_overwrite_module_params_on_conversion() -> bool:
|
| 26 |
+
"""
|
| 27 |
+
Returns whether to assign new tensors to the parameters instead of changing the
|
| 28 |
+
existing parameters in-place when converting an :class:`torch.nn.Module`. Defaults to ``False``.
|
| 29 |
+
|
| 30 |
+
See :func:`~torch.__future__.set_overwrite_module_params_on_conversion` for more information.
|
| 31 |
+
"""
|
| 32 |
+
return _overwrite_module_params_on_conversion
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def set_swap_module_params_on_conversion(value: bool) -> None:
|
| 36 |
+
"""
|
| 37 |
+
Sets whether to use :func:`~torch.utils.swap_tensors` instead of setting ``.data`` to
|
| 38 |
+
change the existing parameters in-place when converting an ``nn.Module`` and instead
|
| 39 |
+
of ``param.copy_(state_dict[key])`` when loading a state dict into an ``nn.Module``.
|
| 40 |
+
|
| 41 |
+
.. note::
|
| 42 |
+
This function takes precedence over :func:`~torch.__future__.get_overwrite_module_params_on_conversion`
|
| 43 |
+
|
| 44 |
+
When enabled, the following methods will swap the existing parameters in-place:
|
| 45 |
+
|
| 46 |
+
#. ``module.{device}()`` (e.g. :meth:`nn.Module.cuda()`) for moving a module between devices
|
| 47 |
+
#. ``module.{dtype}()`` (e.g. :meth:`nn.Module.float()`) for converting a module to a different dtype
|
| 48 |
+
#. :meth:`nn.Module.to`
|
| 49 |
+
#. :meth:`nn.Module.to_empty`
|
| 50 |
+
#. :meth:`nn.Module.load_state_dict`
|
| 51 |
+
|
| 52 |
+
The semantics for :meth:`~nn.Module.load_state_dict` when this is set are as follows:
|
| 53 |
+
|
| 54 |
+
#. For each parameter/buffer, its corresponding ``state_dict['key']`` is transformed via
|
| 55 |
+
:meth:`~torch.Tensor.module_load` (i.e. ``res = param.module_load(state_dict['key'])``)
|
| 56 |
+
#. If necessary, ``res`` will be wrapped in an :class:`~nn.Parameter`
|
| 57 |
+
#. The parameter/buffer in the module will be swapped via :func:`~torch.utils.swap_tensors`
|
| 58 |
+
with ``res``
|
| 59 |
+
|
| 60 |
+
Args:
|
| 61 |
+
value (bool): Whether to use :func:`~torch.utils.swap_tensors` or not.
|
| 62 |
+
|
| 63 |
+
"""
|
| 64 |
+
global _swap_module_params_on_conversion
|
| 65 |
+
_swap_module_params_on_conversion = value
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def get_swap_module_params_on_conversion() -> bool:
|
| 69 |
+
"""
|
| 70 |
+
Returns whether to use :func:`~torch.utils.swap_tensors` instead of setting .data to
|
| 71 |
+
change the existing parameters in-place when converting an ``nn.Module``. Defaults to ``False``.
|
| 72 |
+
|
| 73 |
+
See :func:`~torch.__future__.set_swap_module_params_on_conversion` for more information.
|
| 74 |
+
"""
|
| 75 |
+
return _swap_module_params_on_conversion
|