|
| 1 | +# ============================================================================== |
| 2 | +# Copyright 2018-2019 Intel Corporation |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# ============================================================================== |
| 16 | +"""nGraph TensorFlow bridge gather_nd operation test |
| 17 | +
|
| 18 | +""" |
| 19 | +from __future__ import absolute_import |
| 20 | +from __future__ import division |
| 21 | +from __future__ import print_function |
| 22 | + |
| 23 | +import pytest |
| 24 | + |
| 25 | +import tensorflow as tf |
| 26 | +import os |
| 27 | +import numpy as np |
| 28 | + |
| 29 | +from common import NgraphTest |
| 30 | + |
| 31 | + |
| 32 | +class TestGatherNDOperations(NgraphTest): |
| 33 | + |
| 34 | + def test_gather_nd(self): |
| 35 | + val = tf.placeholder(tf.float32, shape=(5, 10)) |
| 36 | + indices = np.zeros([1, 3, 3, 1], dtype=np.int32) |
| 37 | + out = tf.gather_nd(val, indices, batch_dims=0, name='output') |
| 38 | + |
| 39 | + def run_test(sess): |
| 40 | + return sess.run((out,), |
| 41 | + feed_dict={val: np.arange(50).reshape([5, 10])})[0] |
| 42 | + |
| 43 | + self.with_ngraph(run_test) |
| 44 | + |
| 45 | + assert ( |
| 46 | + self.with_ngraph(run_test) == self.without_ngraph(run_test)).all() |
0 commit comments