Skip to content

Commit

Permalink
Adding flag for number of batches to use for TF-TRT engine building
Browse files Browse the repository at this point in the history
  • Loading branch information
DEKHTIARJonathan committed Mar 10, 2022
1 parent 920597b commit dd03467
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions tftrt/examples/benchmark_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ def __init__(self):
help="Minimum number of TensorFlow ops in a TRT engine."
)

self._parser.add_argument(
"--num_build_batches",
type=int,
default=1,
help="How many iterations(batches) to use to build the TF-TRT "
"engines. If not supplied, only one batch will be used. This "
"parameter has only an effect if `--optimize_offline=True`"
)

self._parser.add_argument(
"--num_calib_batches",
type=int,
Expand Down
3 changes: 2 additions & 1 deletion tftrt/examples/benchmark_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ def engine_build_input_fn(num_batches, model_phase):
if self._args.optimize_offline:

offline_opt_input_fn = lambda: engine_build_input_fn(
num_batches=1, model_phase="Building"
num_batches=self._args.num_build_batches,
model_phase="Building"
)

with timed_section("Building TensorRT engines"):
Expand Down

0 comments on commit dd03467

Please sign in to comment.