未验证 提交 4eeda9d6 编写于 作者: Z Zeng Jinle 提交者: GitHub

fix tensor_util, test=develop (#20699)

上级 ab575de7
......@@ -281,12 +281,15 @@ TEST(TensorFromDLPack, Tensor) {
// Copy to GPUTensor
gpu_tensor.Resize(paddle::framework::make_ddim({3, 3}));
paddle::platform::CUDAPlace gpu_place;
paddle::platform::CUDADeviceContext gpu_ctx(gpu_place);
auto& gpu_ctx =
*paddle::platform::DeviceContextPool::Instance().GetByPlace(gpu_place);
paddle::framework::TensorFromVector<int>(src_vec, gpu_ctx, &gpu_tensor);
gpu_ctx.Wait();
paddle::framework::DLPackTensor dlpack_tensor(gpu_tensor, 1);
paddle::framework::TensorFromDLPack(dlpack_tensor, &gpu_tensor_from_dlpack);
gpu_ctx.Wait();
// Copy from GPU to CPU tensor for comparison
paddle::framework::TensorCopy(gpu_tensor_from_dlpack, cpu_place, gpu_ctx,
&dst_tensor);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册