diff --git a/paddle/fluid/inference/api/details/zero_copy_tensor.cc b/paddle/fluid/inference/api/details/zero_copy_tensor.cc index 59ad2c09c0f94d9657c91879956810ccfacbcb35..271b0fcbb7205d58f6818f50c241c807de71ae27 100644 --- a/paddle/fluid/inference/api/details/zero_copy_tensor.cc +++ b/paddle/fluid/inference/api/details/zero_copy_tensor.cc @@ -52,7 +52,7 @@ T *ZeroCopyTensor::mutable_data(PaddlePlace place) { return tensor->mutable_data(platform::CPUPlace()); } case static_cast(PaddlePlace::kGPU): { - return tensor->mutable_data(platform::CUDAPlace()); + return tensor->mutable_data(platform::CUDAPlace(device_)); } default: PADDLE_THROW("Unsupported place: %d", static_cast(place)); diff --git a/paddle/fluid/inference/tests/api/trt_fc_prelu_test.cc b/paddle/fluid/inference/tests/api/trt_fc_prelu_test.cc index cb00c9c21c81ecf07243efb86f57598d3fc3b9bc..37a443e0f6918e18e1410b1a8b6be282d86117c1 100644 --- a/paddle/fluid/inference/tests/api/trt_fc_prelu_test.cc +++ b/paddle/fluid/inference/tests/api/trt_fc_prelu_test.cc @@ -51,6 +51,7 @@ TEST(ZeroCopyTensor, uint8) { input_t->Reshape({batch_size, length}); input_t->copy_from_cpu(input); input_t->type(); + input_t->mutable_data(PaddlePlace::kGPU); ASSERT_TRUE(predictor->ZeroCopyRun()); }