Check that scalar and empty indices shapes work as well.
(self)
| 110 | self.assertAllEqual(expected, gather_val) |
| 111 | |
| 112 | def testHigherRank(self): |
| 113 | """Check that scalar and empty indices shapes work as well.""" |
| 114 | shape = (2, 1, 3, 2) |
| 115 | for indices_shape in (), (0,), (2, 0), (2, 3): |
| 116 | for dtype in self.all_tf_types: |
| 117 | for axis in 0, 1, 2, 3, -1, -2: |
| 118 | params = self._buildParams(np.random.randn(*shape), dtype) |
| 119 | indices = np.random.randint(shape[axis], size=indices_shape) |
| 120 | with self.session() as sess, self.test_scope(): |
| 121 | tf_params = array_ops.placeholder(dtype=dtype) |
| 122 | tf_indices = constant_op.constant(indices, dtype=dtypes.int32) |
| 123 | gather = array_ops.gather(tf_params, tf_indices, axis=axis) |
| 124 | gather_value = sess.run(gather, feed_dict={tf_params: params}) |
| 125 | gather_np = constant_op.constant( |
| 126 | np.take(params, indices, axis=axis), dtype) |
| 127 | self.assertAllEqual(gather_np, gather_value) |
| 128 | |
| 129 | def testIndicesWithDifferentDimensions(self): |
| 130 | with self.session(): |
nothing calls this directly
no test coverage detected