diff --git a/lite/core/mir/memory_optimize_pass.cc b/lite/core/mir/memory_optimize_pass.cc index ee78fac9a88aa339514778dcc03e2c907487fb39..fe2971777c12121d15eb99c4761965a71af2bfc2 100644 --- a/lite/core/mir/memory_optimize_pass.cc +++ b/lite/core/mir/memory_optimize_pass.cc @@ -123,7 +123,8 @@ void MemoryOptimizePass::CollectLifeCycleByDevice( // non-tensor(like tensor_array) variables will not be reused for (auto& node : graph->nodes()) { - if (node.IsArg() && !node.arg()->type->IsTensor()) { + if (node.IsArg() && (node.arg()->type != nullptr) && + !node.arg()->type->IsTensor()) { invalid_var_names.insert(node.arg()->name); } } diff --git a/lite/core/mir/node.h b/lite/core/mir/node.h index e7c44d2be689a9d890158c097e198314413d1ba3..45b15812fadb0789edea3f89fb00b4612bdb010f 100644 --- a/lite/core/mir/node.h +++ b/lite/core/mir/node.h @@ -85,7 +85,7 @@ class Node { struct Arg { std::string name; int id{0}; - const Type* type{}; + const Type* type{nullptr}; // Weight is a special kind of argument, it is marked as weight explicitly // so that some weight related optimization can take place. bool is_weight{false};