MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testContext

Method testContext

tensorflow/python/eager/core_test.py:330–372  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

328 ops.disable_tensor_equality()
329
330 def testContext(self):
331 ctx = context.Context()
332 self.assertTrue(ctx.executing_eagerly())
333
334 self.assertEqual('', ctx.scope_name)
335 ctx.scope_name = 'foo'
336 self.assertEqual('foo', ctx.scope_name)
337
338 self.assertEqual(context.SYNC, ctx.execution_mode)
339 ctx.execution_mode = context.ASYNC
340 self.assertEqual(context.ASYNC, ctx.execution_mode)
341 ctx.execution_mode = context.SYNC
342 self.assertEqual(context.SYNC, ctx.execution_mode)
343
344 self.assertIsNone(ctx.summary_writer)
345 ctx.summary_writer = 'mock'
346 self.assertEqual('mock', ctx.summary_writer)
347 self.assertIsNone(ctx.summary_recording)
348 ctx.summary_recording = 'mock'
349 self.assertEqual('mock', ctx.summary_recording)
350 self.assertIsNone(ctx.summary_step)
351 ctx.summary_step = 'mock'
352 self.assertEqual('mock', ctx.summary_step)
353
354 self.assertEqual('', ctx.device_name)
355 self.assertEqual(ctx.device_name, ctx.device_spec.to_string())
356 with ctx.device('GPU:0'):
357 self.assertEqual('/job:localhost/replica:0/task:0/device:GPU:0',
358 ctx.device_name)
359 self.assertEqual(ctx.device_name, ctx.device_spec.to_string())
360 with ctx.device(None):
361 self.assertEqual('', ctx.device_name)
362 self.assertEqual(ctx.device_name, ctx.device_spec.to_string())
363 with ctx.device('CPU:0'):
364 self.assertEqual('/job:localhost/replica:0/task:0/device:CPU:0',
365 ctx.device_name)
366 self.assertEqual(ctx.device_name, ctx.device_spec.to_string())
367
368 has_cpu_device = False
369 for x in ctx.devices():
370 has_cpu_device = has_cpu_device or 'CPU' in x
371 self.assertTrue(has_cpu_device)
372 del ctx
373
374 def testAsyncBasic(self):
375 ctx = context.Context(execution_mode=context.ASYNC)

Callers

nothing calls this directly

Calls 5

executing_eagerlyMethod · 0.95
deviceMethod · 0.95
devicesMethod · 0.95
ContextMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected