def testInteractiveSession(self):
     server = self._cached_server
     # Session creation will warn (in C++) that the place_pruned_graph option
     # is not supported, but it should successfully ignore it.
     sess = session.InteractiveSession(server.target)
     c = constant_op.constant(42.0)
     self.assertEqual(42.0, c.eval())
     sess.close()
Ejemplo n.º 2
0
 def testInteractive(self):
     with ops.device('/cpu:0'):
         sess = session.InteractiveSession()
         a = constant_op.constant(1.0, shape=[1, 2])
         b = constant_op.constant(2.0, shape=[2, 3])
         c = math_ops.matmul(a, b)
         self.assertAllEqual([[4.0, 4.0, 4.0]], c.eval())
         d = constant_op.constant([1.0, 2.0, 3.0], shape=[3, 1])
         e = math_ops.matmul(c, d)
         self.assertAllEqual([[24.0]], e.eval())
         sess.close()
Ejemplo n.º 3
0
    def testInteractivePlacePrunedGraph(self):
        sess = session.InteractiveSession()

        # Build a graph that has a bad op in it (no kernel).
        #
        # This test currently does not link in any GPU kernels,
        # which is why placing this is invalid.  If at some point
        # GPU kernels are added to this test, some other different
        # op / device combo should be chosen.
        with ops.device('/gpu:0'):
            a = constant_op.constant(1.0, shape=[1, 2])

        b = constant_op.constant(1.0, shape=[1, 2])

        # Only run the valid op, this should work.
        b.eval()

        with self.assertRaises(errors.InvalidArgumentError):
            a.eval()
        sess.close()
Ejemplo n.º 4
0
    def testInteractiveSessionInit(self):
        """The wrapper should work also on other subclasses of session.Session."""

        TestDebugWrapperSession(session.InteractiveSession(), self._dump_root,
                                self._observer)
Ejemplo n.º 5
0
 def testInteractiveSessionNesting(self):
   sess1 = session.InteractiveSession()
   sess2 = session.InteractiveSession()
   del sess1
   del sess2