From 909fa60601f4e11ee686abaf7347097a2b6e6720 Mon Sep 17 00:00:00 2001
From: Vinh Nguyen <vinhn@nvidia.com>
Date: Mon, 14 Oct 2019 12:34:10 +0000
Subject: [PATCH] adding automatic mixed precision training support

---
 DeepSpeech.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/DeepSpeech.py b/DeepSpeech.py
index a2dd045a..870250e8 100755
--- a/DeepSpeech.py
+++ b/DeepSpeech.py
@@ -446,6 +446,10 @@ def train():
 
     # Building the graph
     optimizer = create_optimizer()
+    
+    # Enable mixed precision training
+    if FLAGS.automatic_mixed_precision:
+        optimizer = tf.train.experimental.enable_mixed_precision_graph_rewrite(optimizer)
     gradients, loss, non_finite_files = get_tower_results(iterator, optimizer, dropout_rates)
 
     # Average tower gradients across GPUs