Ejemplo n.º 1
0
 def testExecuteBasicAsync(self):
     with context.execution_mode(context.ASYNC):
         three = constant_op.constant(3)
         five = constant_op.constant(5)
         product = execute(b'Mul',
                           num_outputs=1,
                           inputs=[three, five],
                           attrs=('T', three.dtype.as_datatype_enum))[0]
         self.assertAllEqual(15, product)
     # Error: Invalid arguments
     context.set_execution_mode(context.ASYNC)
     with self.assertRaises(errors.InvalidArgumentError):
         execute(b'MatMul',
                 num_outputs=1,
                 inputs=[three, five],
                 attrs=('transpose_a', False, 'transpose_b', False, 'T',
                        three.dtype.as_datatype_enum))
         context.async_wait()
     context.async_clear_error()
     context.context().execution_mode = context.SYNC
Ejemplo n.º 2
0
 def testExecuteBasicAsync(self):
   with context.execution_mode(context.ASYNC):
     three = constant_op.constant(3)
     five = constant_op.constant(5)
     product = execute(
         b'Mul',
         num_outputs=1,
         inputs=[three, five],
         attrs=('T', three.dtype.as_datatype_enum))[0]
     self.assertAllEqual(15, product)
   # Error: Invalid arguments
   context.set_execution_mode(context.ASYNC)
   with self.assertRaises(errors.InvalidArgumentError):
     execute(
         b'MatMul',
         num_outputs=1,
         inputs=[three, five],
         attrs=('transpose_a', False, 'transpose_b', False, 'T',
                three.dtype.as_datatype_enum))
     context.async_wait()
   context.async_clear_error()
   context.set_execution_mode(context.SYNC)