Example #1
0
    def testDoNotCompileScalarConstGraph(self):
        with self.session() as sess:

            def my_graph(a, b):
                with ops.device("/device:IPU:0"):
                    x = math_ops.add(a, b)
                return x

            with ops.device('cpu'):
                a = 2
                b = 3
            out = ipu.ipu_compiler.compile(my_graph, [a, b])
            report = ReportJSON(self, sess)
            report.reset()

            result = sess.run(out)

            report.parse_log()
            report.assert_contains_no_compile_event()

            self.assertEqual(result, [5])
Example #2
0
    def testDoNotCompileScalarElementWiseGraphWithParameter(self):
        with self.session() as sess:

            def my_graph(a, b):
                with ops.device("/device:IPU:0"):
                    x = math_ops.add(a, b)
                return x

            with ops.device('cpu'):
                a = array_ops.placeholder(np.int32, name="a")
                b = array_ops.placeholder(np.int32, name="b")

            out = ipu.ipu_compiler.compile(my_graph, [a, b])
            report = ReportJSON(self, sess)
            report.reset()

            fd = {a: np.int32(2), b: np.int32(3)}
            result = sess.run(out, fd)

            report.parse_log()
            report.assert_contains_no_compile_event()

            self.assertAllClose(result, [5])