@@ -0,0 +1,2227 @@
+import unittest%0Aimport sys%0Aimport ctypes%0Aimport array%0Afrom blaze.blaze_kernels import BlazeElementKernel%0Aimport llvm.core as lc%0Aimport llvm%0A%0Amod = lc.Module.new('simple')%0A%0Adef create_func(mod):%0A    try:%0A        func = mod.get_function_named('add')%0A        return func%0A    except llvm.LLVMException:%0A        pass%0A    double = lc.Type.double()%0A    func_type = lc.Type.function(double, %5Bdouble, double%5D)%0A    func = lc.Function.new(mod, func_type, name='add')%0A    block = func.append_basic_block('entry')%0A    builder = lc.Builder.new(block)%0A    val = builder.fadd(func.args%5B0%5D, func.args%5B1%5D)%0A    builder.ret(val)%0A    return func%0A%0A%0Aclass TestKernelLift(unittest.TestCase):%0A    def test_basic_scalar_lift(self):%0A        addkernel = BlazeElementKernel(create_func(mod))%0A        res = addkernel.lift(1, 'C')%0A        cfunc = res.ctypes_func%0A        cb = ctypes.byref%0A        data = array.array('d',range(100))%0A        odata = array.array('d', %5B0%5D*100)%0A        struct = cfunc.argtypes%5B0%5D._type_%0A%0A        def _convert(arr):%0A            address, count = arr.buffer_info()%0A            buff = ctypes.cast(address, ctypes.POINTER(ctypes.c_double))%0A            shape = (ctypes.c_ssize_t * 1)(count)%0A            val = struct(buff, shape)%0A            return val%0A%0A        val = _convert(data)%0A        out = _convert(odata)%0A        cfunc(cb(val), cb(val), cb(out))%0A        assert all((outd == ind + ind) for ind, outd in zip(data, odata))%0A%0A    def test_scalar_lift_to2d(self):%0A        addkernel = BlazeElementKernel(create_func(mod))%0A        res = addkernel.lift(2, 'C')%0A        cfunc = res.ctypes_func%0A        cb = ctypes.byref%0A        data = array.array('d',range(150))%0A        odata = array.array('d', %5B0%5D*150)%0A        struct = cfunc.argtypes%5B0%5D._type_%0A%0A        def _convert(arr):%0A            address, count = arr.buffer_info()%0A            buff = ctypes.cast(address, ctypes.POINTER(ctypes.c_double))%0A            shape = (ctypes.c_ssize_t * 2)(10, count / 10)%0A            val = struct(buff, shape)%0A            return val%0A%0A        val = _convert(data)%0A        out = _convert(odata)%0A        cfunc(cb(val), cb(val), cb(out))%0A        assert all((outd == ind + ind) for ind, outd in zip(data, odata))%0A%0A%0Aif __name__ == '__main__':%0A    unittest.main()

Add test for lifting.