forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__init__.pyi.in
2111 lines (1915 loc) · 75 KB
/
__init__.pyi.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ${generated_comment}
# mypy: disable-error-code="type-arg"
import builtins
from enum import Enum, IntEnum
from pathlib import Path
from typing import (
Any,
AnyStr,
BinaryIO,
Callable,
ContextManager,
Dict,
Generic,
Iterable,
Iterator,
List,
Literal,
NamedTuple,
Optional,
Protocol,
Sequence,
Set,
SupportsIndex,
Tuple,
Type,
TypeVar,
Union,
overload,
runtime_checkable,
)
from typing_extensions import ParamSpec
import torch
from torch import inf, SymInt, Tensor
from torch.autograd.graph import Node as _Node
from torch.package import PackageExporter
from torch.storage import UntypedStorage, TypedStorage
from torch.types import (
_bool,
_complex,
_device,
_dispatchkey,
_dtype,
_float,
_int,
_layout,
_qscheme,
_size,
Device,
Number,
Storage,
)
from torch._prims_common import DeviceLikeType
# This module is defined in torch/csrc/Module.cpp
from . import _functorch, _lazy, _lazy_ts_backend, _nn, _onnx, _VariableFunctions, _cpu
K = TypeVar("K")
T = TypeVar("T")
S = TypeVar("S", bound="torch.Tensor")
P = ParamSpec("P")
ReturnVal = TypeVar("ReturnVal", covariant=True) # return value (always covariant)
_T_co = TypeVar("_T_co", covariant=True)
@runtime_checkable
class _NestedSequence(Protocol[_T_co]):
"""A protocol for representing nested sequences.
References::
`numpy._typing._NestedSequence`
<https://github.com/numpy/numpy/blob/main/numpy/_typing/_nested_sequence.py>
"""
def __len__(self, /) -> builtins.int: ...
def __getitem__(self, index: builtins.int, /) -> _T_co | _NestedSequence[_T_co]: ...
def __contains__(self, x: builtins.object, /) -> builtins.bool: ...
def __iter__(self, /) -> Iterator[_T_co | _NestedSequence[_T_co]]: ...
def __reversed__(self, /) -> Iterator[_T_co | _NestedSequence[_T_co]]: ...
def count(self, value: Any, /) -> builtins.int: ...
def index(self, value: Any, /) -> builtins.int: ...
# Defined in torch/csrc/Device.cpp
class device:
type: str # THPDevice_type
index: _int # THPDevice_index
def __get__(self, instance, owner=None) -> device: ...
# THPDevice_pynew
@overload
def __init__(self, device: DeviceLikeType) -> None: ...
@overload
def __init__(self, type: str, index: _int) -> None: ...
# Uncomment if we ever make torch.device a decorator
# def __call__(self, func: T) -> T: ...
def __enter__(self) -> device: ...
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
def __reduce__(self) -> Tuple[Any, ...]: ... # THPDevice_reduce
# Defined in torch/csrc/Stream.cpp
class Stream:
stream_id: _int # Stream id
device_index: _int
device_type: _int
device: device # The device of the stream
# Defined in torch/csrc/Size.cpp
class Size(Tuple[_int, ...]):
# TODO: __reduce__
@overload # type: ignore[override]
def __getitem__(self: Size, key: _int) -> _int: ...
@overload
def __getitem__(self: Size, key: slice) -> Size: ...
def numel(self: Size) -> _int: ...
# Defined in torch/csrc/Dtype.cpp
class dtype:
# TODO: __reduce__
is_floating_point: _bool
is_complex: _bool
is_signed: _bool
itemsize: _int
def to_real(self) -> dtype: ...
def to_complex(self) -> dtype: ...
# Defined in torch/csrc/TypeInfo.cpp
class iinfo:
bits: _int
min: _int
max: _int
dtype: str
def __init__(self, dtype: _dtype) -> None: ...
class finfo:
bits: _int
min: _float
max: _float
eps: _float
tiny: _float
smallest_normal: _float
resolution: _float
dtype: str
@overload
def __init__(self, dtype: _dtype) -> None: ...
@overload
def __init__(self) -> None: ...
${dtype_class_hints}
# Defined in torch/csrc/Layout.cpp
class layout: ...
# Defined in torch/csrc/utils/disable_torch_function.cpp
def DisableTorchFunction(): ...
def DisableTorchFunctionSubclass(): ...
# Defined in torch/csrc/utils/tensor_layouts.cpp
strided: layout = ...
sparse_coo: layout = ...
sparse_csr: layout = ...
sparse_csc: layout = ...
sparse_bsr: layout = ...
sparse_bsc: layout = ...
_mkldnn: layout = ...
jagged: layout = ...
# Defined in torch/csrc/MemoryFormat.cpp
class memory_format: ...
# Defined in torch/csrc/utils/tensor_memoryformats.cpp
contiguous_format: memory_format = ...
channels_last: memory_format = ...
channels_last_3d: memory_format = ...
preserve_format: memory_format = ...
# Defined in torch/csrc/QScheme.cpp
class qscheme: ...
# Defined in torch/csrc/utils/tensor_qschemes.h
per_tensor_affine: qscheme = ...
per_channel_affine: qscheme = ...
per_tensor_symmetric: qscheme = ...
per_channel_symmetric: qscheme = ...
per_channel_affine_float_qparams: qscheme = ...
# Defined in torch/csrc/autograd/python_function.cpp
class _FunctionBase:
saved_tensors: Tuple[Tensor]
_raw_saved_tensors: Tuple[Any]
next_functions: Tuple[Tuple[Any, _int], ...]
needs_input_grad: Tuple[_bool]
metadata: dict
_materialize_non_diff_grads: _bool
# skip adding type hints for the fields that have wrappers defined
# in torch/autograd/function.py
# Defined in torch/csrc/autograd/python_legacy_variable.cpp
class _LegacyVariableBase(Tensor): # inherits from Tensor to appease mypy
def __init__(
self,
data: Optional[Tensor] = ...,
requires_grad: Optional[_bool] = ...,
volatile: Optional[_bool] = ...,
_grad_fn: Optional[_FunctionBase] = ...,
) -> None: ...
# Defined in torch/csrc/jit/python/init.cpp
class IODescriptor: ...
class JITException: ...
class Future(Generic[T]):
def __init__(self, devices: List[device]) -> None: ...
def done(self) -> _bool: ...
def value(self) -> T: ...
def wait(self) -> T: ...
def add_done_callback(self, callback: Callable) -> None: ...
def then(self, callback: Callable) -> Future[T]: ...
def set_result(self, result: T) -> None: ...
def _set_unwrap_func(self, callback: Callable) -> None: ...
class _Await:
def __init__(self) -> None: ...
def fn(self) -> Callable: ...
def args(self) -> Tuple[Any, ...]: ...
def is_nowait(self) -> _bool: ...
def _jit_set_num_profiled_runs(num: _size) -> _size: ...
# Defined in torch/csrc/jit/passes/mobile_optimizer_type.h
class _MobileOptimizerType: ...
CONV_BN_FUSION: _MobileOptimizerType
INSERT_FOLD_PREPACK_OPS: _MobileOptimizerType
REMOVE_DROPOUT: _MobileOptimizerType
FUSE_ADD_RELU: _MobileOptimizerType
HOIST_CONV_PACKED_PARAMS: _MobileOptimizerType
VULKAN_AUTOMATIC_GPU_TRANSFER: _MobileOptimizerType
def fork(*args: Any, **kwargs: Any) -> Future: ...
def wait(fut: Future) -> Any: ...
def _awaitable(*args: Any, **kwargs: Any) -> _Await: ...
def _awaitable_wait(aw: _Await) -> Any: ...
def _awaitable_nowait(x: Any) -> _Await: ...
def _collect_all(futures: List[Future]) -> Future: ...
def _set_print_stack_traces_on_fatal_signal(print: _bool) -> None: ...
def unify_type_list(types: List[JitType]) -> JitType: ...
def _freeze_module(
module: ScriptModule,
preserved_attrs: List[str] = [],
freeze_interfaces: _bool = True,
preserveParameters: _bool = True,
) -> ScriptModule: ...
def _jit_pass_optimize_frozen_graph(Graph, optimize_numerics: _bool = True) -> None: ...
def _jit_pass_optimize_for_inference(
module: torch.jit.ScriptModule,
other_methods: List[str] = [],
) -> None: ...
def _jit_pass_fold_frozen_conv_bn(graph: Graph): ...
def _jit_pass_fold_frozen_conv_add_or_sub(graph: Graph): ...
def _jit_pass_fold_frozen_conv_mul_or_div(graph: Graph): ...
def _jit_pass_fuse_frozen_conv_add_relu(graph: Graph): ...
def _jit_pass_concat_frozen_linear(graph: Graph): ...
def _jit_pass_convert_frozen_ops_to_mkldnn(graph: Graph): ...
def _jit_pass_transpose_frozen_linear(graph: Graph): ...
def _jit_pass_remove_dropout(module: torch.jit.ScriptModule): ...
def _is_tracing() -> _bool: ...
def _jit_init() -> _bool: ...
def _jit_flatten(arg: Any) -> Tuple[List[Tensor], IODescriptor]: ...
def _jit_unflatten(vars: List[Tensor], desc: IODescriptor) -> Any: ...
def _jit_get_operation(op_name: str) -> Tuple[Callable, List[str]]: ...
def _get_operation_overload(
op_name: str,
op_overload_name: str,
) -> Tuple[Callable, Callable, List[Any]]: ...
def _get_schema(op_name: str, overload_name: str) -> FunctionSchema: ...
def _jit_pass_optimize_for_mobile(
module: torch.jit.ScriptModule,
optimization_blocklist: Set[_MobileOptimizerType],
preserved_methods: List[AnyStr],
) -> torch.jit.ScriptModule: ...
def _clone_module_with_class(
module: torch.jit.ScriptModule,
ignored_methods: List[AnyStr],
ignored_attributes: List[AnyStr],
) -> torch.jit.ScriptModule: ...
def _jit_pass_vulkan_optimize_for_mobile(
module: torch.jit.ScriptModule,
optimization_blocklist: Set[_MobileOptimizerType],
preserved_methods: List[AnyStr],
) -> torch.jit.ScriptModule: ...
def _jit_pass_metal_optimize_for_mobile(
module: torch.jit.ScriptModule,
preserved_methods: List[AnyStr],
) -> torch.jit.ScriptModule: ...
def _jit_pass_inline(Graph) -> None: ...
def _jit_pass_constant_propagation(Graph) -> None: ...
def _jit_pass_propagate_shapes_on_graph(Graph) -> None: ...
def _jit_register_decomposition_for_schema(schema: FunctionSchema, Graph) -> None: ...
def _jit_erase_non_input_shape_information(Graph) -> None: ...
def _jit_get_schemas_for_operator(name: str) -> List[FunctionSchema]: ...
def _jit_get_all_schemas() -> List[FunctionSchema]: ...
def _jit_check_alias_annotation(
g: Graph,
args: Tuple[Any, ...],
unqualified_op_name: str,
): ...
def _jit_can_fuse_on_cpu() -> _bool: ...
def _jit_can_fuse_on_gpu() -> _bool: ...
def _jit_can_fuse_on_cpu_legacy() -> _bool: ...
def _debug_get_fusion_group_inlining() -> _bool: ...
def _debug_set_fusion_group_inlining(enable: _bool): ...
def _jit_texpr_fuser_enabled() -> _bool: ...
def _jit_nvfuser_enabled() -> _bool: ...
def _jit_llga_enabled() -> _bool: ...
def _jit_set_llga_enabled(enable: _bool): ...
def _llvm_enabled() -> _bool: ...
def _jit_override_can_fuse_on_cpu(override: _bool): ...
def _jit_override_can_fuse_on_gpu(override: _bool): ...
def _jit_override_can_fuse_on_cpu_legacy(override: _bool): ...
def _jit_set_symbolic_shapes_test_mode(override: _bool): ...
def _jit_symbolic_shapes_test_mode_enabled() -> _bool: ...
def _jit_set_texpr_fuser_enabled(enable: _bool): ...
def _jit_set_te_must_use_llvm_cpu(use_llvm: _bool): ...
def _jit_set_nvfuser_enabled(enable: _bool) -> _bool: ...
def _jit_cat_wo_conditionals(optimize_cat: _bool): ...
def _jit_opt_conditionals(opt_conds: _bool): ...
def _jit_pass_canonicalize(graph: Graph, keep_unique_names: _bool = True): ...
def _jit_pass_erase_shape_information(graph: Graph): ...
def _jit_pass_fold_convbn(module: torch.jit.ScriptModule): ...
def _jit_pass_insert_observers(
module: torch.jit.ScriptModule,
method_name: str,
qconfig_dict: Dict[str, Any],
inplace: _bool,
quant_type: _int,
): ...
def _jit_pass_insert_quant_dequant(
module: torch.jit.ScriptModule,
method_name: str,
inplace: _bool,
debug: _bool,
quant_type: _int,
): ...
def _jit_pass_insert_quant_dequant_for_ondevice_ptq(
module: torch.jit.ScriptModule,
method_name: str,
inplace: _bool,
debug: _bool,
quant_type: _int,
): ...
def _jit_pass_quant_finalize(
module: torch.jit.ScriptModule,
quant_type: _int,
preserved_attrs: Sequence[str],
): ...
def _jit_pass_quant_finalize_for_ondevice_ptq(
module: torch.jit.ScriptModule,
quant_type: _int,
method_name: str,
): ...
def _jit_pass_insert_observer_method_for_ondevice_ptq(
module: torch.jit.ScriptModule,
method_name: str,
qconfig_dict: Dict[str, Any],
inplace: _bool,
quant_type: _int,
): ...
def _jit_set_profiling_executor(profiling_flag: _bool) -> _bool: ...
def _jit_set_profiling_mode(profiling_flag: _bool) -> _bool: ...
def _jit_set_fusion_strategy(
strategy: List[Tuple[str, _int]],
) -> List[Tuple[str, _int]]: ...
def _jit_try_infer_type(obj: Any) -> InferredType: ...
def _jit_get_trigger_value(trigger_name: str) -> _int: ...
# Defined in torch/csrc/jit/python/script_init.cpp
ResolutionCallback = Callable[[str], Callable[..., Any]]
# Defined in torch/csrc/jit/python/script_init.cpp
# and torch/csrc/jit/python/init.cpp
def _create_function_from_graph(qualname: str, graph: Graph) -> ScriptFunction: ...
def _debug_set_autodiff_subgraph_inlining(disabled: _bool) -> None: ...
def _ivalue_tags_match(lhs: ScriptModule, rhs: ScriptModule) -> _bool: ...
def _jit_assert_is_instance(obj: Any, type: JitType): ...
def _jit_clear_class_registry() -> None: ...
def _jit_set_emit_hooks(
ModuleHook: Optional[Callable],
FunctionHook: Optional[Callable],
) -> None: ...
def _jit_get_emit_hooks() -> Tuple[Callable, Callable]: ...
def _load_for_lite_interpreter(
filename: Union[str, Path],
map_location: Optional[DeviceLikeType],
): ...
def _load_for_lite_interpreter_from_buffer(
buffer: BinaryIO,
map_location: Optional[DeviceLikeType],
): ...
def _export_operator_list(module: LiteScriptModule): ...
def _quantize_ondevice_ptq_dynamic(module: LiteScriptModule, method_name: str): ...
def _get_model_bytecode_version(filename: Union[str, Path]) -> _int: ...
def _get_model_bytecode_version_from_buffer(buffer: BinaryIO) -> _int: ...
def _backport_for_mobile(
filename_input: Union[str, Path],
filename_output: Union[str, Path],
to_version: _int,
) -> None: ...
def _backport_for_mobile_from_buffer(
buffer: BinaryIO,
filename_output: Union[str, Path],
to_version: _int,
) -> None: ...
def _backport_for_mobile_to_buffer(
filename_input: Union[str, Path],
to_version: _int,
) -> bytes: ...
def _backport_for_mobile_from_buffer_to_buffer(
buffer: BinaryIO,
to_version: _int,
) -> bytes: ...
def _get_model_ops_and_info(filename: Union[str, Path]): ...
def _get_model_ops_and_info_from_buffer(buffer: BinaryIO): ...
def _get_mobile_model_contained_types(filename: Union[str, Path]): ...
def _get_mobile_model_contained_types_from_buffer(buffer: BinaryIO): ...
def _logging_set_logger(logger: LoggerBase) -> LoggerBase: ...
def _get_graph_executor_optimize(optimize: Optional[_bool] = None) -> _bool: ...
def _set_graph_executor_optimize(optimize: _bool): ...
def _export_opnames(module: ScriptModule) -> List[str]: ...
def _create_function_from_trace(
qualname: str,
func: Callable[..., Any],
input_tuple: Tuple[Any, ...],
var_lookup_fn: Callable[[Tensor], str],
strict: _bool,
force_outplace: _bool,
argument_names: List[str],
) -> Tuple[Graph, Stack]: ...
def _create_function_from_trace_with_dict(
qualname: str,
func: Callable[..., Any],
input_dict: Dict[str, Any],
var_lookup_fn: Callable[[Tensor], str],
strict: _bool,
force_outplace: _bool,
argument_names: List[str],
) -> Tuple[Graph, Stack]: ...
def _jit_is_script_object(obj: Any) -> _bool: ...
def _last_executed_optimized_graph() -> Graph: ...
def parse_type_comment(comment: str) -> Decl: ...
def _get_upgraders_map_size() -> _int: ...
def _get_upgraders_entry_map() -> Dict[str, str]: ...
def _dump_upgraders_map() -> Dict[str, str]: ...
def _test_only_populate_upgraders(content: Dict[str, str]) -> None: ...
def _test_only_remove_upgraders(content: Dict[str, str]) -> None: ...
def merge_type_from_type_comment(
decl: Decl,
type_annotation_decl: Decl,
is_method: _bool,
) -> Decl: ...
def parse_ir(input: str, parse_tensor_constants: _bool = False) -> Graph: ...
def parse_schema(schema: str) -> FunctionSchema: ...
def get_device(input: Tensor) -> _int: ...
def _resolve_type_from_object(
obj: Any,
range: SourceRange,
rcb: ResolutionCallback,
) -> JitType: ...
def _create_module_with_type(ty: JitType) -> ScriptModule: ...
def _create_object_with_type(ty: ClassType) -> ScriptObject: ...
def _run_emit_module_hook(m: ScriptModule): ...
def _replace_overloaded_method_decl(
overload_decl: Decl,
implementation_def: Def,
new_name: str,
) -> Def: ...
def _jit_pass_lower_all_tuples(graph: Graph) -> None: ...
def _jit_pass_onnx_set_dynamic_input_shape(
graph: Graph,
dynamic_axes: Dict[str, Dict[_int, str]],
input_names: List[str],
) -> None: ...
def _jit_pass_onnx_graph_shape_type_inference(
graph: Graph,
params_dict: Dict[str, IValue],
opset_version: _int,
) -> None: ...
def _jit_pass_onnx_assign_output_shape(
graph: Graph,
tensors: List[Tensor],
desc: IODescriptor,
onnx_shape_inference: _bool,
is_script: _bool,
opset_version: _int,
) -> None: ...
def _jit_pass_onnx_remove_inplace_ops_for_onnx(
graph: Graph,
module: Optional[ScriptModule] = None,
) -> None: ...
def _jit_pass_remove_inplace_ops(graph: Graph) -> None: ...
def _jit_pass_canonicalize_graph_fuser_ops(graph: Graph) -> None: ...
def _jit_pass_peephole(
graph: Graph,
disable_shape_peepholes: _bool = False,
) -> None: ...
def _jit_pass_onnx_autograd_function_process(graph: Graph) -> None: ...
def _jit_pass_fuse_addmm(graph: Graph) -> None: ...
def _jit_pass_onnx_preprocess(graph: Graph) -> None: ...
def _jit_pass_prepare_division_for_onnx(graph: Graph) -> None: ...
def _jit_pass_onnx_remove_print(graph: Graph) -> None: ...
def _jit_pass_onnx_preprocess_caffe2(graph: Graph) -> None: ...
def _jit_pass_onnx_unpack_quantized_weights(
graph: Graph,
paramsDict: Dict[str, IValue],
caffe2: _bool,
) -> Dict[str, IValue]: ...
def _jit_pass_onnx_quantization_insert_permutes(
graph: Graph,
paramsDict: Dict[str, IValue],
) -> Dict[str, IValue]: ...
def _jit_pass_custom_pattern_based_rewrite_graph(
pattern: str,
fused_node_name: str,
graph: Graph,
) -> None: ...
def _jit_onnx_list_model_parameters(
module: ScriptModule,
) -> Tuple[ScriptModule, List[IValue]]: ...
def _jit_pass_erase_number_types(graph: Graph) -> None: ...
def _jit_pass_onnx_lint(graph: Graph) -> None: ...
def _jit_pass_onnx(
graph: Graph,
_jit_pass_onnx: _onnx.OperatorExportTypes,
) -> Graph: ...
def _jit_pass_onnx_scalar_type_analysis(
graph: Graph,
lowprecision_cast: _bool,
opset_version: _int,
) -> None: ...
def _jit_pass_onnx_peephole(
graph: Graph,
opset_version: _int,
fixed_batch_size: _bool,
) -> None: ...
def _jit_pass_dce_allow_deleting_nodes_with_side_effects(graph: Graph) -> None: ...
def _jit_pass_onnx_function_substitution(graph: Graph) -> None: ...
def _jit_pass_onnx_function_extraction(
graph: Graph,
module_names: Set[str],
param_names: List[str],
) -> Dict[Node, Dict[str, str]]: ...
def _jit_pass_onnx_clear_scope_records() -> None: ...
def _jit_pass_onnx_track_scope_attributes(
graph: Graph,
onnx_attrs: Dict[str, Any],
) -> None: ...
def _jit_is_onnx_log_enabled() -> _bool: ...
def _jit_set_onnx_log_enabled(enabled: _bool) -> None: ...
def _jit_set_onnx_log_output_stream(stream_name: str) -> None: ...
def _jit_onnx_log(*args: Any) -> None: ...
def _jit_pass_lower_graph(graph: Graph, m: Module) -> Tuple[Graph, List[IValue]]: ...
def _jit_pass_inline_fork_wait(graph: Graph) -> None: ...
def _jit_pass_onnx_deduplicate_initializers(
graph: Graph,
params_dict: Dict[str, IValue],
is_train: _bool,
) -> Dict[str, IValue]: ...
def _jit_pass_onnx_eval_peephole(
graph: Graph,
paramsDict: Dict[str, IValue],
) -> Dict[str, IValue]: ...
def _jit_pass_onnx_constant_fold(
graph: Graph,
paramsDict: Dict[str, IValue],
opset_version: _int,
) -> Dict[str, IValue]: ...
def _jit_pass_onnx_eliminate_unused_items(
graph: Graph,
paramsDict: Dict[str, IValue],
) -> Dict[str, IValue]: ...
def _jit_pass_onnx_cast_all_constant_to_floating(graph: Graph) -> None: ...
def _jit_pass_filter_non_tensor_arguments(
params: Dict[str, IValue],
) -> Dict[str, Tensor]: ...
def _jit_decay_packed_param_input_types(graph: Graph) -> None: ...
def _jit_pass_onnx_node_shape_type_inference(
n: Node,
paramsDict: Dict[str, IValue],
opset_version: _int,
) -> None: ...
def _jit_onnx_convert_pattern_from_subblock(
block: Block,
n: Node,
env: Dict[Value, Value],
) -> List[Value]: ...
def _jit_pass_onnx_block(
old_block: Block,
new_block: Block,
operator_export_type: _onnx.OperatorExportTypes,
env: Dict[Value, Value],
is_sub_block: _bool,
) -> Dict[Value, Value]: ...
def _jit_pass_onnx_assign_scoped_names_for_node_and_value(graph: Graph) -> None: ...
def _jit_pass_fixup_onnx_controlflow_node(
n: Node,
opset_version: _int,
) -> List[Value]: ...
def _jit_onnx_create_full_scope_name(class_name: str, variable_name: str) -> str: ...
def _compile_graph_to_code_table(name: str, graph: Graph) -> IValue: ...
def _generate_upgraders_graph() -> Dict[str, Graph]: ...
def _calculate_package_version_based_on_upgraders(val: _bool): ...
def _get_version_calculator_flag() -> _bool: ...
def _jit_script_interface_compile(
name: str,
class_def: ClassDef,
rcb: ResolutionCallback,
is_module: _bool,
): ...
def _jit_script_compile_overload(
qualname: str,
overload_decl: Decl,
implementation_def: Def,
rcb: ResolutionCallback,
implementation_defaults: Dict[str, Any],
signature: Any,
): ...
def _jit_script_compile(
qual_name: str,
definition: Def,
rcb: ResolutionCallback,
defaults: Dict[str, Any],
): ...
def _jit_script_class_compile(
qual_name: str,
definition: ClassDef,
defaults: Dict[str, Dict[str, Any]],
rcb: ResolutionCallback,
): ...
def _parse_source_def(src: str) -> Def: ...
def import_ir_module(
cu: CompilationUnit,
filename: Union[str, Path],
map_location: Optional[DeviceLikeType],
extra_files: Dict[str, Any],
) -> ScriptModule: ...
def import_ir_module_from_buffer(
cu: CompilationUnit,
buffer: BinaryIO,
map_location: Optional[DeviceLikeType],
extra_files: Dict[str, Any],
) -> ScriptModule: ...
def _import_ir_module_from_package(
cu: CompilationUnit,
reader: PyTorchFileReader,
storage_context: DeserializationStorageContext,
map_location: Optional[DeviceLikeType],
ts_id: str,
) -> ScriptModule: ...
def _assign_output_shapes(graph: Graph, inputs: List[Tensor]) -> Graph: ...
def _check_onnx_proto(proto: str) -> None: ...
def _propagate_and_assign_input_shapes(
graph: Graph,
inputs: Tuple[Tensor, ...],
param_count_list: List[_int],
with_grad: _bool,
propagate: _bool,
) -> Graph: ...
# Defined in torch/csrc/jit/runtime/graph_executor.h
class GraphExecutorState: ...
# Defined in torch/torch/csrc/jit/ir/alias_analysis.h
class AliasDb:
def __str__(self) -> str: ...
class _InsertPoint:
def __enter__(self) -> None: ...
def __exit__(self, *args) -> None: ...
# Defined in torch/csrc/jit/ir/ir.h
class Use:
@property
def user(self) -> Node: ...
@property
def offset(self) -> _int: ...
def isAfter(self, other: Use) -> _bool: ...
# Defined in torch/csrc/jit/ir/ir.h
class Value:
def type(self) -> JitType: ...
def setType(self, t: JitType) -> Value: ...
def setTypeAs(self, other: Value) -> Value: ...
def inferTypeFrom(self, t: Tensor) -> None: ...
def debugName(self) -> str: ...
def setDebugName(self, name: str) -> None: ...
def unique(self) -> _int: ...
def offset(self) -> _int: ...
def node(self) -> Node: ...
def uses(self) -> List[Use]: ...
def replaceAllUsesWith(self, val: Value) -> None: ...
def replaceAllUsesAfterNodeWith(self, node: Node, val: Value) -> None: ...
def requires_grad(self) -> _bool: ...
def requiresGrad(self) -> _bool: ...
def copyMetadata(self, other: Value) -> Value: ...
def isCompleteTensor(self) -> _bool: ...
def toIValue(self) -> IValue: ...
# Defined in torch/csrc/jit/ir/ir.h
class Block:
def inputs(self) -> Iterator[Value]: ...
def outputs(self) -> Iterator[Value]: ...
def nodes(self) -> Iterator[Node]: ...
def paramNode(self) -> Node: ...
def returnNode(self) -> Node: ...
def owningNode(self) -> Node: ...
def registerOutput(self, n: Value) -> _int: ...
def addNode(self, name: str, inputs: Sequence[Value]) -> Node: ...
# Defined in torch/csrc/jit/ir/ir.h
class Node:
def __getitem__(self, key: str) -> Any: ...
def schema(self) -> str: ...
def input(self) -> Value: ...
def inputs(self) -> Iterator[Value]: ...
def inputsAt(self, idx: _int) -> Value: ...
def inputsSize(self) -> _int: ...
def output(self) -> Value: ...
def outputs(self) -> Iterator[Value]: ...
def outputsAt(self, idx: _int) -> Value: ...
def outputsSize(self) -> _int: ...
def hasMultipleOutputs(self) -> _bool: ...
def blocks(self) -> List[Block]: ...
def addBlock(self) -> Block: ...
def mustBeNone(self) -> _bool: ...
def matches(self, pattern: str) -> _bool: ...
def kind(self) -> str: ...
def kindOf(self, name: str) -> str: ...
def addInput(self, name: str) -> Value: ...
def replaceInput(self, i: _int, newValue: Value) -> Value: ...
def replaceInputWith(self, from_: Value, to: Value) -> None: ...
def replaceAllUsesWith(self, n: Node) -> None: ...
def insertBefore(self, n: Node) -> Node: ...
def insertAfter(self, n: Node) -> Node: ...
def isBefore(self, n: Node) -> _bool: ...
def isAfter(self, n: Node) -> _bool: ...
def moveBefore(self, n: Node) -> None: ...
def moveAfter(self, n: Node) -> None: ...
def removeInput(self, i: _int) -> None: ...
def removeAllInputs(self, i: _int) -> None: ...
def hasUses(self) -> _bool: ...
def eraseOutput(self, i: _int) -> None: ...
def addOutput(self) -> Value: ...
def scopeName(self) -> str: ...
def isNondeterministic(self) -> _bool: ...
def copyAttributes(self, rhs: Node) -> Node: ...
def copyMetadata(self, rhs: Node) -> Node: ...
def hasAttributes(self) -> _bool: ...
def hasAttribute(self, name: str) -> _bool: ...
def removeAttribute(self, attr: str) -> Node: ...
def namedInput(self, name: str) -> Value: ...
def sourceRange(self) -> SourceRange: ...
def owningBlock(self) -> Block: ...
def findNode(self, kind: str, recurse: _bool = True) -> Node: ...
def findAllNodes(self, kind: str, recurse: _bool = True) -> List[Node]: ...
def getModuleHierarchy(self) -> str: ...
def prev(self) -> Node: ...
def destroy(self) -> None: ...
def attributeNames(self) -> List[str]: ...
# Accessors for attributes as types.
def f(self, name: str) -> _float: ...
def f_(self, name: str, val: _float) -> Node: ...
def fs(self, name: str) -> List[_float]: ...
def fs_(self, name: str, val: List[_float]) -> Node: ...
def c(self, name: str) -> complex: ...
def c_(self, name: str, val: complex) -> Node: ...
def s(self, name: str) -> str: ...
def s_(self, name: str, val: str) -> Node: ...
def ss(self, name: str) -> List[str]: ...
def ss_(self, name: str, val: List[str]) -> Node: ...
def i(self, name: str) -> _int: ...
def i_(self, name: str, val: _int) -> Node: ...
# Cannot define "is" like this because it's a reserved keyword in python.
# def is(self, name: str) -> List[_int]: ...
# def is_(self, name: str, val: List[_int]) -> Node: ...
def g(self, name: str) -> Graph: ...
def g_(self, name: str, val: Graph) -> Node: ...
def gs(self, name: str) -> List[Graph]: ...
def gs_(self, name: str, val: List[Graph]) -> Node: ...
def ival(self, name: str) -> IValue: ...
def ival_(self, name: str, val: IValue) -> Node: ...
def t(self, name: str) -> Tensor: ...
def t_(self, name: str, val: Tensor) -> Node: ...
def ts(self, name: str) -> List[Tensor]: ...
def ts_(self, name: str, val: List[Tensor]) -> Node: ...
def ty(self, name: str) -> JitType: ...
def ty_(self, name: str, val: JitType) -> Node: ...
def tys(self, name: str) -> List[JitType]: ...
def tys_(self, name: str, val: List[JitType]) -> Node: ...
# Defined in torch/torch/csrc/jit/ir/ir.h
class Graph:
def inputs(self) -> Iterator[Value]: ...
def outputs(self) -> Iterator[Value]: ...
def nodes(self) -> Iterator[Node]: ...
def param_node(self) -> Node: ...
def return_node(self) -> Node: ...
def addInput(self, name: str = "") -> Value: ...
def eraseInput(self, i: _int) -> None: ...
def registerOutput(self, n: Value) -> _int: ...
def eraseOutput(self, i: _int) -> None: ...
def create(self, name: str, args, num_outputs: _int) -> Node: ...
def appendNode(self, n: Node) -> Node: ...
def prependNode(self, n: Node) -> Node: ...
def insertNode(self, n: Node) -> Node: ...
def block(self) -> Block: ...
def lint(self) -> None: ...
def alias_db(self) -> AliasDb: ...
def setInsertPoint(self, n: Union[Block, Node]) -> None: ...
def insert_point_guard(self, n: Union[Block, Node]) -> _InsertPoint: ...
def insertPoint(self) -> Node: ...
def insertGraph(self, callee: Graph, inputs: List[Value]) -> List[Value]: ...
def makeMultiOutputIntoTuple(self) -> None: ...
def copy(self) -> Graph: ...
# Defined in torch/aten/src/ATen/core/alias_info.h
class AliasInfo:
is_write: _bool
before_set: Set[str]
after_set: Set[str]
# Defined in torch/aten/src/ATen/core/function_schema.h
class Argument:
name: str
type: JitType
default_value: Optional[Any]
def has_default_value(self) -> _bool: ...
kwarg_only: _bool
is_out: _bool
alias_info: Optional[AliasInfo]
class FunctionSchema:
arguments: List[Argument]
returns: List[Argument]
name: str
overload_name: str
class _UpgraderEntry:
bumped_at_version: _int
upgrader_name: str
old_schema: str
def __init__(
self,
bumped_at_version: _int,
upgrader_name: str,
old_schema: str,
) -> None: ...
class _UpgraderRange:
min_version: _int
max_version: _int
def _get_max_operator_version() -> _int: ...
def _get_operator_version_map() -> Dict[str, List[_UpgraderEntry]]: ...
def _get_upgrader_ranges(name: str) -> List[_UpgraderRange]: ...
def _test_only_add_entry_to_op_version(op_name: str, entry: _UpgraderEntry) -> None: ...
def _test_only_remove_entry_to_op_version(op_name: str) -> None: ...
# Defined in torch/csrc/jit/python/script_init.cpp
class ScriptModuleSerializer:
def __init__(self, export_writer: PyTorchFileWriter) -> None: ...
def serialize(self, model: ScriptModule, script_module_id: _int) -> None: ...
def write_files(self) -> None: ...
def storage_context(self) -> SerializationStorageContext: ...
# Defined in torch/csrc/jit/python/script_init.cpp
class SerializationStorageContext:
def __init__(self) -> None: ...
def has_storage(self, storage: Storage) -> _bool: ...
def get_or_add_storage(self, storage: Storage) -> _int: ...
# Defined in torch/csrc/jit/python/script_init.cpp
class DeserializationStorageContext:
def __init__(self) -> None: ...
def get_storage(self, name: str, dtype: _dtype) -> Tensor: ...
def has_storage(self, name: str) -> _bool: ...
def add_storage(self, name: str, tensor: Tensor) -> _int: ...
# Defined in torch/csrc/jit/python/script_init.cpp
class ConcreteModuleTypeBuilder:
def __init__(self, obj: Any) -> None: ...
def set_module_dict(self): ...
def set_module_list(self): ...
def set_parameter_list(self): ...
def set_parameter_dict(self): ...
def add_attribute(
self,
name: str,
ty: JitType,
is_param: _bool,
is_buffer: _bool,
): ...
def add_module(self, name: str, meta: ConcreteModuleType): ...
def add_constant(self, name: str, value: Any): ...
def add_overload(self, method_name: str, overloaded_method_names: List[str]): ...
def add_builtin_function(self, name: str, symbol_name: str): ...
def add_failed_attribute(self, name: str, failure_reason: str): ...
def add_function_attribute(
self,
name: str,
ty: JitType,
func: Callable[..., Any],
): ...
def add_ignored_attribute(self, name: str): ...
def add_ignored_attributes(self, names: List[str]): ...
def add_forward_hook(self, hook: Callable[..., Any]): ...
def add_forward_pre_hook(self, pre_hook: Callable[..., Any]): ...
class ConcreteModuleType:
def get_constants(self) -> Dict[str, Any]: ...
def equals(self, other: ConcreteModuleType) -> _bool: ...
@staticmethod
def from_jit_type(ty: JitType) -> ConcreteModuleType: ...
class CallStack:
def __init__(self, name: str, range: SourceRange): ...
class ErrorReport:
def __init__(self, range: SourceRange) -> None: ...
def what(self) -> str: ...
@staticmethod
def call_stack() -> str: ...
class CompilationUnit:
def __init__(self, lang: str = ..., _frames_up: _int = ...) -> None: ...
def find_function(self, name: str) -> ScriptFunction: ...
def __getattr__(self, name: str) -> ScriptFunction: ...
def define(
self,
script: str,
rcb: ResolutionCallback = ...,
_frames_up: _int = ...,
): ...
def get_interface(self, name: str) -> InterfaceType: ...
def get_functions(self) -> List[ScriptFunction]: ...
def create_function(
self,
name: str,
graph: Graph,
shouldMangle: _bool = ...,
) -> ScriptFunction: ...
def get_class(self, name: str) -> ClassType: ...
class ScriptObject:
def setattr(self, name: str, value: Any): ...
class ScriptModule(ScriptObject):
def _method_names(self) -> List[str]: ...
def _get_method(self, name: str) -> ScriptMethod: ...
class LiteScriptModule:
def __call__(self, *input): ...
def find_method(self, method_name: str): ...
def forward(self, *input) -> List[str]: ...
def run_method(self, method_name: str, *input): ...
# NOTE: switch to collections.abc.Callable in python 3.9
class ScriptFunction(Generic[P, ReturnVal]):
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> ReturnVal: ...
def save(self, filename: str, _extra_files: Dict[str, bytes]) -> None: ...
def save_to_buffer(self, _extra_files: Dict[str, bytes]) -> bytes: ...
@property
def graph(self) -> Graph: ...
def inlined_graph(self) -> Graph: ...
def schema(self) -> FunctionSchema: ...
def code(self) -> str: ...
def name(self) -> str: ...
@property
def qualified_name(self) -> str: ...
# NOTE: switch to collections.abc.Callable in python 3.9
class ScriptMethod(Generic[P, ReturnVal]):
graph: Graph
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> ReturnVal: ...
@property
def owner(self) -> ScriptModule: ...
@property
def name(self) -> str: ...
class ScriptDict(Generic[K, T]):