()
| 136 | return tape.gradient(y, x) |
| 137 | |
| 138 | def f(): |
| 139 | with test_util.use_gpu(): |
| 140 | # Randomly construct a 1D shape from [1, 40) |
| 141 | shape = random_ops.random_uniform([1], |
| 142 | minval=1, |
| 143 | maxval=40, |
| 144 | dtype=dtypes.int32) |
| 145 | x32 = random_ops.random_uniform(shape, minval=-1, maxval=1) |
| 146 | x16 = math_ops.cast(x32, dtype=dtypes.float16) |
| 147 | return grad(x32), grad(x16) |
| 148 | |
| 149 | # We're going to ensure that the fp16 and fp32 gradients |
| 150 | # are "close" to each other for ~100 random values. |
nothing calls this directly
no test coverage detected