Skip to content

Commit

Permalink
disable_mixed_precision_graph_rewrite
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz committed May 6, 2024
1 parent ecfa478 commit e4e07ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions deepmd/tf/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
)

import tensorflow
from packaging.version import (
Version,
)
from tensorflow.python.framework import (
tensor_util,
)
Expand All @@ -31,6 +34,7 @@
)
from deepmd.tf.env import (
GLOBAL_TF_FLOAT_PRECISION,
TF_VERSION,
op_module,
tf,
)
Expand Down Expand Up @@ -289,3 +293,8 @@ def clear_session():
tf.reset_default_graph()
# TODO: remove this line when data_requirement is not a global variable
data_requirement.clear()
_TF_VERSION = Version(TF_VERSION)
if _TF_VERSION < Version("2.4.0"):
tf.train.experimental.disable_mixed_precision_graph_rewrite()

Check warning on line 298 in deepmd/tf/common.py

View check run for this annotation

Codecov / codecov/patch

deepmd/tf/common.py#L298

Added line #L298 was not covered by tests
else:
tf.mixed_precision.disable_mixed_precision_graph_rewrite()
4 changes: 4 additions & 0 deletions source/tests/tf/test_mixed_prec_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
Version,
)

from deepmd.tf.common import (
clear_session,
)
from deepmd.tf.env import (
TF_VERSION,
)
Expand Down Expand Up @@ -61,3 +64,4 @@ def tearDown(self):
_file_delete("model.ckpt-100.data-00000-of-00001")
_file_delete("input_v2_compat.json")
_file_delete("lcurve.out")
clear_session()

0 comments on commit e4e07ce

Please sign in to comment.