1
- from nvidia .dali import backend as b
2
- import nvidia .dali .ops as ops
1
+ # Copyright (c) 2020-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
3
15
import nvidia .dali .plugin .pytorch
4
16
import nvidia .dali .plugin .numba
5
17
import inspect
6
18
import sys
7
- from pathlib import Path
8
19
9
20
import operations_table
10
21
11
22
# Dictionary with modules that can have registered Ops
12
23
ops_modules = {
13
- ' nvidia.dali.ops' : nvidia .dali .ops ,
14
- ' nvidia.dali.plugin.numba.experimental' : nvidia .dali .plugin .numba .experimental ,
24
+ " nvidia.dali.ops" : nvidia .dali .ops ,
25
+ " nvidia.dali.plugin.numba.experimental" : nvidia .dali .plugin .numba .experimental ,
15
26
}
16
27
17
28
18
- exclude_ops_members = {
19
- 'nvidia.dali.ops' : ["PythonFunctionBase" ]
20
- }
29
+ exclude_ops_members = {"nvidia.dali.ops" : ["PythonFunctionBase" ]}
21
30
22
31
23
32
fn_modules = {
24
- ' nvidia.dali.fn' : nvidia .dali .fn ,
25
- ' nvidia.dali.plugin.pytorch.fn' : nvidia .dali .plugin .pytorch .fn ,
26
- ' nvidia.dali.plugin.numba.fn.experimental' : nvidia .dali .plugin .numba .fn .experimental ,
33
+ " nvidia.dali.fn" : nvidia .dali .fn ,
34
+ " nvidia.dali.plugin.pytorch.fn" : nvidia .dali .plugin .pytorch .fn ,
35
+ " nvidia.dali.plugin.numba.fn.experimental" : nvidia .dali .plugin .numba .fn .experimental ,
27
36
}
28
37
29
38
30
- exclude_fn_members = {
31
- }
39
+ exclude_fn_members = {}
32
40
33
41
34
42
mod_aditional_doc = {
35
- 'nvidia.dali.fn.transforms' : "All operators in this module support only CPU device as they are meant " +
36
- "to be provided as an input to named keyword operator arguments. Check for more details the relevant " +
37
- ":ref:`pipeline documentation section<Processing Graph Structure>`."
43
+ "nvidia.dali.fn.transforms" : (
44
+ "All operators in this module support only CPU device as they are meant to be provided"
45
+ " as an input to named keyword operator arguments. Check for more details the relevant"
46
+ " :ref:`pipeline documentation section<Processing Graph Structure>`."
47
+ )
38
48
}
39
49
40
50
@@ -47,8 +57,11 @@ def get_modules(top_modules):
47
57
modules = []
48
58
for module in sys .modules .keys ():
49
59
for doc_module in top_modules :
50
- if (module .startswith (doc_module ) and not module .endswith ('hidden' )
51
- and not _is_private (module )):
60
+ if (
61
+ module .startswith (doc_module )
62
+ and not module .endswith ("hidden" )
63
+ and not _is_private (module )
64
+ ):
52
65
modules += [module ]
53
66
return sorted (modules )
54
67
@@ -66,6 +79,7 @@ def get_functions(module):
66
79
result .append (member_name )
67
80
return result
68
81
82
+
69
83
def get_schema_names (module , functions ):
70
84
return [getattr (sys .modules [module ], fun )._schema_name for fun in functions ]
71
85
@@ -85,7 +99,7 @@ def op_autodoc(out_filename):
85
99
excluded = exclude_ops_members [module ]
86
100
s += " :exclude-members: {}\n " .format (", " .join (excluded ))
87
101
s += "\n \n "
88
- with open (out_filename , 'w' ) as f :
102
+ with open (out_filename , "w" ) as f :
89
103
f .write (s )
90
104
91
105
@@ -99,18 +113,18 @@ def get_references(name, references):
99
113
result += f" * `{ desc } <../{ url } >`_\n "
100
114
return result
101
115
116
+
102
117
def single_fun_file (full_name , references ):
103
- """Generate stub page for documentation of given function from fn api.
104
- """
118
+ """Generate stub page for documentation of given function from fn api."""
105
119
result = f"{ full_name } \n "
106
120
result += "-" * len (full_name ) + "\n \n "
107
121
result += f".. autofunction:: { full_name } \n \n "
108
122
result += get_references (full_name , references )
109
123
return result
110
124
125
+
111
126
def single_module_file (module , funs_in_module , references ):
112
- """Generate stub page for documentation of given module
113
- """
127
+ """Generate stub page for documentation of given module"""
114
128
result = f"{ module } \n "
115
129
result += "~" * len (module ) + "\n \n "
116
130
@@ -123,7 +137,6 @@ def single_module_file(module, funs_in_module, references):
123
137
result += operations_table .operations_table_str (get_schema_names (module , funs_in_module ))
124
138
result += "\n \n "
125
139
126
-
127
140
result += ".. toctree::\n :hidden:\n \n "
128
141
129
142
for fun in funs_in_module :
@@ -133,6 +146,7 @@ def single_module_file(module, funs_in_module, references):
133
146
result += f" { full_name } \n "
134
147
return result
135
148
149
+
136
150
def fn_autodoc (out_filename , generated_path , references ):
137
151
all_modules_str = ".. toctree::\n :hidden:\n \n "
138
152
all_modules = get_modules (fn_modules )
@@ -149,7 +163,7 @@ def fn_autodoc(out_filename, generated_path, references):
149
163
all_modules_str += f" { generated_path / module } \n "
150
164
151
165
single_module_str = single_module_file (module , funs_in_module , references )
152
- with open (generated_path / (module + ".rst" ), 'w' ) as module_file :
166
+ with open (generated_path / (module + ".rst" ), "w" ) as module_file :
153
167
module_file .write (single_module_str )
154
168
155
169
for fun in funs_in_module :
@@ -160,5 +174,5 @@ def fn_autodoc(out_filename, generated_path, references):
160
174
single_file_str = single_fun_file (full_name , references )
161
175
function_file .write (single_file_str )
162
176
163
- with open (out_filename , 'w' ) as f :
177
+ with open (out_filename , "w" ) as f :
164
178
f .write (all_modules_str )
0 commit comments