Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
f21337b1
Unverified
Commit
f21337b1
authored
Jun 21, 2019
by
Toby Boyd
Committed by
GitHub
Jun 21, 2019
Browse files
Add ResNet56 CPU benchmark and accuracy tests. (#7070)
* cpu benchmark and accuracy tests. * add docstrings to fix lint.
parent
a68f65f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
27 deletions
+118
-27
official/resnet/keras/keras_cifar_benchmark.py
official/resnet/keras/keras_cifar_benchmark.py
+118
-27
No files found.
official/resnet/keras/keras_cifar_benchmark.py
View file @
f21337b1
...
@@ -77,6 +77,49 @@ class Resnet56KerasAccuracy(keras_benchmark.KerasBenchmark):
...
@@ -77,6 +77,49 @@ class Resnet56KerasAccuracy(keras_benchmark.KerasBenchmark):
FLAGS
.
enable_eager
=
True
FLAGS
.
enable_eager
=
True
self
.
_run_and_report_benchmark
()
self
.
_run_and_report_benchmark
()
def
benchmark_cpu
(
self
):
"""Test keras based model on CPU."""
self
.
_setup
()
FLAGS
.
num_gpus
=
0
FLAGS
.
data_dir
=
self
.
data_dir
FLAGS
.
batch_size
=
128
FLAGS
.
train_epochs
=
182
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_cpu'
)
FLAGS
.
dtype
=
'fp32'
FLAGS
.
enable_eager
=
True
FLAGS
.
data_format
=
'channels_last'
self
.
_run_and_report_benchmark
()
def
benchmark_cpu_no_dist_strat
(
self
):
"""Test keras based model on CPU without distribution strategies."""
self
.
_setup
()
FLAGS
.
num_gpus
=
0
FLAGS
.
data_dir
=
self
.
data_dir
FLAGS
.
batch_size
=
128
FLAGS
.
train_epochs
=
182
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_cpu_no_dist_strat'
)
FLAGS
.
dtype
=
'fp32'
FLAGS
.
enable_eager
=
True
FLAGS
.
distribution_strategy
=
'off'
FLAGS
.
data_format
=
'channels_last'
self
.
_run_and_report_benchmark
()
def
benchmark_cpu_no_dist_strat_run_eagerly
(
self
):
"""Test keras based model on CPU w/forced eager and no dist_strat."""
self
.
_setup
()
FLAGS
.
num_gpus
=
0
FLAGS
.
data_dir
=
self
.
data_dir
FLAGS
.
batch_size
=
128
FLAGS
.
train_epochs
=
182
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_cpu_no_dist_strat_run_eagerly'
)
FLAGS
.
dtype
=
'fp32'
FLAGS
.
enable_eager
=
True
FLAGS
.
run_eagerly
=
True
FLAGS
.
distribution_strategy
=
'off'
FLAGS
.
data_format
=
'channels_last'
self
.
_run_and_report_benchmark
()
def
benchmark_1_gpu_no_dist_strat
(
self
):
def
benchmark_1_gpu_no_dist_strat
(
self
):
"""Test keras based model with eager and no dist strat."""
"""Test keras based model with eager and no dist strat."""
self
.
_setup
()
self
.
_setup
()
...
@@ -92,7 +135,7 @@ class Resnet56KerasAccuracy(keras_benchmark.KerasBenchmark):
...
@@ -92,7 +135,7 @@ class Resnet56KerasAccuracy(keras_benchmark.KerasBenchmark):
self
.
_run_and_report_benchmark
()
self
.
_run_and_report_benchmark
()
def
benchmark_1_gpu_no_dist_strat_run_eagerly
(
self
):
def
benchmark_1_gpu_no_dist_strat_run_eagerly
(
self
):
"""Test keras based model w
ith
forced eager and no dist_strat."""
"""Test keras based model w
/
forced eager and no dist_strat."""
self
.
_setup
()
self
.
_setup
()
FLAGS
.
num_gpus
=
1
FLAGS
.
num_gpus
=
1
FLAGS
.
data_dir
=
self
.
data_dir
FLAGS
.
data_dir
=
self
.
data_dir
...
@@ -177,57 +220,48 @@ class Resnet56KerasBenchmarkBase(keras_benchmark.KerasBenchmark):
...
@@ -177,57 +220,48 @@ class Resnet56KerasBenchmarkBase(keras_benchmark.KerasBenchmark):
total_batch_size
=
FLAGS
.
batch_size
,
total_batch_size
=
FLAGS
.
batch_size
,
log_steps
=
FLAGS
.
log_steps
)
log_steps
=
FLAGS
.
log_steps
)
def
benchmark_1_gpu_no_dist_strat
(
self
):
def
benchmark_1_gpu
(
self
):
self
.
_setup
()
"""Test 1 gpu."""
FLAGS
.
num_gpus
=
1
FLAGS
.
enable_eager
=
True
FLAGS
.
distribution_strategy
=
'off'
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_1_gpu_no_dist_strat'
)
FLAGS
.
batch_size
=
128
self
.
_run_and_report_benchmark
()
def
benchmark_1_gpu_no_dist_strat_tweaked
(
self
):
"""Test no distribution strategy with manual config."""
self
.
_setup
()
self
.
_setup
()
FLAGS
.
num_gpus
=
1
FLAGS
.
num_gpus
=
1
FLAGS
.
enable_eager
=
True
FLAGS
.
enable_eager
=
True
FLAGS
.
explicit_gpu_placement
=
True
FLAGS
.
distribution_strategy
=
'default'
FLAGS
.
distribution_strategy
=
'off'
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_1_gpu'
)
FLAGS
.
set_learning_phase_to_train
=
False
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_1_gpu_no_dist_strat_tweaked'
)
FLAGS
.
batch_size
=
128
FLAGS
.
batch_size
=
128
self
.
_run_and_report_benchmark
()
self
.
_run_and_report_benchmark
()
def
benchmark_graph_1_gpu_no_dist_strat
(
self
):
def
benchmark_graph_1_gpu
(
self
):
"""Test 1 gpu graph."""
self
.
_setup
()
self
.
_setup
()
FLAGS
.
num_gpus
=
1
FLAGS
.
num_gpus
=
1
FLAGS
.
enable_eager
=
False
FLAGS
.
enable_eager
=
False
FLAGS
.
distribution_strategy
=
'
off
'
FLAGS
.
distribution_strategy
=
'
default
'
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_graph_1_gpu
_no_dist_strat
'
)
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_graph_1_gpu'
)
FLAGS
.
batch_size
=
128
FLAGS
.
batch_size
=
128
self
.
_run_and_report_benchmark
()
self
.
_run_and_report_benchmark
()
def
benchmark_1_gpu
(
self
):
def
benchmark_1_gpu_no_dist_strat
(
self
):
"""Test 1 gpu without distribution strategies."""
self
.
_setup
()
self
.
_setup
()
FLAGS
.
num_gpus
=
1
FLAGS
.
num_gpus
=
1
FLAGS
.
enable_eager
=
True
FLAGS
.
enable_eager
=
True
FLAGS
.
distribution_strategy
=
'
default
'
FLAGS
.
distribution_strategy
=
'
off
'
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_1_gpu'
)
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_1_gpu
_no_dist_strat
'
)
FLAGS
.
batch_size
=
128
FLAGS
.
batch_size
=
128
self
.
_run_and_report_benchmark
()
self
.
_run_and_report_benchmark
()
def
benchmark_graph_1_gpu
(
self
):
def
benchmark_graph_1_gpu_no_dist_strat
(
self
):
"""Test 1 gpu graph mode without distribution strategies."""
self
.
_setup
()
self
.
_setup
()
FLAGS
.
num_gpus
=
1
FLAGS
.
num_gpus
=
1
FLAGS
.
enable_eager
=
False
FLAGS
.
enable_eager
=
False
FLAGS
.
distribution_strategy
=
'
default
'
FLAGS
.
distribution_strategy
=
'
off
'
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_graph_1_gpu'
)
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_graph_1_gpu
_no_dist_strat
'
)
FLAGS
.
batch_size
=
128
FLAGS
.
batch_size
=
128
self
.
_run_and_report_benchmark
()
self
.
_run_and_report_benchmark
()
def
benchmark_1_gpu_no_dist_strat_run_eagerly
(
self
):
def
benchmark_1_gpu_no_dist_strat_run_eagerly
(
self
):
"""Test
keras based model with
forced eager."""
"""Test
1 gpu without distribution strategy and
forced eager."""
self
.
_setup
()
self
.
_setup
()
FLAGS
.
num_gpus
=
1
FLAGS
.
num_gpus
=
1
FLAGS
.
batch_size
=
128
FLAGS
.
batch_size
=
128
...
@@ -240,6 +274,7 @@ class Resnet56KerasBenchmarkBase(keras_benchmark.KerasBenchmark):
...
@@ -240,6 +274,7 @@ class Resnet56KerasBenchmarkBase(keras_benchmark.KerasBenchmark):
self
.
_run_and_report_benchmark
()
self
.
_run_and_report_benchmark
()
def
benchmark_2_gpu
(
self
):
def
benchmark_2_gpu
(
self
):
"""Test 2 gpu."""
self
.
_setup
()
self
.
_setup
()
FLAGS
.
num_gpus
=
2
FLAGS
.
num_gpus
=
2
FLAGS
.
enable_eager
=
True
FLAGS
.
enable_eager
=
True
...
@@ -249,6 +284,7 @@ class Resnet56KerasBenchmarkBase(keras_benchmark.KerasBenchmark):
...
@@ -249,6 +284,7 @@ class Resnet56KerasBenchmarkBase(keras_benchmark.KerasBenchmark):
self
.
_run_and_report_benchmark
()
self
.
_run_and_report_benchmark
()
def
benchmark_graph_2_gpu
(
self
):
def
benchmark_graph_2_gpu
(
self
):
"""Test 2 gpu graph mode."""
self
.
_setup
()
self
.
_setup
()
FLAGS
.
num_gpus
=
2
FLAGS
.
num_gpus
=
2
FLAGS
.
enable_eager
=
False
FLAGS
.
enable_eager
=
False
...
@@ -257,6 +293,61 @@ class Resnet56KerasBenchmarkBase(keras_benchmark.KerasBenchmark):
...
@@ -257,6 +293,61 @@ class Resnet56KerasBenchmarkBase(keras_benchmark.KerasBenchmark):
FLAGS
.
batch_size
=
128
*
2
# 2 GPUs
FLAGS
.
batch_size
=
128
*
2
# 2 GPUs
self
.
_run_and_report_benchmark
()
self
.
_run_and_report_benchmark
()
def
benchmark_cpu
(
self
):
"""Test cpu."""
self
.
_setup
()
FLAGS
.
num_gpus
=
0
FLAGS
.
enable_eager
=
True
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_cpu'
)
FLAGS
.
batch_size
=
128
FLAGS
.
data_format
=
'channels_last'
self
.
_run_and_report_benchmark
()
def
benchmark_graph_cpu
(
self
):
"""Test cpu graph mode."""
self
.
_setup
()
FLAGS
.
num_gpus
=
0
FLAGS
.
enable_eager
=
False
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_graph_cpu'
)
FLAGS
.
batch_size
=
128
FLAGS
.
data_format
=
'channels_last'
self
.
_run_and_report_benchmark
()
def
benchmark_cpu_no_dist_strat_run_eagerly
(
self
):
"""Test cpu without distribution strategy and forced eager."""
self
.
_setup
()
FLAGS
.
num_gpus
=
0
FLAGS
.
distribution_strategy
=
'off'
FLAGS
.
enable_eager
=
True
FLAGS
.
run_eagerly
=
True
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_cpu_no_dist_strat_run_eagerly'
)
FLAGS
.
batch_size
=
128
FLAGS
.
data_format
=
'channels_last'
self
.
_run_and_report_benchmark
()
def
benchmark_cpu_no_dist_strat
(
self
):
"""Test cpu without distribution strategies."""
self
.
_setup
()
FLAGS
.
num_gpus
=
0
FLAGS
.
enable_eager
=
True
FLAGS
.
distribution_strategy
=
'off'
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_cpu_no_dist_strat'
)
FLAGS
.
batch_size
=
128
FLAGS
.
data_format
=
'channels_last'
self
.
_run_and_report_benchmark
()
def
benchmark_graph_cpu_no_dist_strat
(
self
):
"""Test cpu graph mode without distribution strategies."""
self
.
_setup
()
FLAGS
.
num_gpus
=
0
FLAGS
.
enable_eager
=
False
FLAGS
.
distribution_strategy
=
'off'
FLAGS
.
model_dir
=
self
.
_get_model_dir
(
'benchmark_graph_cpu_no_dist_strat'
)
FLAGS
.
batch_size
=
128
FLAGS
.
data_format
=
'channels_last'
self
.
_run_and_report_benchmark
()
class
Resnet56KerasBenchmarkSynth
(
Resnet56KerasBenchmarkBase
):
class
Resnet56KerasBenchmarkSynth
(
Resnet56KerasBenchmarkBase
):
"""Synthetic benchmarks for ResNet56 and Keras."""
"""Synthetic benchmarks for ResNet56 and Keras."""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment