未验证 提交 3ab19ab4 编写于 作者: Y YuhangLi 提交者: GitHub

[CUSTOM DEVICE]analysis predictor custom device support (#52015)

* [CUSTOM DEVICE]analysis predictor custom device support

* del debug log
上级 5d503ec9
......@@ -59,6 +59,9 @@ PassStrategy *AnalysisConfig::pass_builder() const {
} else if (use_ipu_) {
LOG(INFO) << "Create IPU IR passes";
pass_builder_.reset(new IpuPassStrategy);
} else if (use_custom_device_) {
LOG(INFO) << "Create CUSTOM DEVICE IR passes";
pass_builder_.reset(new CustomDevicePassStrategy);
} else {
LOG(INFO) << "Create CPU IR passes";
pass_builder_.reset(new CpuPassStrategy);
......@@ -555,6 +558,9 @@ AnalysisConfig::AnalysisConfig(const AnalysisConfig &other) {
} else if (use_xpu_) {
pass_builder_.reset(new XpuPassStrategy(
*static_cast<XpuPassStrategy *>(other.pass_builder())));
} else if (use_custom_device_) {
pass_builder_.reset(new CustomDevicePassStrategy(
*static_cast<CustomDevicePassStrategy *>(other.pass_builder())));
} else if (use_npu_) {
pass_builder_.reset(new NpuPassStrategy(
*static_cast<NpuPassStrategy *>(other.pass_builder())));
......
......@@ -239,10 +239,28 @@ bool PaddleTensorToLoDTensor(const PaddleTensor &pt,
#else
PADDLE_THROW(paddle::platform::errors::Fatal(
"Not compile with XPU, should not reach here."));
#endif
} else if (platform::is_custom_place(place)) {
#ifdef PADDLE_WITH_CUSTOM_DEVICE
paddle::platform::DeviceContextPool &pool =
paddle::platform::DeviceContextPool::Instance();
auto custom_place = place;
auto *dev_ctx = static_cast<const paddle::platform::CustomDeviceContext *>(
pool.Get(custom_place));
memory::Copy(custom_place,
static_cast<void *>(input_ptr),
platform::CPUPlace(),
pt.data.data(),
pt.data.length(),
dev_ctx->stream());
#else
PADDLE_THROW(paddle::platform::errors::Fatal(
"Not compile with CUSTOM_DEVICE, should not reach here."));
#endif
} else {
PADDLE_THROW(paddle::platform::errors::InvalidArgument(
"The analysis predictor supports CPU, GPU and XPU now."));
"The analysis predictor supports CPU, GPU, XPU and CUSTOM_DEVICE "
"now."));
}
// TODO(Superjomn) Low performance, need optimization for heavy LoD copy.
framework::LoD lod;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册