Skip to content

Commit d738933

Browse files
committed
remove fire
1 parent feab45c commit d738933

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

tools/profile_conversion_time.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
"""
33
Profiles the conversion of a Keras model.
44
"""
5-
import cProfile, pstats, io
5+
import sys
6+
import cProfile
7+
import pstats
68
from pstats import SortKey
7-
import fire
9+
import io
10+
import argparse
811
import tensorflow as tf
912
from tf2onnx import tfonnx
1013
from tensorflow.keras.applications import MobileNet, EfficientNetB2
@@ -62,7 +65,7 @@ def profile(profiler="none", name="MobileNet", show_all=False):
6265
6366
:param profiler: one among none, spy, pyinstrument, cProfile
6467
:param name: model to profile, MobileNet, EfficientNetB2
65-
:param show_all: use by pyinstrument to show all functions
68+
:param showall: used by pyinstrument to show all functions
6669
"""
6770
print("create(%r, %r)" % (profiler, name))
6871
graph_def, model = create(name)
@@ -94,6 +97,21 @@ def profile(profiler="none", name="MobileNet", show_all=False):
9497
raise ValueError("Unknown profiler %r." % profiler)
9598

9699

100+
def main(args):
101+
parser = argparse.ArgumentParser(description='Process some integers.')
102+
parser.add_argument('--profiler', default='none',
103+
choices=['none', 'spy', 'pyinstrument', 'cProfile'],
104+
help='a profiler')
105+
parser.add_argument('--name', default="MobileNet",
106+
choices=['MobileNet', 'EfficientNetB2'],
107+
help="a model")
108+
parser.add_argument('--showall', type=bool, default=False,
109+
help="used by pyinstrument to show all functions")
110+
res = parser.parse_args(args)
111+
profile(res.profiler, res.name, res.showall)
112+
113+
97114
if __name__ == '__main__':
98-
fire.Fire(profile)
115+
print('Begin Profile with', sys.argv[1:])
116+
main(sys.argv[1:])
99117
print('Profile complete.')

0 commit comments

Comments
 (0)