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

Method testShape

tensorflow/compiler/tests/eager_test.py:196–221  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

194 # are distincts from tf2xla kernels.
195
196 def testShape(self):
197 def const(value):
198 return array_ops.shape(
199 constant_op.constant(value)).numpy()
200
201 def ones(value):
202 return array_ops.shape(
203 array_ops.ones(value)).numpy()
204
205 with self.test_scope():
206 # Shapes of directly constructed tensors
207 self.assertAllEqual([], const(3))
208 self.assertAllEqual([3], const([1.0, 2.0, 3.0]))
209 self.assertAllEqual([2, 2], const([[1.0, 2.0], [3.0, 4.0]]))
210 self.assertAllEqual([2, 1, 2], const([[[1.0, 2.0]], [[3.0, 4.0]]]))
211
212 # Shapes of tensors created by op running on device
213 # We make this distinction because directly constructed tensors
214 # are treated differently in a few places that can influence shape:
215 # - they always have on_host_tensor
216 # - they and their shapes can be cached
217 # - they end up on device via a copy, instead of as program output
218 self.assertAllEqual([], ones([]))
219 self.assertAllEqual([3], ones([3]))
220 self.assertAllEqual([2, 2], ones([2, 2]))
221 self.assertAllEqual([2, 1, 2], ones([2, 1, 2]))
222
223 def testShapeN(self):
224 with self.test_scope():

Callers

nothing calls this directly

Calls 3

onesFunction · 0.50
test_scopeMethod · 0.45
assertAllEqualMethod · 0.45

Tested by

no test coverage detected