forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_cwrap.py
38 lines (33 loc) · 1.3 KB
/
extract_cwrap.py
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
from optparse import OptionParser
parser = OptionParser()
parser.add_option('-o', '--output', help='where to write the result file.',
action='store', default='.')
options, _ = parser.parse_args()
files = [
# '../../csrc/cudnn/cuDNN.cwrap',
'../../csrc/generic/TensorMethods.cwrap',
# '../../csrc/generic/methods/SparseTensor.cwrap',
'../../csrc/generic/methods/Tensor.cwrap',
'../../csrc/generic/methods/TensorApply.cwrap',
'../../csrc/generic/methods/TensorCompare.cwrap',
'../../csrc/generic/methods/TensorCuda.cwrap',
'../../csrc/generic/methods/TensorMath.cwrap',
'../../csrc/generic/methods/TensorRandom.cwrap',
# '../../csrc/generic/methods/TensorSerialization.cwrap',
]
declaration_lines = []
for filename in files:
with open(filename, 'r') as file:
in_declaration = False
for line in file.readlines():
line = line.rstrip()
if line == '[[':
in_declaration = True
declaration_lines.append(line)
elif line == ']]':
in_declaration = False
declaration_lines.append(line)
elif in_declaration:
declaration_lines.append(line)
with open(options.output, 'w') as output:
output.write('\n'.join(declaration_lines) + '\n')