(self)
| 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(): |
nothing calls this directly
no test coverage detected