(self)
| 227 | |
| 228 | @test_util.enable_control_flow_v2 |
| 229 | def testMap(self): |
| 230 | if is_compile_on_demand(): |
| 231 | self.skipTest("list_ops are not supported in cpu_ondemand") |
| 232 | with self.session(), self.test_scope(): |
| 233 | xla_context = control_flow_ops.XLAControlFlowContext() |
| 234 | xla_context.Enter() |
| 235 | nums = [1, 2, 3, 4, 5, 6] |
| 236 | elems = constant_op.constant(nums, name="data") |
| 237 | r = map_fn.map_fn(lambda x: math_ops.multiply(math_ops.add(x, 3), 2), |
| 238 | elems) |
| 239 | self.assertAllEqual(r, np.array([(x + 3) * 2 for x in nums])) |
| 240 | xla_context.Exit() |
| 241 | |
| 242 | |
| 243 | def is_compile_on_demand(): |
nothing calls this directly
no test coverage detected