Unverified Commit d2666136 authored by Felipe Curti's avatar Felipe Curti Committed by GitHub
Browse files

[Benchmarks] Change all args to from `no_...` to their positive form (#7075)



* Changed name to all no_... arguments and all references to them, inverting the boolean condition

* Change benchmark tests to use new Benchmark Args

* Update src/transformers/benchmark/benchmark_args_utils.py
Co-authored-by: default avatarPatrick von Platen <patrick.v.platen@gmail.com>

* Update src/transformers/benchmark/benchmark.py
Co-authored-by: default avatarPatrick von Platen <patrick.v.platen@gmail.com>

* Fix Style. Add --no options in help

* fix some part of tests

* Update src/transformers/benchmark/benchmark_args_utils.py

* Update src/transformers/benchmark/benchmark_args_utils.py

* Update src/transformers/benchmark/benchmark_args_utils.py

* fix all tests

* make style

* add backwards compability

* make backwards compatible
Co-authored-by: default avatarPatrick von Platen <patrick.v.platen@gmail.com>
Co-authored-by: default avatarfmcurti <fcurti@DESKTOP-RRQURBM.localdomain>
parent 8c697d58
...@@ -20,7 +20,25 @@ from transformers import HfArgumentParser, PyTorchBenchmark, PyTorchBenchmarkArg ...@@ -20,7 +20,25 @@ from transformers import HfArgumentParser, PyTorchBenchmark, PyTorchBenchmarkArg
def main(): def main():
parser = HfArgumentParser(PyTorchBenchmarkArguments) parser = HfArgumentParser(PyTorchBenchmarkArguments)
try:
benchmark_args = parser.parse_args_into_dataclasses()[0] benchmark_args = parser.parse_args_into_dataclasses()[0]
except ValueError as e:
arg_error_msg = "Arg --no_{0} is no longer used, please use --no-{0} instead."
begin_error_msg = " ".join(str(e).split(" ")[:-1])
full_error_msg = ""
depreciated_args = eval(str(e).split(" ")[-1])
wrong_args = []
for arg in depreciated_args:
# arg[2:] removes '--'
if arg[2:] in PyTorchBenchmarkArguments.deprecated_args:
# arg[5:] removes '--no_'
full_error_msg += arg_error_msg.format(arg[5:])
else:
wrong_args.append(arg)
if len(wrong_args) > 0:
full_error_msg = full_error_msg + begin_error_msg + str(wrong_args)
raise ValueError(full_error_msg)
benchmark = PyTorchBenchmark(args=benchmark_args) benchmark = PyTorchBenchmark(args=benchmark_args)
benchmark.run() benchmark.run()
......
...@@ -22,6 +22,24 @@ def main(): ...@@ -22,6 +22,24 @@ def main():
parser = HfArgumentParser(TensorFlowBenchmarkArguments) parser = HfArgumentParser(TensorFlowBenchmarkArguments)
benchmark_args = parser.parse_args_into_dataclasses()[0] benchmark_args = parser.parse_args_into_dataclasses()[0]
benchmark = TensorFlowBenchmark(args=benchmark_args) benchmark = TensorFlowBenchmark(args=benchmark_args)
try:
benchmark_args = parser.parse_args_into_dataclasses()[0]
except ValueError as e:
arg_error_msg = "Arg --no_{0} is no longer used, please use --no-{0} instead."
begin_error_msg = " ".join(str(e).split(" ")[:-1])
full_error_msg = ""
depreciated_args = eval(str(e).split(" ")[-1])
wrong_args = []
for arg in depreciated_args:
# arg[2:] removes '--'
if arg[2:] in TensorFlowBenchmark.deprecated_args:
# arg[5:] removes '--no_'
full_error_msg += arg_error_msg.format(arg[5:])
else:
wrong_args.append(arg)
if len(wrong_args) > 0:
full_error_msg = full_error_msg + begin_error_msg + str(wrong_args)
raise ValueError(full_error_msg)
benchmark.run() benchmark.run()
......
...@@ -229,7 +229,7 @@ class PyTorchBenchmark(Benchmark): ...@@ -229,7 +229,7 @@ class PyTorchBenchmark(Benchmark):
if self.args.is_tpu: if self.args.is_tpu:
# tpu # tpu
raise NotImplementedError( raise NotImplementedError(
"Memory Benchmarking is currently not implemented for TPU. Please disable memory benchmarking with `--no_memory` or `args.no_memory=True`" "Memory Benchmarking is currently not implemented for TPU. Please disable memory benchmarking with `--no-memory` or `args.memory=False`"
) )
elif self.args.is_gpu: elif self.args.is_gpu:
if not is_py3nvml_available(): if not is_py3nvml_available():
......
...@@ -34,6 +34,34 @@ logger = logging.get_logger(__name__) ...@@ -34,6 +34,34 @@ logger = logging.get_logger(__name__)
@dataclass @dataclass
class PyTorchBenchmarkArguments(BenchmarkArguments): class PyTorchBenchmarkArguments(BenchmarkArguments):
deprecated_args = [
"no_inference",
"no_cuda",
"no_tpu",
"no_speed",
"no_memory",
"no_env_print",
"no_multi_process",
]
def __init__(self, **kwargs):
"""This __init__ is there for legacy code. When removing
deprecated args completely, the class can simply be deleted
"""
for deprecated_arg in self.deprecated_args:
if deprecated_arg in kwargs:
positive_arg = deprecated_arg[3:]
setattr(self, positive_arg, not kwargs.pop(deprecated_arg))
logger.warning(
f"{deprecated_arg} is depreciated. Please use --no-{positive_arg} or {positive_arg}={kwargs[positive_arg]}"
)
self.torchscript = kwargs.pop("torchscript", self.torchscript)
self.torch_xla_tpu_print_metrics = kwargs.pop("torch_xla_tpu_print_metrics", self.torch_xla_tpu_print_metrics)
self.fp16_opt_level = kwargs.pop("fp16_opt_level", self.fp16_opt_level)
super().__init__(**kwargs)
torchscript: bool = field(default=False, metadata={"help": "Trace the models using torchscript"}) torchscript: bool = field(default=False, metadata={"help": "Trace the models using torchscript"})
torch_xla_tpu_print_metrics: bool = field(default=False, metadata={"help": "Print Xla/PyTorch tpu metrics"}) torch_xla_tpu_print_metrics: bool = field(default=False, metadata={"help": "Print Xla/PyTorch tpu metrics"})
fp16_opt_level: str = field( fp16_opt_level: str = field(
...@@ -50,7 +78,7 @@ class PyTorchBenchmarkArguments(BenchmarkArguments): ...@@ -50,7 +78,7 @@ class PyTorchBenchmarkArguments(BenchmarkArguments):
@torch_required @torch_required
def _setup_devices(self) -> Tuple["torch.device", int]: def _setup_devices(self) -> Tuple["torch.device", int]:
logger.info("PyTorch: setting up devices") logger.info("PyTorch: setting up devices")
if self.no_cuda: if not self.cuda:
device = torch.device("cpu") device = torch.device("cpu")
n_gpu = 0 n_gpu = 0
elif is_torch_tpu_available(): elif is_torch_tpu_available():
...@@ -63,7 +91,7 @@ class PyTorchBenchmarkArguments(BenchmarkArguments): ...@@ -63,7 +91,7 @@ class PyTorchBenchmarkArguments(BenchmarkArguments):
@property @property
def is_tpu(self): def is_tpu(self):
return is_torch_tpu_available() and not self.no_tpu return is_torch_tpu_available() and self.tpu
@property @property
@torch_required @torch_required
......
...@@ -31,6 +31,34 @@ logger = logging.get_logger(__name__) ...@@ -31,6 +31,34 @@ logger = logging.get_logger(__name__)
@dataclass @dataclass
class TensorFlowBenchmarkArguments(BenchmarkArguments): class TensorFlowBenchmarkArguments(BenchmarkArguments):
deprecated_args = [
"no_inference",
"no_cuda",
"no_tpu",
"no_speed",
"no_memory",
"no_env_print",
"no_multi_process",
]
def __init__(self, **kwargs):
"""This __init__ is there for legacy code. When removing
deprecated args completely, the class can simply be deleted
"""
for deprecated_arg in self.deprecated_args:
if deprecated_arg in kwargs:
positive_arg = deprecated_arg[3:]
kwargs[positive_arg] = not kwargs.pop(deprecated_arg)
logger.warning(
f"{deprecated_arg} is depreciated. Please use --no-{positive_arg} or {positive_arg}={kwargs[positive_arg]}"
)
self.tpu_name = kwargs.pop("tpu_name", self.tpu_name)
self.device_idx = kwargs.pop("device_idx", self.device_idx)
self.eager_mode = kwargs.pop("eager_mode", self.eager_mode)
self.use_xla = kwargs.pop("use_xla", self.use_xla)
super().__init__(**kwargs)
tpu_name: str = field( tpu_name: str = field(
default=None, default=None,
metadata={"help": "Name of TPU"}, metadata={"help": "Name of TPU"},
...@@ -50,7 +78,7 @@ class TensorFlowBenchmarkArguments(BenchmarkArguments): ...@@ -50,7 +78,7 @@ class TensorFlowBenchmarkArguments(BenchmarkArguments):
@cached_property @cached_property
@tf_required @tf_required
def _setup_tpu(self) -> Tuple["tf.distribute.cluster_resolver.TPUClusterResolver"]: def _setup_tpu(self) -> Tuple["tf.distribute.cluster_resolver.TPUClusterResolver"]:
if not self.no_tpu: if self.tpu:
try: try:
if self.tpu_name: if self.tpu_name:
tpu = tf.distribute.cluster_resolver.TPUClusterResolver(self.tpu_name) tpu = tf.distribute.cluster_resolver.TPUClusterResolver(self.tpu_name)
...@@ -98,7 +126,7 @@ class TensorFlowBenchmarkArguments(BenchmarkArguments): ...@@ -98,7 +126,7 @@ class TensorFlowBenchmarkArguments(BenchmarkArguments):
@property @property
@tf_required @tf_required
def n_gpu(self) -> int: def n_gpu(self) -> int:
if not self.no_cuda: if self.cuda:
return len(self.gpu_list) return len(self.gpu_list)
return 0 return 0
......
...@@ -57,22 +57,38 @@ class BenchmarkArguments: ...@@ -57,22 +57,38 @@ class BenchmarkArguments:
metadata={"help": "List of sequence lengths for which memory and time performance will be evaluated"}, metadata={"help": "List of sequence lengths for which memory and time performance will be evaluated"},
) )
no_inference: bool = field(default=False, metadata={"help": "Don't benchmark inference of model"}) inference: bool = field(
no_cuda: bool = field(default=False, metadata={"help": "Whether to run on available cuda devices"}) default=True,
no_tpu: bool = field(default=False, metadata={"help": "Whether to run on available tpu devices"}) metadata={"help": "Whether to benchmark inference of model. Inference can be disabled via --no-inference."},
)
cuda: bool = field(
default=True,
metadata={"help": "Whether to run on available cuda devices. Cuda can be disabled via --no-cuda."},
)
tpu: bool = field(
default=True, metadata={"help": "Whether to run on available tpu devices. TPU can be disabled via --no-tpu."}
)
fp16: bool = field(default=False, metadata={"help": "Use FP16 to accelerate inference."}) fp16: bool = field(default=False, metadata={"help": "Use FP16 to accelerate inference."})
training: bool = field(default=False, metadata={"help": "Benchmark training of model"}) training: bool = field(default=False, metadata={"help": "Benchmark training of model"})
verbose: bool = field(default=False, metadata={"help": "Verbose memory tracing"}) verbose: bool = field(default=False, metadata={"help": "Verbose memory tracing"})
no_speed: bool = field(default=False, metadata={"help": "Don't perform speed measurements"}) speed: bool = field(
no_memory: bool = field(default=False, metadata={"help": "Don't perform memory measurements"}) default=True,
metadata={"help": "Whether to perform speed measurements. Speed measurements can be disabled via --no-speed."},
)
memory: bool = field(
default=True,
metadata={
"help": "Whether to perform memory measurements. Memory measurements can be disabled via --no-memory"
},
)
trace_memory_line_by_line: bool = field(default=False, metadata={"help": "Trace memory line by line"}) trace_memory_line_by_line: bool = field(default=False, metadata={"help": "Trace memory line by line"})
save_to_csv: bool = field(default=False, metadata={"help": "Save result to a CSV file"}) save_to_csv: bool = field(default=False, metadata={"help": "Save result to a CSV file"})
log_print: bool = field(default=False, metadata={"help": "Save all print statements in a log file"}) log_print: bool = field(default=False, metadata={"help": "Save all print statements in a log file"})
no_env_print: bool = field(default=False, metadata={"help": "Don't print environment information"}) env_print: bool = field(default=False, metadata={"help": "Whether to print environment information"})
no_multi_process: bool = field( multi_process: bool = field(
default=False, default=True,
metadata={ metadata={
"help": "Don't use multiprocessing for memory and speed measurement. It is highly recommended to use multiprocessing for accurate CPU and GPU memory measurements. This option should only be used for debugging / testing and on TPU." "help": "Whether to use multiprocessing for memory and speed measurement. It is highly recommended to use multiprocessing for accurate CPU and GPU memory measurements. This option should only be disabled for debugging / testing and on TPU."
}, },
) )
inference_time_csv_file: str = field( inference_time_csv_file: str = field(
...@@ -122,7 +138,7 @@ class BenchmarkArguments: ...@@ -122,7 +138,7 @@ class BenchmarkArguments:
@property @property
def do_multi_processing(self): def do_multi_processing(self):
if self.no_multi_process: if not self.multi_process:
return False return False
elif self.is_tpu: elif self.is_tpu:
logger.info("Multiprocessing is currently not possible on TPU.") logger.info("Multiprocessing is currently not possible on TPU.")
......
...@@ -248,7 +248,7 @@ class TensorFlowBenchmark(Benchmark): ...@@ -248,7 +248,7 @@ class TensorFlowBenchmark(Benchmark):
if self.args.is_tpu: if self.args.is_tpu:
# tpu # tpu
raise NotImplementedError( raise NotImplementedError(
"Memory Benchmarking is currently not implemented for TPU. Please disable memory benchmarking with `args.no_memory=True`" "Memory Benchmarking is currently not implemented for TPU. Please disable memory benchmarking with `args.memory=False`"
) )
elif self.args.is_gpu: elif self.args.is_gpu:
# gpu # gpu
......
...@@ -584,9 +584,9 @@ class Benchmark(ABC): ...@@ -584,9 +584,9 @@ class Benchmark(ABC):
else: else:
self.config_dict = {model_name: config for model_name, config in zip(self.args.model_names, configs)} self.config_dict = {model_name: config for model_name, config in zip(self.args.model_names, configs)}
if not self.args.no_memory and os.getenv("TRANSFORMERS_USE_MULTIPROCESSING") == 0: if self.args.memory and os.getenv("TRANSFORMERS_USE_MULTIPROCESSING") == 0:
logger.warning( logger.warning(
"Memory consumption will not be measured accurately if `args.no_multi_process` is set to `True.` The flag 'TRANSFORMERS_USE_MULTIPROCESSING' should only be disabled for debugging / testing." "Memory consumption will not be measured accurately if `args.multi_process` is set to `False.` The flag 'TRANSFORMERS_USE_MULTIPROCESSING' should only be disabled for debugging / testing."
) )
self._print_fn = None self._print_fn = None
...@@ -669,24 +669,24 @@ class Benchmark(ABC): ...@@ -669,24 +669,24 @@ class Benchmark(ABC):
for batch_size in self.args.batch_sizes: for batch_size in self.args.batch_sizes:
for sequence_length in self.args.sequence_lengths: for sequence_length in self.args.sequence_lengths:
if not self.args.no_inference: if self.args.inference:
if not self.args.no_memory: if self.args.memory:
memory, inference_summary = self.inference_memory(model_name, batch_size, sequence_length) memory, inference_summary = self.inference_memory(model_name, batch_size, sequence_length)
inference_result_memory[model_name]["result"][batch_size][sequence_length] = memory inference_result_memory[model_name]["result"][batch_size][sequence_length] = memory
if not self.args.no_speed: if self.args.speed:
time = self.inference_speed(model_name, batch_size, sequence_length) time = self.inference_speed(model_name, batch_size, sequence_length)
inference_result_time[model_name]["result"][batch_size][sequence_length] = time inference_result_time[model_name]["result"][batch_size][sequence_length] = time
if self.args.training: if self.args.training:
if not self.args.no_memory: if self.args.memory:
memory, train_summary = self.train_memory(model_name, batch_size, sequence_length) memory, train_summary = self.train_memory(model_name, batch_size, sequence_length)
train_result_memory[model_name]["result"][batch_size][sequence_length] = memory train_result_memory[model_name]["result"][batch_size][sequence_length] = memory
if not self.args.no_speed: if self.args.speed:
time = self.train_speed(model_name, batch_size, sequence_length) time = self.train_speed(model_name, batch_size, sequence_length)
train_result_time[model_name]["result"][batch_size][sequence_length] = time train_result_time[model_name]["result"][batch_size][sequence_length] = time
if not self.args.no_inference: if self.args.inference:
if not self.args.no_speed: if self.args.speed:
self.print_fn("\n" + 20 * "=" + ("INFERENCE - SPEED - RESULT").center(40) + 20 * "=") self.print_fn("\n" + 20 * "=" + ("INFERENCE - SPEED - RESULT").center(40) + 20 * "=")
self.print_results(inference_result_time, type_label="Time in s") self.print_results(inference_result_time, type_label="Time in s")
self.save_to_csv(inference_result_time, self.args.inference_time_csv_file) self.save_to_csv(inference_result_time, self.args.inference_time_csv_file)
...@@ -695,7 +695,7 @@ class Benchmark(ABC): ...@@ -695,7 +695,7 @@ class Benchmark(ABC):
"TPU was used for inference. Note that the time after compilation stabilized (after ~10 inferences model.forward(..) calls) was measured." "TPU was used for inference. Note that the time after compilation stabilized (after ~10 inferences model.forward(..) calls) was measured."
) )
if not self.args.no_memory: if self.args.memory:
self.print_fn("\n" + 20 * "=" + ("INFERENCE - MEMORY - RESULT").center(40) + 20 * "=") self.print_fn("\n" + 20 * "=" + ("INFERENCE - MEMORY - RESULT").center(40) + 20 * "=")
self.print_results(inference_result_memory, type_label="Memory in MB") self.print_results(inference_result_memory, type_label="Memory in MB")
self.save_to_csv(inference_result_memory, self.args.inference_memory_csv_file) self.save_to_csv(inference_result_memory, self.args.inference_memory_csv_file)
...@@ -705,7 +705,7 @@ class Benchmark(ABC): ...@@ -705,7 +705,7 @@ class Benchmark(ABC):
self.print_memory_trace_statistics(inference_summary) self.print_memory_trace_statistics(inference_summary)
if self.args.training: if self.args.training:
if not self.args.no_speed: if self.args.speed:
self.print_fn("\n" + 20 * "=" + ("TRAIN - SPEED - RESULTS").center(40) + 20 * "=") self.print_fn("\n" + 20 * "=" + ("TRAIN - SPEED - RESULTS").center(40) + 20 * "=")
self.print_results(train_result_time, "Time in s") self.print_results(train_result_time, "Time in s")
self.save_to_csv(train_result_time, self.args.train_time_csv_file) self.save_to_csv(train_result_time, self.args.train_time_csv_file)
...@@ -714,7 +714,7 @@ class Benchmark(ABC): ...@@ -714,7 +714,7 @@ class Benchmark(ABC):
"TPU was used for training. Note that the time after compilation stabilized (after ~10 train loss=model.forward(...) + loss.backward() calls) was measured." "TPU was used for training. Note that the time after compilation stabilized (after ~10 train loss=model.forward(...) + loss.backward() calls) was measured."
) )
if not self.args.no_memory: if self.args.memory:
self.print_fn("\n" + 20 * "=" + ("TRAIN - MEMORY - RESULTS").center(40) + 20 * "=") self.print_fn("\n" + 20 * "=" + ("TRAIN - MEMORY - RESULTS").center(40) + 20 * "=")
self.print_results(train_result_memory, type_label="Memory in MB") self.print_results(train_result_memory, type_label="Memory in MB")
self.save_to_csv(train_result_memory, self.args.train_memory_csv_file) self.save_to_csv(train_result_memory, self.args.train_memory_csv_file)
...@@ -723,7 +723,7 @@ class Benchmark(ABC): ...@@ -723,7 +723,7 @@ class Benchmark(ABC):
self.print_fn("\n" + 20 * "=" + ("TRAIN - MEMOMRY - LINE BY LINE - SUMMARY").center(40) + 20 * "=") self.print_fn("\n" + 20 * "=" + ("TRAIN - MEMOMRY - LINE BY LINE - SUMMARY").center(40) + 20 * "=")
self.print_memory_trace_statistics(train_summary) self.print_memory_trace_statistics(train_summary)
if not self.args.no_env_print: if self.args.env_print:
self.print_fn("\n" + 20 * "=" + ("ENVIRONMENT INFORMATION").center(40) + 20 * "=") self.print_fn("\n" + 20 * "=" + ("ENVIRONMENT INFORMATION").center(40) + 20 * "=")
self.print_fn( self.print_fn(
"\n".join(["- {}: {}".format(prop, val) for prop, val in self.environment_info.items()]) + "\n" "\n".join(["- {}: {}".format(prop, val) for prop, val in self.environment_info.items()]) + "\n"
......
...@@ -24,10 +24,10 @@ class BenchmarkTest(unittest.TestCase): ...@@ -24,10 +24,10 @@ class BenchmarkTest(unittest.TestCase):
benchmark_args = PyTorchBenchmarkArguments( benchmark_args = PyTorchBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=False, training=False,
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = PyTorchBenchmark(benchmark_args) benchmark = PyTorchBenchmark(benchmark_args)
results = benchmark.run() results = benchmark.run()
...@@ -39,10 +39,10 @@ class BenchmarkTest(unittest.TestCase): ...@@ -39,10 +39,10 @@ class BenchmarkTest(unittest.TestCase):
benchmark_args = PyTorchBenchmarkArguments( benchmark_args = PyTorchBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=False, training=False,
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
only_pretrain_model=True, only_pretrain_model=True,
) )
benchmark = PyTorchBenchmark(benchmark_args) benchmark = PyTorchBenchmark(benchmark_args)
...@@ -55,11 +55,11 @@ class BenchmarkTest(unittest.TestCase): ...@@ -55,11 +55,11 @@ class BenchmarkTest(unittest.TestCase):
benchmark_args = PyTorchBenchmarkArguments( benchmark_args = PyTorchBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=False, training=False,
no_inference=False, inference=True,
torchscript=True, torchscript=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = PyTorchBenchmark(benchmark_args) benchmark = PyTorchBenchmark(benchmark_args)
results = benchmark.run() results = benchmark.run()
...@@ -72,11 +72,11 @@ class BenchmarkTest(unittest.TestCase): ...@@ -72,11 +72,11 @@ class BenchmarkTest(unittest.TestCase):
benchmark_args = PyTorchBenchmarkArguments( benchmark_args = PyTorchBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=False, training=False,
no_inference=False, inference=True,
fp16=True, fp16=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = PyTorchBenchmark(benchmark_args) benchmark = PyTorchBenchmark(benchmark_args)
results = benchmark.run() results = benchmark.run()
...@@ -91,10 +91,10 @@ class BenchmarkTest(unittest.TestCase): ...@@ -91,10 +91,10 @@ class BenchmarkTest(unittest.TestCase):
benchmark_args = PyTorchBenchmarkArguments( benchmark_args = PyTorchBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=True, training=True,
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = PyTorchBenchmark(benchmark_args, configs=[config]) benchmark = PyTorchBenchmark(benchmark_args, configs=[config])
results = benchmark.run() results = benchmark.run()
...@@ -106,10 +106,10 @@ class BenchmarkTest(unittest.TestCase): ...@@ -106,10 +106,10 @@ class BenchmarkTest(unittest.TestCase):
benchmark_args = PyTorchBenchmarkArguments( benchmark_args = PyTorchBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=True, training=True,
no_inference=True, inference=False,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = PyTorchBenchmark(benchmark_args) benchmark = PyTorchBenchmark(benchmark_args)
results = benchmark.run() results = benchmark.run()
...@@ -122,11 +122,11 @@ class BenchmarkTest(unittest.TestCase): ...@@ -122,11 +122,11 @@ class BenchmarkTest(unittest.TestCase):
benchmark_args = PyTorchBenchmarkArguments( benchmark_args = PyTorchBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=True, training=True,
no_inference=True, inference=False,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
fp16=True, fp16=True,
no_multi_process=True, multi_process=False,
) )
benchmark = PyTorchBenchmark(benchmark_args) benchmark = PyTorchBenchmark(benchmark_args)
results = benchmark.run() results = benchmark.run()
...@@ -139,10 +139,10 @@ class BenchmarkTest(unittest.TestCase): ...@@ -139,10 +139,10 @@ class BenchmarkTest(unittest.TestCase):
benchmark_args = PyTorchBenchmarkArguments( benchmark_args = PyTorchBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=False, training=False,
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = PyTorchBenchmark(benchmark_args, configs=[config]) benchmark = PyTorchBenchmark(benchmark_args, configs=[config])
results = benchmark.run() results = benchmark.run()
...@@ -155,10 +155,10 @@ class BenchmarkTest(unittest.TestCase): ...@@ -155,10 +155,10 @@ class BenchmarkTest(unittest.TestCase):
benchmark_args = PyTorchBenchmarkArguments( benchmark_args = PyTorchBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=False, training=False,
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = PyTorchBenchmark(benchmark_args, configs=[config]) benchmark = PyTorchBenchmark(benchmark_args, configs=[config])
results = benchmark.run() results = benchmark.run()
...@@ -171,10 +171,10 @@ class BenchmarkTest(unittest.TestCase): ...@@ -171,10 +171,10 @@ class BenchmarkTest(unittest.TestCase):
benchmark_args = PyTorchBenchmarkArguments( benchmark_args = PyTorchBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=True, training=True,
no_inference=True, inference=False,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = PyTorchBenchmark(benchmark_args, configs=[config]) benchmark = PyTorchBenchmark(benchmark_args, configs=[config])
results = benchmark.run() results = benchmark.run()
...@@ -187,10 +187,10 @@ class BenchmarkTest(unittest.TestCase): ...@@ -187,10 +187,10 @@ class BenchmarkTest(unittest.TestCase):
benchmark_args = PyTorchBenchmarkArguments( benchmark_args = PyTorchBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=True, training=True,
no_inference=True, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = PyTorchBenchmark(benchmark_args, configs=[config]) benchmark = PyTorchBenchmark(benchmark_args, configs=[config])
results = benchmark.run() results = benchmark.run()
...@@ -203,7 +203,7 @@ class BenchmarkTest(unittest.TestCase): ...@@ -203,7 +203,7 @@ class BenchmarkTest(unittest.TestCase):
benchmark_args = PyTorchBenchmarkArguments( benchmark_args = PyTorchBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=True, training=True,
no_inference=False, inference=True,
save_to_csv=True, save_to_csv=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
...@@ -212,7 +212,7 @@ class BenchmarkTest(unittest.TestCase): ...@@ -212,7 +212,7 @@ class BenchmarkTest(unittest.TestCase):
inference_memory_csv_file=os.path.join(tmp_dir, "inf_mem.csv"), inference_memory_csv_file=os.path.join(tmp_dir, "inf_mem.csv"),
train_time_csv_file=os.path.join(tmp_dir, "train_time.csv"), train_time_csv_file=os.path.join(tmp_dir, "train_time.csv"),
env_info_csv_file=os.path.join(tmp_dir, "env.csv"), env_info_csv_file=os.path.join(tmp_dir, "env.csv"),
no_multi_process=True, multi_process=False,
) )
benchmark = PyTorchBenchmark(benchmark_args) benchmark = PyTorchBenchmark(benchmark_args)
benchmark.run() benchmark.run()
...@@ -235,13 +235,13 @@ class BenchmarkTest(unittest.TestCase): ...@@ -235,13 +235,13 @@ class BenchmarkTest(unittest.TestCase):
benchmark_args = PyTorchBenchmarkArguments( benchmark_args = PyTorchBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=True, training=True,
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
log_filename=os.path.join(tmp_dir, "log.txt"), log_filename=os.path.join(tmp_dir, "log.txt"),
log_print=True, log_print=True,
trace_memory_line_by_line=True, trace_memory_line_by_line=True,
no_multi_process=True, multi_process=False,
) )
benchmark = PyTorchBenchmark(benchmark_args) benchmark = PyTorchBenchmark(benchmark_args)
result = benchmark.run() result = benchmark.run()
......
...@@ -26,11 +26,11 @@ class TFBenchmarkTest(unittest.TestCase): ...@@ -26,11 +26,11 @@ class TFBenchmarkTest(unittest.TestCase):
benchmark_args = TensorFlowBenchmarkArguments( benchmark_args = TensorFlowBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=False, training=False,
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
eager_mode=True, eager_mode=True,
no_multi_process=True, multi_process=False,
) )
benchmark = TensorFlowBenchmark(benchmark_args) benchmark = TensorFlowBenchmark(benchmark_args)
results = benchmark.run() results = benchmark.run()
...@@ -42,10 +42,10 @@ class TFBenchmarkTest(unittest.TestCase): ...@@ -42,10 +42,10 @@ class TFBenchmarkTest(unittest.TestCase):
benchmark_args = TensorFlowBenchmarkArguments( benchmark_args = TensorFlowBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=False, training=False,
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
only_pretrain_model=True, only_pretrain_model=True,
) )
benchmark = TensorFlowBenchmark(benchmark_args) benchmark = TensorFlowBenchmark(benchmark_args)
...@@ -58,10 +58,10 @@ class TFBenchmarkTest(unittest.TestCase): ...@@ -58,10 +58,10 @@ class TFBenchmarkTest(unittest.TestCase):
benchmark_args = TensorFlowBenchmarkArguments( benchmark_args = TensorFlowBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=False, training=False,
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = TensorFlowBenchmark(benchmark_args) benchmark = TensorFlowBenchmark(benchmark_args)
results = benchmark.run() results = benchmark.run()
...@@ -74,11 +74,11 @@ class TFBenchmarkTest(unittest.TestCase): ...@@ -74,11 +74,11 @@ class TFBenchmarkTest(unittest.TestCase):
benchmark_args = TensorFlowBenchmarkArguments( benchmark_args = TensorFlowBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=False, training=False,
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
eager_mode=True, eager_mode=True,
no_multi_process=True, multi_process=False,
) )
benchmark = TensorFlowBenchmark(benchmark_args, [config]) benchmark = TensorFlowBenchmark(benchmark_args, [config])
results = benchmark.run() results = benchmark.run()
...@@ -91,10 +91,10 @@ class TFBenchmarkTest(unittest.TestCase): ...@@ -91,10 +91,10 @@ class TFBenchmarkTest(unittest.TestCase):
benchmark_args = TensorFlowBenchmarkArguments( benchmark_args = TensorFlowBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=False, training=False,
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = TensorFlowBenchmark(benchmark_args, [config]) benchmark = TensorFlowBenchmark(benchmark_args, [config])
results = benchmark.run() results = benchmark.run()
...@@ -106,10 +106,10 @@ class TFBenchmarkTest(unittest.TestCase): ...@@ -106,10 +106,10 @@ class TFBenchmarkTest(unittest.TestCase):
benchmark_args = TensorFlowBenchmarkArguments( benchmark_args = TensorFlowBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=True, training=True,
no_inference=True, inference=False,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = TensorFlowBenchmark(benchmark_args) benchmark = TensorFlowBenchmark(benchmark_args)
results = benchmark.run() results = benchmark.run()
...@@ -122,10 +122,10 @@ class TFBenchmarkTest(unittest.TestCase): ...@@ -122,10 +122,10 @@ class TFBenchmarkTest(unittest.TestCase):
benchmark_args = TensorFlowBenchmarkArguments( benchmark_args = TensorFlowBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=True, training=True,
no_inference=True, inference=False,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = TensorFlowBenchmark(benchmark_args, [config]) benchmark = TensorFlowBenchmark(benchmark_args, [config])
results = benchmark.run() results = benchmark.run()
...@@ -138,10 +138,10 @@ class TFBenchmarkTest(unittest.TestCase): ...@@ -138,10 +138,10 @@ class TFBenchmarkTest(unittest.TestCase):
benchmark_args = TensorFlowBenchmarkArguments( benchmark_args = TensorFlowBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=False, training=False,
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
no_multi_process=True, multi_process=False,
) )
benchmark = TensorFlowBenchmark(benchmark_args, configs=[config]) benchmark = TensorFlowBenchmark(benchmark_args, configs=[config])
results = benchmark.run() results = benchmark.run()
...@@ -154,11 +154,11 @@ class TFBenchmarkTest(unittest.TestCase): ...@@ -154,11 +154,11 @@ class TFBenchmarkTest(unittest.TestCase):
benchmark_args = TensorFlowBenchmarkArguments( benchmark_args = TensorFlowBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
training=False, training=False,
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
use_xla=True, use_xla=True,
no_multi_process=True, multi_process=False,
) )
benchmark = TensorFlowBenchmark(benchmark_args) benchmark = TensorFlowBenchmark(benchmark_args)
results = benchmark.run() results = benchmark.run()
...@@ -170,14 +170,14 @@ class TFBenchmarkTest(unittest.TestCase): ...@@ -170,14 +170,14 @@ class TFBenchmarkTest(unittest.TestCase):
with tempfile.TemporaryDirectory() as tmp_dir: with tempfile.TemporaryDirectory() as tmp_dir:
benchmark_args = TensorFlowBenchmarkArguments( benchmark_args = TensorFlowBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
no_inference=False, inference=True,
save_to_csv=True, save_to_csv=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
inference_time_csv_file=os.path.join(tmp_dir, "inf_time.csv"), inference_time_csv_file=os.path.join(tmp_dir, "inf_time.csv"),
inference_memory_csv_file=os.path.join(tmp_dir, "inf_mem.csv"), inference_memory_csv_file=os.path.join(tmp_dir, "inf_mem.csv"),
env_info_csv_file=os.path.join(tmp_dir, "env.csv"), env_info_csv_file=os.path.join(tmp_dir, "env.csv"),
no_multi_process=True, multi_process=False,
) )
benchmark = TensorFlowBenchmark(benchmark_args) benchmark = TensorFlowBenchmark(benchmark_args)
benchmark.run() benchmark.run()
...@@ -197,14 +197,14 @@ class TFBenchmarkTest(unittest.TestCase): ...@@ -197,14 +197,14 @@ class TFBenchmarkTest(unittest.TestCase):
with tempfile.TemporaryDirectory() as tmp_dir: with tempfile.TemporaryDirectory() as tmp_dir:
benchmark_args = TensorFlowBenchmarkArguments( benchmark_args = TensorFlowBenchmarkArguments(
models=[MODEL_ID], models=[MODEL_ID],
no_inference=False, inference=True,
sequence_lengths=[8], sequence_lengths=[8],
batch_sizes=[1], batch_sizes=[1],
log_filename=os.path.join(tmp_dir, "log.txt"), log_filename=os.path.join(tmp_dir, "log.txt"),
log_print=True, log_print=True,
trace_memory_line_by_line=True, trace_memory_line_by_line=True,
eager_mode=True, eager_mode=True,
no_multi_process=True, multi_process=False,
) )
benchmark = TensorFlowBenchmark(benchmark_args) benchmark = TensorFlowBenchmark(benchmark_args)
result = benchmark.run() result = benchmark.run()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment