Skip to content

Commit cd717de

Browse files
KimBioInfoStudiotqchen
authored andcommitted
[ Relay ][ Frontend ][ Tensorflow ]add op add_n to relay/frontend/tensorflow.py (#4181)
1 parent bafc675 commit cd717de

File tree

3 files changed

+431
-137
lines changed

3 files changed

+431
-137
lines changed

docs/frontend/tensorflow.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ Supported Ops
115115

116116
- Abs
117117
- Add
118+
- AddN
118119
- All
119120
- Any
120121
- ArgMax

python/tvm/relay/frontend/tensorflow.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,18 @@ def _impl(inputs, attr, params):
13181318
return AttrCvt('ndarray_size', transforms={'out_type' : 'dtype'})(inputs, new_attr)
13191319
return _impl
13201320

1321+
def _add_n():
1322+
def _impl(inputs, attr, params):
1323+
if not isinstance(inputs, tuple):
1324+
inputs = list(inputs)
1325+
assert len(inputs) > 0, "add_n take >=1 inputs, but 0 given."
1326+
_res = inputs[0]
1327+
for each in inputs[1:]:
1328+
_res = _op.add(_res, each)
1329+
return _res
1330+
return _impl
1331+
1332+
13211333
# compatible operators that do NOT require any conversion.
13221334
_identity_list = []
13231335

@@ -1329,6 +1341,7 @@ def _impl(inputs, attr, params):
13291341
_convert_map = {
13301342
'Abs' : AttrCvt('abs'),
13311343
'Add' : _elemwise('add'),
1344+
'AddN' : _add_n(),
13321345
'All' : _reduce('all'),
13331346
'Any' : _reduce('any'),
13341347
'ArgMax' : _argx(_op.argmax, 'argmax'),

0 commit comments

Comments
 (0)