(compiled)
| 430 | """Tests that the backprop function is properly compiled.""" |
| 431 | |
| 432 | def _Run(compiled): |
| 433 | |
| 434 | @function.Defun(compiled=compiled) |
| 435 | def Forward(x): |
| 436 | return math_ops.log(x) |
| 437 | |
| 438 | g = ops.Graph() |
| 439 | with g.as_default(): |
| 440 | x = array_ops.placeholder(dtypes.float32) |
| 441 | y = Forward(x) |
| 442 | dx, = gradients_impl.gradients(y, [x], 1.0) |
| 443 | |
| 444 | cfg = NoRewriteSessionConfig() |
| 445 | cfg.graph_options.optimizer_options.opt_level = ( |
| 446 | config_pb2.OptimizerOptions.L1) |
| 447 | cfg.graph_options.optimizer_options.do_function_inlining = True |
| 448 | with session_lib.Session(graph=g, config=cfg) as sess: |
| 449 | run_metadata = config_pb2.RunMetadata() |
| 450 | dx_val = test_utils.RunWithWarmup( |
| 451 | sess, |
| 452 | dx, |
| 453 | feed_dict={x: 100.}, |
| 454 | run_metadata=run_metadata, |
| 455 | options=config_pb2.RunOptions( |
| 456 | trace_level=config_pb2.RunOptions.FULL_TRACE)) |
| 457 | self.assertAllClose(dx_val, 0.01) |
| 458 | return RunMetadataLabels(run_metadata) |
| 459 | |
| 460 | # SymGrad[f=log(x)](x, dy) = 1/x * dy |
| 461 | # |
nothing calls this directly
no test coverage detected