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] Fix type assignment for 'tf.range' operator #4294

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions python/tvm/relay/frontend/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,14 +1067,15 @@ def _impl(inputs, attr, params):

return _impl


def _range():
def _impl(inputs, attr, params):
start = _get_param(params, inputs[0])[0]
limit = _get_param(params, inputs[1])[0] \
if hasattr(inputs[1], "name_hint") or isinstance(inputs[1], _expr.Constant) \
else params.pop('Rank').asnumpy()[0]
delta = _get_param(params, inputs[2])[0]
dtype = attr['dtype'].name if 'dtype' in attr else "int32"
dtype = attr['Tidx'].name if 'Tidx' in attr else str(start.dtype)
return AttrCvt(
op_name="arange",
ignores=['Tidx'],
Expand All @@ -1084,6 +1085,7 @@ def _impl(inputs, attr, params):
'dtype': dtype})([], attr)
return _impl


def _elu():
def _impl(inputs, attr, params):
dtype = attr['T'].name
Expand Down Expand Up @@ -1194,7 +1196,7 @@ def _impl(inputs, attr, params):
raise tvm.error.OpAttributeInvalid(
'Attribute k must be positive in operator TopKV2')
if attr['sorted'] is False:
raise tvm.error.OpAttributeUnimplemented(
raise tvm.error.OpAttributeUnImplemented(
'Attribute sorted=False is not supported in operator TopKV2')
return AttrCvt(op_name='topk',
ignores=['sorted'],
Expand Down
5 changes: 5 additions & 0 deletions tests/python/frontend/tensorflow/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,11 @@ def test_forward_range():
tf.range(1, 18, 3, name="range")
compare_tf_with_tvm([], [], 'range:0')

"""test type assignment for operator Range"""
tf.reset_default_graph()
tf.range(1, 256 + 1, 1, dtype=tf.float32)
compare_tf_with_tvm([], [], 'range:0')

#######################################################################
# Pad
# ---
Expand Down