Skip to content

Commit

Permalink
add a workaround against that invalid nnabla_pb2.Variable can come (#828
Browse files Browse the repository at this point in the history
)

  - originally,  NnpExpander should be fixed
  • Loading branch information
Ryo Takahashi authored and Ryo Takahashi committed Apr 21, 2018
1 parent 2a658a2 commit d63b8a2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion python/src/nnabla/utils/converter/nnablart/nnb.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,15 @@ def export(self, *args):
index, pointer = self._alloc(data=data)
var.data_index = index
elif v.type == 'Buffer':
var.data_index = (vidx_to_abidx[n] + 1) * -1
# FIXME: remove the following workaround
if n in vidx_to_abidx:
# n which is NOT in vidx_to_abidx can appear
# since NnpExpander doesn't handle --nnp-expand-network correctly
var.data_index = (vidx_to_abidx[n] + 1) * -1
else:
# this var doesn't make sense, but add it
# so that nn_network_t::variables::size is conserved
var.data_index = -1

variable = struct.pack('IiIBi',
var.id,
Expand Down

0 comments on commit d63b8a2

Please sign in to comment.