Tests an operator with compile-time constant and non-constant inputs.
(self)
| 281 | """Tests for auto-compilation on CPU/GPU devices.""" |
| 282 | |
| 283 | def testReshape(self): |
| 284 | """Tests an operator with compile-time constant and non-constant inputs.""" |
| 285 | |
| 286 | with self.session(config=NoRewriteSessionConfig()) as sess: |
| 287 | x = array_ops.placeholder(dtypes.float32) |
| 288 | y = array_ops.placeholder(dtypes.int32) |
| 289 | with jit_scope(): |
| 290 | # Reshape's first argument is non-constant in the JIT, but its second |
| 291 | # (shape) argument will be treated as a compile-time constant for |
| 292 | # each JIT compilation. |
| 293 | # We do not use a tf.const() argument since we want to ensure the |
| 294 | # shape is still a run-time argument to the JIT, and not |
| 295 | # statically known as part of the JIT compilation's input graph. |
| 296 | z = array_ops.reshape(x, y) |
| 297 | run_metadata = config_pb2.RunMetadata() |
| 298 | out = test_utils.RunWithWarmup( |
| 299 | sess, |
| 300 | z, { |
| 301 | x: np.array([1, 2, 3, 4, 5, 6], np.float32), |
| 302 | y: [-1, 3] |
| 303 | }, |
| 304 | run_metadata=run_metadata, |
| 305 | options=config_pb2.RunOptions( |
| 306 | trace_level=config_pb2.RunOptions.FULL_TRACE)) |
| 307 | self.assert_(MetadataHasXlaRunOp(run_metadata)) |
| 308 | self.assertAllClose(np.array([[1, 2, 3], [4, 5, 6]], np.float32), out) |
| 309 | |
| 310 | def testIgnoredArguments(self): |
| 311 | """Tests that JIT computations can ignore formal parameters.""" |
nothing calls this directly
no test coverage detected