Skip to content

Commit 5f657da

Browse files
author
Saumitro Dasgupta
committed
Added comments for tensorflow transformer
1 parent f9110bb commit 5f657da

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

kaffe/tensorflow/transformer.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,34 @@
55

66

77
class TensorFlowNode(object):
8+
'''An intermediate representation for TensorFlow operations.'''
89

910
def __init__(self, op, *args, **kwargs):
11+
# A string corresponding to the TensorFlow operation
1012
self.op = op
13+
# Positional arguments for the operation
1114
self.args = args
15+
# Keyword arguments for the operation
1216
self.kwargs = list(kwargs.items())
17+
# The source Caffe node
1318
self.node = None
1419

1520
def format(self, arg):
21+
'''Returns a string representation for the given value.'''
1622
return "'%s'" % arg if isinstance(arg, basestring) else str(arg)
1723

1824
def pair(self, key, value):
25+
'''Returns key=formatted(value).'''
1926
return '%s=%s' % (key, self.format(value))
2027

2128
def emit(self):
29+
'''Emits the Python source for this node.'''
30+
# Format positional arguments
2231
args = map(self.format, self.args)
32+
# Format any keyword arguments
2333
if self.kwargs:
2434
args += [self.pair(k, v) for k, v in self.kwargs]
35+
# Set the node name
2536
args.append(self.pair('name', self.node.name))
2637
args = ', '.join(args)
2738
return '%s(%s)' % (self.op, args)

0 commit comments

Comments
 (0)