未验证 提交 d71615dc 编写于 作者: C csy0225 提交者: GitHub

shared_external mermory add xpu (#53240)

上级 41e90283
......@@ -345,9 +345,16 @@ void Tensor::ShareExternalData(const T *data,
const_cast<T *>(data), size, paddle::platform::CUDAPlace(device_)),
meta);
*tensor = std::move(dtensor);
} else if (place == PlaceType::kXPU) {
phi::DenseTensor dtensor(
std::make_shared<phi::Allocation>(
const_cast<T *>(data), size, paddle::platform::XPUPlace(device_)),
meta);
*tensor = std::move(dtensor);
} else {
PADDLE_THROW(paddle::platform::errors::InvalidArgument(
"PlaceType must be PlaceType::kCPU or PlaceType::kGPU."));
"PlaceType must be one of [PlaceType::kCPU, PlaceType::kGPU, "
"PlaceType::kXPU]."));
}
}
......
......@@ -81,4 +81,8 @@ void LinspaceKernel(const Context& ctx,
} // namespace phi
PD_REGISTER_KERNEL(
linspace, XPU, ALL_LAYOUT, phi::LinspaceKernel, float, int32_t) {}
linspace, XPU, ALL_LAYOUT, phi::LinspaceKernel, float, int32_t) {
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND);
kernel->InputAt(1).SetBackend(phi::Backend::ALL_BACKEND);
kernel->InputAt(2).SetBackend(phi::Backend::ALL_BACKEND);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册