1
1
module Docs
2
2
class Pytorch
3
3
class EntriesFilter < Docs ::EntriesFilter
4
- TYPE_REPLACEMENTS = {
5
- "torch.Tensor" => "Tensor" ,
6
- "torch.nn" => "Neuro Network" ,
7
- "Probability distributions - torch.distributions" => "Probability Distributions" ,
8
- "torch" => "Torch" ,
9
- "Quantization" => "Quantization" ,
10
- "torch.optim" => "Optimization" ,
11
- "torch.Storage" => "Storage" ,
12
- "torch.nn.functional" => "NN Functions" ,
13
- "torch.cuda" => "CUDA" ,
14
- "Torch Distributed Elastic" => "Distributed Elastic" ,
15
- "torch.fx" => "FX" ,
16
- "TorchScript" => "Torch Script" ,
17
- "torch.onnx" => "ONNX" ,
18
- "Distributed communication package - torch.distributed" => "Distributed Communication" ,
19
- "Automatic differentiation package - torch.autograd" => "Automatic Differentiation" ,
20
- "torch.linalg" => "Linear Algebra" ,
21
- "Distributed Checkpoint - torch.distributed.checkpoint" => "Distributed Checkpoint" ,
22
- "Distributed RPC Framework" => "Distributed RPC" ,
23
- "torch.special" => "SciPy-like Special" ,
24
- "torch.package" => "Package" ,
25
- "torch.backends" => "Backends" ,
26
- "FullyShardedDataParallel" => "Fully Sharded Data Parallel" ,
27
- "torch.sparse" => "Sparse Tensors" ,
28
- "torch.export" => "Traced Graph Export" ,
29
- "torch.fft" => "Discrete Fourier Transforms" ,
30
- "torch.utils.data" => "Datasets and Data Loaders" ,
31
- "torch.monitor" => "Monitor" ,
32
- "Automatic Mixed Precision package - torch.amp" => "Automatic Mixed Precision" ,
33
- "torch.utils.tensorboard" => "Tensorboard" ,
34
- "torch.profiler" => "Profiler" ,
35
- "torch.mps" => "MPS" ,
36
- "DDP Communication Hooks" => "DDP Communication Hooks" ,
37
- "Benchmark Utils - torch.utils.benchmark" => "Benchmark Utils" ,
38
- "torch.nn.init" => "Parameter Initializations" ,
39
- "Tensor Parallelism - torch.distributed.tensor.parallel" => "Tensor Parallelism" ,
40
- "torch.func" => "JAX-like Function Transforms" ,
41
- "Distributed Optimizers" => "Distributed Optimizers" ,
42
- "torch.signal" => "SciPy-like Signal" ,
43
- "torch.futures" => "Miscellaneous" ,
44
- "torch.utils.cpp_extension" => "Miscellaneous" ,
45
- "torch.overrides" => "Miscellaneous" ,
46
- "Generic Join Context Manager" => "Miscellaneous" ,
47
- "torch.hub" => "Miscellaneous" ,
48
- "torch.cpu" => "Miscellaneous" ,
49
- "torch.random" => "Miscellaneous" ,
50
- "torch.compiler" => "Miscellaneous" ,
51
- "Pipeline Parallelism" => "Miscellaneous" ,
52
- "Named Tensors" => "Miscellaneous" ,
53
- "Multiprocessing package - torch.multiprocessing" => "Miscellaneous" ,
54
- "torch.utils" => "Miscellaneous" ,
55
- "torch.library" => "Miscellaneous" ,
56
- "Tensor Attributes" => "Miscellaneous" ,
57
- "torch.testing" => "Miscellaneous" ,
58
- "torch.nested" => "Miscellaneous" ,
59
- "Understanding CUDA Memory Usage" => "Miscellaneous" ,
60
- "torch.utils.dlpack" => "Miscellaneous" ,
61
- "torch.utils.checkpoint" => "Miscellaneous" ,
62
- "torch.__config__" => "Miscellaneous" ,
63
- "Type Info" => "Miscellaneous" ,
64
- "torch.utils.model_zoo" => "Miscellaneous" ,
65
- "torch.utils.mobile_optimizer" => "Miscellaneous" ,
66
- "torch._logging" => "Miscellaneous" ,
67
- "torch.masked" => "Miscellaneous" ,
68
- "torch.utils.bottleneck" => "Miscellaneous"
69
- }
70
-
71
4
def get_breadcrumbs
72
5
css ( '.pytorch-breadcrumbs > li' ) . map {
73
6
|node | node . content . delete_suffix ( ' >' ) . strip
74
7
} . reject { |item | item . nil? || item . empty? }
75
8
end
76
9
77
10
def get_name
78
- b = get_breadcrumbs
79
- b [ ( b [ 1 ] == 'torch' ? 2 : 1 ) ..] . join ( '.' )
11
+ get_breadcrumbs [ -1 ]
80
12
end
81
13
82
14
def get_type
83
- t = get_breadcrumbs [ 1 ]
84
- TYPE_REPLACEMENTS . fetch ( t , t )
85
- end
86
-
87
- def include_default_entry?
88
- # Only include API entries to simplify and unify the list
89
- return name . start_with? ( 'torch.' )
15
+ get_breadcrumbs [ 1 ]
90
16
end
91
17
92
18
def additional_entries
@@ -108,8 +34,6 @@ def additional_entries
108
34
entries << [ id + '()' , id ]
109
35
when 'py class' , 'py attribute' , 'py property'
110
36
entries << [ id , id ]
111
- when 'footnote brackets' , 'field-list simple'
112
- next
113
37
end
114
38
end
115
39
0 commit comments