MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testHigherRank

Method testHigherRank

tensorflow/compiler/tests/gather_test.py:112–127  ·  view source on GitHub ↗

Check that scalar and empty indices shapes work as well.

(self)

Source from the content-addressed store, hash-verified

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():

Callers

nothing calls this directly

Calls 9

_buildParamsMethod · 0.95
sessionMethod · 0.45
test_scopeMethod · 0.45
placeholderMethod · 0.45
constantMethod · 0.45
gatherMethod · 0.45
runMethod · 0.45
takeMethod · 0.45
assertAllEqualMethod · 0.45

Tested by

no test coverage detected