コード例 #1
0
    def setUp(self):
        x = tensor.vector("x")
        y = tensor.vector("y")

        ws = Workspace()
        ws[x] = [1, 2]
        ws[y] = [3, 4]
        ws.add_method("f", updates=[(x, y), (y, x)])
        self.foo = x, y, ws
コード例 #2
0
    def setUp(self):
        letters = "xyzabcdefghijklmnopqrstuvw"
        symbols = [tensor.vector(a) for a in letters[: self.n_groups]]
        assert len(symbols) == self.n_groups

        ws = Workspace()
        for i, s in enumerate(symbols):
            ws[s] = range(i, i + self.n_items)
        f = ws.add_method("f", updates=[(s, 2 * s) for s in symbols])
        # XXX set up a new test with this update, because it seems
        # to break the optimizations
        # f = ws.add_method('f', updates=[(s, tensor.log(2 + tensor.cos(s))) for s in symbols])

        ws_shrd = SharedStorageWorkspace(ws)
        f_opt = ws_shrd.compiled_updates["f"]
        self.foo = letters, symbols, ws, ws_shrd