Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix keras dtype importing and unpin for CI #6857

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
- name: 'Install TensorFlow'
run: |
python -m pip install -U pip
pip install "${TENSORFLOW_VERSION}" keras-nightly==3.3.3.dev2024051503
pip install "${TENSORFLOW_VERSION}"
if: matrix.tf_version_id != 'notf'
- name: 'Install Python dependencies'
run: |
Expand Down
18 changes: 12 additions & 6 deletions tensorboard/plugins/graph/keras_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,19 @@ def keras_model_to_graph_def(keras_layer):
node_def.attr["keras_class"].s = keras_cls_name

dtype_or_policy = layer_config.get("dtype")
# Skip dtype processing if this is a dict, since it's presumably a instance of
# tf/keras/mixed_precision/Policy rather than a single dtype.
dtype = None
# If this is a dict, try and extract the dtype string from
# `config.name`; keras will export like this for non-input layers. If
# we can't find `config.name`, we skip it as it's presumably a instance
# of tf/keras/mixed_precision/Policy rather than a single dtype.
# TODO(#5548): parse the policy dict and populate the dtype attr with the variable dtype.
if dtype_or_policy is not None and not isinstance(
dtype_or_policy, dict
):
tf_dtype = dtypes.as_dtype(layer_config.get("dtype"))
if isinstance(dtype_or_policy, dict):
if "config" in dtype_or_policy:
dtype = dtype_or_policy.get("config").get("name")
elif dtype_or_policy is not None:
dtype = dtype_or_policy
if dtype is not None:
tf_dtype = dtypes.as_dtype(dtype)
node_def.attr["dtype"].type = tf_dtype.as_datatype_enum
if layer.get("inbound_nodes") is not None:
for name, size, index in _get_inbound_nodes(layer):
Expand Down
Loading