test_primitives.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:quantumsim 作者: brianzi 项目源码 文件源码
def test_sum_bit1(self):

        n = 32
        x = np.random.random(n)
        # x = np.arange(n).astype(np.float64)

        x_gpu = drv.to_device(x)

        trace(
            x_gpu, np.int32(1), block=(
                n, 1, 1), grid=(
                1, 1, 1), shared=8 * 128)

        x2 = drv.from_device_like(x_gpu, x)

        print(x)
        print(x2)

        assert np.allclose(x2[1], np.sum(x[::4]) + np.sum(x[1::4]))
        assert np.allclose(x2[0], np.sum(x[2::4]) + np.sum(x[3::4]))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号