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

[ Relay ][ Frontend ][ Tensorflow ]add op add_n to relay/frontend/tensorflow.py #4181

Merged
merged 16 commits into from
Nov 1, 2019
13 changes: 13 additions & 0 deletions python/tvm/relay/frontend/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,18 @@ def _impl(inputs, attr, params):
return AttrCvt('ndarray_size', transforms={'out_type' : 'dtype'})(inputs, new_attr)
return _impl

def _add_n():
def _impl(inputs, attr, params):
if not isinstance(inputs, tuple):
inputs = list(inputs)
assert len(inputs) > 0, "add_n take >=1 inputs, but 0 given."
_res = inputs[0]
for each in inputs[1:]:
_res = _op.add(_res, each)
return _res
return _impl


# compatible operators that do NOT require any conversion.
_identity_list = []

Expand All @@ -1323,6 +1335,7 @@ def _impl(inputs, attr, params):
_convert_map = {
'Abs' : AttrCvt('abs'),
'Add' : _elemwise('add'),
'AddN' : _add_n(),
KimBioInfoStudio marked this conversation as resolved.
Show resolved Hide resolved
'All' : _reduce('all'),
'ArgMax' : _argx(_op.argmax, 'argmax'),
'ArgMin' : _argx(_op.argmin, 'argmin'),
Expand Down
Loading