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)
benchmark_args = parser.parse_args_into_dataclasses()[0] 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 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
......
# coding=utf-8 # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team. # Copyright 2018 The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import dataclasses import dataclasses
import json import json
from dataclasses import dataclass, field from dataclasses import dataclass, field
from time import time from time import time
from typing import List from typing import List
from ..utils import logging from ..utils import logging
logger = logging.get_logger(__name__) logger = logging.get_logger(__name__)
def list_field(default=None, metadata=None): def list_field(default=None, metadata=None):
return field(default_factory=lambda: default, metadata=metadata) return field(default_factory=lambda: default, metadata=metadata)
@dataclass @dataclass
class BenchmarkArguments: class BenchmarkArguments:
""" """
BenchMarkArguments are arguments we use in our benchmark scripts BenchMarkArguments are arguments we use in our benchmark scripts
**which relate to the training loop itself**. **which relate to the training loop itself**.
Using `HfArgumentParser` we can turn this class Using `HfArgumentParser` we can turn this class
into argparse arguments to be able to specify them on into argparse arguments to be able to specify them on
the command line. the command line.
""" """
models: List[str] = list_field( models: List[str] = list_field(
default=[], default=[],
metadata={ metadata={
"help": "Model checkpoints to be provided to the AutoModel classes. Leave blank to benchmark the base version of all available models" "help": "Model checkpoints to be provided to the AutoModel classes. Leave blank to benchmark the base version of all available models"
}, },
) )
batch_sizes: List[int] = list_field( batch_sizes: List[int] = list_field(
default=[8], metadata={"help": "List of batch sizes for which memory and time performance will be evaluated"} default=[8], metadata={"help": "List of batch sizes for which memory and time performance will be evaluated"}
) )
sequence_lengths: List[int] = list_field( sequence_lengths: List[int] = list_field(
default=[8, 32, 128, 512], default=[8, 32, 128, 512],
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."},
fp16: bool = field(default=False, metadata={"help": "Use FP16 to accelerate inference."}) )
training: bool = field(default=False, metadata={"help": "Benchmark training of model"}) cuda: bool = field(
verbose: bool = field(default=False, metadata={"help": "Verbose memory tracing"}) default=True,
no_speed: bool = field(default=False, metadata={"help": "Don't perform speed measurements"}) metadata={"help": "Whether to run on available cuda devices. Cuda can be disabled via --no-cuda."},
no_memory: bool = field(default=False, metadata={"help": "Don't perform memory measurements"}) )
trace_memory_line_by_line: bool = field(default=False, metadata={"help": "Trace memory line by line"}) tpu: bool = field(
save_to_csv: bool = field(default=False, metadata={"help": "Save result to a CSV file"}) default=True, metadata={"help": "Whether to run on available tpu devices. TPU can be disabled via --no-tpu."}
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"}) fp16: bool = field(default=False, metadata={"help": "Use FP16 to accelerate inference."})
no_multi_process: bool = field( training: bool = field(default=False, metadata={"help": "Benchmark training of model"})
default=False, verbose: bool = field(default=False, metadata={"help": "Verbose memory tracing"})
metadata={ speed: bool = field(
"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." default=True,
}, metadata={"help": "Whether to perform speed measurements. Speed measurements can be disabled via --no-speed."},
) )
inference_time_csv_file: str = field( memory: bool = field(
default=f"inference_time_{round(time())}.csv", default=True,
metadata={"help": "CSV filename used if saving time results to csv."}, metadata={
) "help": "Whether to perform memory measurements. Memory measurements can be disabled via --no-memory"
inference_memory_csv_file: str = field( },
default=f"inference_memory_{round(time())}.csv", )
metadata={"help": "CSV filename used if saving memory results to csv."}, 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"})
train_time_csv_file: str = field( log_print: bool = field(default=False, metadata={"help": "Save all print statements in a log file"})
default=f"train_time_{round(time())}.csv", env_print: bool = field(default=False, metadata={"help": "Whether to print environment information"})
metadata={"help": "CSV filename used if saving time results to csv for training."}, multi_process: bool = field(
) default=True,
train_memory_csv_file: str = field( metadata={
default=f"train_memory_{round(time())}.csv", "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."
metadata={"help": "CSV filename used if saving memory results to csv for training."}, },
) )
env_info_csv_file: str = field( inference_time_csv_file: str = field(
default=f"env_info_{round(time())}.csv", default=f"inference_time_{round(time())}.csv",
metadata={"help": "CSV filename used if saving environment information."}, metadata={"help": "CSV filename used if saving time results to csv."},
) )
log_filename: str = field( inference_memory_csv_file: str = field(
default=f"log_{round(time())}.csv", default=f"inference_memory_{round(time())}.csv",
metadata={"help": "Log filename used if print statements are saved in log."}, metadata={"help": "CSV filename used if saving memory results to csv."},
) )
repeat: int = field(default=3, metadata={"help": "Times an experiment will be run."}) train_time_csv_file: str = field(
only_pretrain_model: bool = field( default=f"train_time_{round(time())}.csv",
default=False, metadata={"help": "CSV filename used if saving time results to csv for training."},
metadata={ )
"help": "Instead of loading the model as defined in `config.architectures` if exists, just load the pretrain model weights." train_memory_csv_file: str = field(
}, default=f"train_memory_{round(time())}.csv",
) metadata={"help": "CSV filename used if saving memory results to csv for training."},
)
def to_json_string(self): env_info_csv_file: str = field(
""" default=f"env_info_{round(time())}.csv",
Serializes this instance to a JSON string. metadata={"help": "CSV filename used if saving environment information."},
""" )
return json.dumps(dataclasses.asdict(self), indent=2) log_filename: str = field(
default=f"log_{round(time())}.csv",
@property metadata={"help": "Log filename used if print statements are saved in log."},
def model_names(self): )
assert ( repeat: int = field(default=3, metadata={"help": "Times an experiment will be run."})
len(self.models) > 0 only_pretrain_model: bool = field(
), "Please make sure you provide at least one model name / model identifier, *e.g.* `--models bert-base-cased` or `args.models = ['bert-base-cased']." default=False,
return self.models metadata={
"help": "Instead of loading the model as defined in `config.architectures` if exists, just load the pretrain model weights."
@property },
def do_multi_processing(self): )
if self.no_multi_process:
return False def to_json_string(self):
elif self.is_tpu: """
logger.info("Multiprocessing is currently not possible on TPU.") Serializes this instance to a JSON string.
return False """
else: return json.dumps(dataclasses.asdict(self), indent=2)
return True
@property
def model_names(self):
assert (
len(self.models) > 0
), "Please make sure you provide at least one model name / model identifier, *e.g.* `--models bert-base-cased` or `args.models = ['bert-base-cased']."
return self.models
@property
def do_multi_processing(self):
if not self.multi_process:
return False
elif self.is_tpu:
logger.info("Multiprocessing is currently not possible on TPU.")
return False
else:
return True
...@@ -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
......
...@@ -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