in tensorflow_hub/native_module.py [0:0]
def replace_apply_state(meta_graph, state_ops, feed_map):
"""Replaces state ops with non state Placeholder ops for the apply graph."""
for node in meta_graph.graph_def.node:
keys_to_purge = []
tensor_name = node.name + ":0"
# Verify that the node is a state op and that its due to be rewired
# in the feedmap.
if node.op in state_ops and tensor_name in feed_map:
node.op = "Placeholder"
for key in node.attr:
# Only shape and dtype are required for Placeholder. Remove other
# attributes.
if key != "shape":
keys_to_purge.append(key)
for key in keys_to_purge:
del node.attr[key]
node.attr["dtype"].type = types_pb2.DT_RESOURCE