forked from NVIDIA-AI-IOT/torch2trt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump_converters.py
54 lines (40 loc) · 1.79 KB
/
dump_converters.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import argparse
import sys
import subprocess
import os
from importlib.machinery import SourceFileLoader
torch2trt = SourceFileLoader("torch2trt", "torch2trt/__init__.py").load_module() # to load relative to root
HEADER = """
# Converters
This table contains a list of supported PyTorch methods and their associated converters.
If your model is not converting, a good start in debugging would be to see if it contains a method not listed
in this table. You may also find these a useful reference when writing your own converters.
| Method | Converter |
|--------|-----------|"""
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--github',
type=str,
default='https://github.com/NVIDIA-AI-IOT/torch2trt')
parser.add_argument('--tag', type=str, default='master')
args = parser.parse_args()
print(HEADER)
for method, entry in torch2trt.CONVERTERS.items():
if not entry['is_real']:
continue
converter = entry['converter']
# get commit hash
# p = subprocess.Popen(['git', 'rev-parse', 'HEAD'],
# stdout=subprocess.PIPE,
# stderr=subprocess.PIPE)
# commit, err = p.communicate()
# commit = commit.decode('utf-8').strip('\n')
# get github URL
url = '{github}/blob/{commit}/{relpath}#L{lineno}'.format(
github=args.github,
commit=args.tag,
relpath=os.path.relpath(converter.__code__.co_filename,
os.path.abspath('.')),
lineno=converter.__code__.co_firstlineno)
print('| ``{method}`` | [``{converter}``]({url}) |'.format(
method=method, converter=converter.__name__, url=url))