提交 238a2699 编写于 作者: D dingminghui 提交者: MaxwellDing

fix(place): remove invalid place in subgraph_pass

上级 cf01b626
......@@ -62,15 +62,6 @@ Node* MLUPostprocessPass::InsertCastBefore(const std::string& op_type,
cast_op->Attach(op_desc, inst_node->AsStmt().op()->scope());
auto v_places = graph->valid_places();
for (auto it = v_places.begin(); it != v_places.end();) {
if (it->target != TARGET(kMLU) && it->target != TARGET(kHost) &&
it->target != TARGET(kX86)) {
it = v_places.erase(it);
} else {
++it;
}
}
// create kernels
auto kernels = cast_op->CreateKernels(v_places);
std::vector<std::unique_ptr<KernelBase>> selected_kernels;
......@@ -157,15 +148,6 @@ Node* MLUPostprocessPass::InsertCastAfter(const std::string& op_type,
cast_op->Attach(op_desc, inst_node->AsStmt().op()->scope());
auto v_places = graph->valid_places();
for (auto it = v_places.begin(); it != v_places.end();) {
if (it->target != TARGET(kMLU) && it->target != TARGET(kHost) &&
it->target != TARGET(kX86)) {
it = v_places.erase(it);
} else {
++it;
}
}
// create kernels
auto kernels = cast_op->CreateKernels(v_places);
std::vector<std::unique_ptr<KernelBase>> selected_kernels;
......
......@@ -84,6 +84,20 @@ void RKNPUSubgraphPass::Apply(const std::unique_ptr<SSAGraph>& graph) {
}
void MLUSubgraphPass::Apply(const std::unique_ptr<SSAGraph>& graph) {
#ifdef LITE_WITH_MLU
// remove invalid places, since only support X86, host, MLU
auto v_places = graph->valid_places();
for (auto it = v_places.begin(); it != v_places.end();) {
if (it->target != TARGET(kMLU) && it->target != TARGET(kHost) &&
it->target != TARGET(kX86)) {
it = v_places.erase(it);
} else {
++it;
}
}
graph->SetValidPlaces(v_places);
#endif
std::unordered_set<std::string> supported_lists;
#define USE_SUBGRAPH_BRIDGE(op_type, target) supported_lists.insert(#op_type);
#include "lite/kernels/mlu/bridges/paddle_use_bridges.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册