Skip to content

Commit 4b06a97

Browse files
Zongwei Zhoutensorflower-gardener
authored andcommitted
Add Resnet-50 CTL FP16 benchmarks
PiperOrigin-RevId: 285568490
1 parent 0788a23 commit 4b06a97

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

official/benchmark/resnet_ctl_imagenet_benchmark.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,17 @@ def benchmark_1_gpu(self):
236236
FLAGS.batch_size = 128
237237
self._run_and_report_benchmark()
238238

239+
def benchmark_1_gpu_fp16(self):
240+
"""Test Keras model with 1 GPU with tf.keras mixed precision."""
241+
self._setup()
242+
243+
FLAGS.num_gpus = 1
244+
FLAGS.distribution_strategy = 'one_device'
245+
FLAGS.model_dir = self._get_model_dir('benchmark_1_gpu_fp16')
246+
FLAGS.batch_size = 256
247+
FLAGS.dtype = 'fp16'
248+
self._run_and_report_benchmark()
249+
239250
def benchmark_1_gpu_amp(self):
240251
"""Test Keras model with 1 GPU with automatic mixed precision."""
241252
self._setup()
@@ -273,6 +284,19 @@ def benchmark_1_gpu_eager(self):
273284
FLAGS.single_l2_loss_op = True
274285
self._run_and_report_benchmark()
275286

287+
def benchmark_1_gpu_fp16_eager(self):
288+
"""Test Keras model with 1 GPU with fp16 and pure eager mode."""
289+
self._setup()
290+
291+
FLAGS.num_gpus = 1
292+
FLAGS.distribution_strategy = 'one_device'
293+
FLAGS.model_dir = self._get_model_dir('benchmark_1_gpu_fp16_eager')
294+
FLAGS.batch_size = 128
295+
FLAGS.dtype = 'fp16'
296+
FLAGS.use_tf_function = False
297+
FLAGS.single_l2_loss_op = True
298+
self._run_and_report_benchmark()
299+
276300
def benchmark_8_gpu(self):
277301
"""Test Keras model with 8 GPUs."""
278302
self._setup()
@@ -283,6 +307,17 @@ def benchmark_8_gpu(self):
283307
FLAGS.batch_size = 128 * 8 # 8 GPUs
284308
self._run_and_report_benchmark()
285309

310+
def benchmark_8_gpu_fp16(self):
311+
"""Test Keras model with 8 GPUs with tf.keras mixed precision."""
312+
self._setup()
313+
314+
FLAGS.num_gpus = 8
315+
FLAGS.distribution_strategy = 'mirrored'
316+
FLAGS.model_dir = self._get_model_dir('benchmark_8_gpu_fp16')
317+
FLAGS.batch_size = 256 * 8 # 8 GPUs
318+
FLAGS.dtype = 'fp16'
319+
self._run_and_report_benchmark()
320+
286321
def benchmark_8_gpu_amp(self):
287322
"""Test Keras model with 8 GPUs with automatic mixed precision."""
288323
self._setup()

0 commit comments

Comments
 (0)