Simplify transfer of costs and gradients from GPU to CPU in ctc test

上级 edd495b3
......@@ -29,15 +29,10 @@ class TestCTC(unittest.TestCase):
cost, grad = train()
cpu_cost = np.empty(shape=cost.shape, dtype=np.float32)
# Transfer costs from GPU memory to host
cost.read(cpu_cost)
cost.sync()
cpu_grad = np.empty(shape=grad.shape, dtype=np.float32)
cpu_cost = np.asarray(cost)
# Transfer gradients from GPU memory to host
grad.read(cpu_grad)
grad.sync()
cpu_grad = np.asarray(grad)
utt.assert_allclose(expected_grads / cost.shape[0], cpu_grad)
utt.assert_allclose(expected_costs, cpu_cost)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论