@@ -73,6 +73,10 @@ TEST(TensorCopy, Tensor) {
7373 // CPU Tensor to GPU Tensor
7474 auto gpu_place = new platform::CUDAPlace (0 );
7575 platform::CUDADeviceContext gpu_ctx (*gpu_place);
76+ gpu_ctx.SetAllocator (paddle::memory::allocation::AllocatorFacade::Instance ()
77+ .GetAllocator (*gpu_place, gpu_ctx.stream ())
78+ .get ());
79+ gpu_ctx.PartialInitWithAllocator ();
7680 TensorCopy (src_tensor, *gpu_place, gpu_ctx, &gpu_tensor);
7781
7882 // GPU Tensor to CPU Tensor
@@ -166,6 +170,10 @@ TEST(TensorFromVector, Tensor) {
166170 gpu_tensor.Resize (paddle::framework::make_ddim ({3 , 3 }));
167171 auto gpu_place = new paddle::platform::CUDAPlace ();
168172 paddle::platform::CUDADeviceContext gpu_ctx (*gpu_place);
173+ gpu_ctx.SetAllocator (paddle::memory::allocation::AllocatorFacade::Instance ()
174+ .GetAllocator (*gpu_place, gpu_ctx.stream ())
175+ .get ());
176+ gpu_ctx.PartialInitWithAllocator ();
169177 paddle::framework::TensorFromVector<int >(src_vec, gpu_ctx, &gpu_tensor);
170178 // Copy from GPU to CPU tensor for comparison
171179 paddle::framework::TensorCopy (gpu_tensor, *cpu_place, gpu_ctx, &dst_tensor);
@@ -230,6 +238,10 @@ TEST(TensorToVector, Tensor) {
230238 paddle::framework::Tensor gpu_tensor;
231239 paddle::platform::CUDAPlace place;
232240 paddle::platform::CUDADeviceContext gpu_ctx (place);
241+ gpu_ctx.SetAllocator (paddle::memory::allocation::AllocatorFacade::Instance ()
242+ .GetAllocator (place, gpu_ctx.stream ())
243+ .get ());
244+ gpu_ctx.PartialInitWithAllocator ();
233245 paddle::framework::TensorFromVector<int >(src_vec, gpu_ctx, &gpu_tensor);
234246
235247 std::vector<int > dst;
@@ -267,6 +279,10 @@ TEST(TensorToVector, Tensor_bool) {
267279 paddle::framework::Tensor gpu_tensor;
268280 paddle::platform::CUDAPlace place;
269281 paddle::platform::CUDADeviceContext gpu_ctx (place);
282+ gpu_ctx.SetAllocator (paddle::memory::allocation::AllocatorFacade::Instance ()
283+ .GetAllocator (place, gpu_ctx.stream ())
284+ .get ());
285+ gpu_ctx.PartialInitWithAllocator ();
270286 paddle::framework::TensorFromVector<bool >(src_vec, gpu_ctx, &gpu_tensor);
271287
272288 std::vector<bool > dst;
@@ -493,6 +509,10 @@ TEST(Tensor, FromAndToStream) {
493509
494510 auto gpu_place = new platform::CUDAPlace ();
495511 platform::CUDADeviceContext gpu_ctx (*gpu_place);
512+ gpu_ctx.SetAllocator (paddle::memory::allocation::AllocatorFacade::Instance ()
513+ .GetAllocator (*gpu_place, gpu_ctx.stream ())
514+ .get ());
515+ gpu_ctx.PartialInitWithAllocator ();
496516
497517 TensorCopy (src_tensor, *gpu_place, gpu_ctx, &gpu_tensor);
498518
0 commit comments