Skip to content

Commit

Permalink
[XPU] fc pass and delete pass nodes check (#60314)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitliuyf authored Jan 11, 2024
1 parent ccf7bd4 commit 839b682
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions paddle/fluid/framework/ir/xpu/delete_isolated_node_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void DeleteIsolatedNodePass::CollectReservedPersistableNodeNames(
std::unordered_set<std::string>* reserved_persistable_node_names) const {
for (auto* node : graph->Nodes()) {
if (!node || node->Name() == "fetch" || node->Name() == "feed") continue;
if (!node->IsVar() || !node->Var()->Persistable()) continue;
if (!node->IsVar() || !node->Var() || !node->Var()->Persistable()) continue;
for (auto* out_node : node->outputs) {
auto op_type = out_node->Op()->Type();
if (control_flow_op_input_map_.count(op_type) == 0) {
Expand Down Expand Up @@ -135,7 +135,7 @@ int DeleteIsolatedNodePass::RemoveIsolatedNodes(
const std::unordered_set<ir::Node*> nodes = graph->Nodes();
for (auto* node : nodes) {
if (!node || node->Name() == "fetch" || node->Name() == "feed") continue;
if (!node->IsVar() || !node->Var()->Persistable()) continue;
if (!node->IsVar() || !node->Var() || !node->Var()->Persistable()) continue;
auto name = node->Var()->Name();
if (reserved_persistable_node_names.count(name) > 0) continue;
delete_nodes.insert(node);
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/framework/ir/xpu/pass_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int ConvertActivationType(std::string act_type) {

Node* FindNodeWithName(Graph* graph, std::string name) {
for (auto* node : graph->Nodes()) {
if (node->IsVar() && node->Var()->Name() == name) {
if (node->IsVar() && node->Var() && node->Var()->Name() == name) {
return node;
}
}
Expand Down

0 comments on commit 839b682

Please sign in to comment.