Skip to content

Commit

Permalink
[FRONTEND][TENSORFLOW] Fix gather_nd indices (apache#5279)
Browse files Browse the repository at this point in the history
* [FRONTEND][TENSORFLOW] Fix gather_nd indices

* retrigger CI
  • Loading branch information
kazum authored and zhiics committed Apr 17, 2020
1 parent 5f44ba9 commit 1100eb6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion python/tvm/relay/frontend/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,9 +1127,11 @@ def _impl(inputs, attr, params, mod):
def _gather_nd():
"""GatherNd"""
def _impl(inputs, attr, params, mod):
indices_dims = len(_infer_shape(inputs[1], mod))
indices = _op.transpose(inputs[1], axes=[-1] + list(range(indices_dims-1)))
return AttrCvt(op_name="gather_nd",
ignores=['Tindices', 'Tparams',\
'Taxis', '_class'])(inputs, attr)
'Taxis', '_class'])([inputs[0], indices], attr)
return _impl

def _stridedSlice():
Expand Down
6 changes: 3 additions & 3 deletions tests/python/frontend/tensorflow/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -1365,11 +1365,11 @@ def test_forward_gather():

def test_forward_gather_nd():
"""test operator GatherNd"""
np_data = np.random.uniform(1, 100, size=(2, 2)).astype(np.float32)
np_data = np.random.uniform(1, 100, size=(2, 2, 2)).astype(np.float32)
tf.reset_default_graph()
with tf.Graph().as_default():
in_data = tf.placeholder(tf.float32, (2, 2), name="in_data")
tf.gather_nd(in_data, indices=[[1, 0], [0, 1]], name="gather_nd")
in_data = tf.placeholder(tf.float32, (2, 2, 2), name="in_data")
tf.gather_nd(in_data, indices=[[1, 0, 0], [0, 0, 0]], name="gather_nd")
compare_tf_with_tvm([np_data], ['in_data:0'], 'gather_nd:0')


Expand Down

0 comments on commit 1100eb6

Please sign in to comment.