From 5cb729ec48e5e78e9a6a3b78ededa89017817fcd Mon Sep 17 00:00:00 2001
From: Haichen Shen <shenhaichen@gmail.com>
Date: Fri, 21 Dec 2018 09:44:26 -0800
Subject: [PATCH] [BUGFIX] Seg fault in memory planing for symbolic shape
 (#2317)

---
 src/relay/backend/graph_plan_memory.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/relay/backend/graph_plan_memory.cc b/src/relay/backend/graph_plan_memory.cc
index 4a5aa4ea0..e17c7a683 100644
--- a/src/relay/backend/graph_plan_memory.cc
+++ b/src/relay/backend/graph_plan_memory.cc
@@ -196,7 +196,7 @@ class StorageAllocator : public StorageAllocaBaseVisitor {
  protected:
   using StorageAllocaBaseVisitor::VisitExpr_;
   // override create token by getting token as prototype requirements.
-  void CreateToken(const ExprNode* op, bool can_realloc)  final {
+  void CreateToken(const ExprNode* op, bool can_realloc) final {
     CHECK(!token_map_.count(op));
     auto it = prototype_.find(op);
     CHECK(it != prototype_.end());
@@ -253,12 +253,12 @@ class StorageAllocator : public StorageAllocaBaseVisitor {
     size_t size = 1;
     for (IndexExpr dim : ttype->shape) {
       const int64_t* pval = as_const_int(dim);
-      CHECK_GE(*pval, 0) <<
-        "can not allocate memory for tensor with negative shape" <<
-        *pval;
       CHECK(pval != nullptr)
           << "Cannot allocate memory symbolic tensor shape "
           << ttype->shape;
+      CHECK_GE(*pval, 0)
+          << "Cannot allocate memory for tensor with negative shape"
+          << *pval;
       size *= static_cast<size_t>(pval[0]);
     }
     size *= DivRoundUp(ttype->dtype.bits() * ttype->dtype.lanes(), 8);
-- 
GitLab