Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaroslavvb/16bb81fcfb0932169087add47ecb8c3a to your computer and use it in GitHub Desktop.
Save yaroslavvb/16bb81fcfb0932169087add47ecb8c3a to your computer and use it in GitHub Desktop.
import tensorflow as tf
from tensorflow.core.framework import op_def_pb2
from google.protobuf import text_format
def get_op_types(op):
for attr in op.attr:
if attr.type != 'type':
continue
return list(attr.allowed_values.list.type)
return []
# directory where you did "git clone"
tensorflow_git_base = "/Users/yaroslavvb/tensorflow_main.git"
ops_file = tensorflow_git_base+"/tensorflow/tensorflow/core/ops/ops.pbtxt"
ops = op_def_pb2.OpList()
text_format.Merge(open(ops_file).read(), ops)
for op in ops.op:
# get templated string types
if tf.string in get_op_types(op):
print op.name, op.summary
for arg in op.input_arg:
if arg.type == tf.string:
print op.name, op.summary
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment