issue in NNVM keras frontend

Hi TVM,

When running the TVM keras tutorial, I have the issue std::Bad_alloc. After digging deeper, I found the following in GDB. It seems that the keras frontend can’t convert keras properly as the output of symbols has a negative length (and the counts of some shared_ptr also). Below please find the detail information.

Many thanks!

nnvm::Graph::Graph (this=0x5e320de0) at /root/lijin/tvm/model_parallelism_tvm/nnvm/include/nnvm/graph.h:47
47 class Graph {
(gdb) n
NNGraphCreate (symbol=0x5ef17900, graph=0x7f4cac5e42b8) at /root/lijin/tvm/model_parallelism_tvm/nnvm/src/c_api/c_api_graph.cc:38
38 g->outputs = static_cast<Symbol*>(symbol)->outputs;
(gdb) p symbol
$2 = (SymbolHandle) 0x5ef17900
(gdb) p static_cast<Symbol*>(symbol)->outputs
$3 = std::vector of length -2090415, capacity -66370137 = {{node = std::shared_ptr (count -125990584, weak -125992121) 0x1, index = 0,
version = 0}, {node = std::shared_ptr (count 1421623570, weak 32586) 0x0, index = 1506244328, version = 0}, {
node = std::shared_ptr (count 1421623570, weak 32586) 0x0, index = 0, version = 0}, {
node = <error reading variable: Cannot access memory at address 0x49>, index = 1442377968, version = 32587}, {
node = std::shared_ptr (count -125990584, weak -125992121) 0x1, index = 1506242144, version = 0}, {
node = std::shared_ptr (count 30830, weak -1) 0x59c76e68, index = 64, version = 0}, {
node = std::shared_ptr (count 1429942954, weak 32586) 0x21, index = 1542713328, version = 0}, {
node = <error reading variable: Cannot access memory at address 0x49>, index = 1442377968, version = 32587}, {
node = std::shared_ptr (count -125990584, weak -125992121) 0x1, index = 1543434864, version = 0}, {
node = std::shared_ptr (count 30830, weak -1) 0x5bfef278, index = 405431728, version = 32589}, {
node = std::shared_ptr (count 1423718404, weak 32586) 0x21, index = 1030514020, version = 1635019124}, {
node = <error reading variable: Cannot access memory at address 0x29>, index = 1442505888, version = 32587}, {node = warning: can’t find linker symbol for virtual table for std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>' value warning: found __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<tvm::runtime::CPUDeviceAPI, std::allocatortvm::runtime::CPUDeviceAPI, (__gnu_cxx::_Lock_policy)2> >::max_size() const’ instead
nnvm::Graph::Graph (this=0x5e320de0) at /root/lijin/tvm/model_parallelism_tvm/nnvm/include/nnvm/graph.h:47
47 class Graph {
(gdb) n
NNGraphCreate (symbol=0x5ef17900, graph=0x7f4cac5e42b8) at /root/lijin/tvm/model_parallelism_tvm/nnvm/src/c_api/c_api_graph.cc:38
38 g->outputs = static_cast<Symbol*>(symbol)->outputs;
(gdb) p symbol
$2 = (SymbolHandle) 0x5ef17900
(gdb) p static_cast<Symbol*>(symbol)->outputs
$3 = std::vector of length -2090415, capacity -66370137 = {{node = std::shared_ptr (count -125990584, weak -125992121) 0x1, index = 0,
version = 0}, {node = std::shared_ptr (count 1421623570, weak 32586) 0x0, index = 1506244328, version = 0}, {
node = std::shared_ptr (count 1421623570, weak 32586) 0x0, index = 0, version = 0}, {
node = <error reading variable: Cannot access memory at address 0x49>, index = 1442377968, version = 32587}, {
node = std::shared_ptr (count -125990584, weak -125992121) 0x1, index = 1506242144, version = 0}, {
node = std::shared_ptr (count 30830, weak -1) 0x59c76e68, index = 64, version = 0}, {
node = std::shared_ptr (count 1429942954, weak 32586) 0x21, index = 1542713328, version = 0}, {
node = <error reading variable: Cannot access memory at address 0x49>, index = 1442377968, version = 32587}, {
node = std::shared_ptr (count -125990584, weak -125992121) 0x1, index = 1543434864, version = 0}, {
node = std::shared_ptr (count 30830, weak -1) 0x5bfef278, index = 405431728, version = 32589}, {
node = std::shared_ptr (count 1423718404, weak 32586) 0x21, index = 1030514020, version = 1635019124}, {
node = <error reading variable: Cannot access memory at address 0x29>, index = 1442505888, version = 32587}, {node = warning: can’t find linker symbol for virtual table for std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>' value warning: found __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<tvm::runtime::CPUDeviceAPI, std::allocatortvm::runtime::CPUDeviceAPI, (__gnu_cxx::_Lock_policy)2> >::max_size() const’ instead