Skip to content

Commit

Permalink
使用されていないバッファがあった場合は警告を表示し、途中で落ちないよう修正
Browse files Browse the repository at this point in the history
  • Loading branch information
Masato Hori committed Mar 1, 2018
1 parent 4188279 commit c62fd40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 8 additions & 1 deletion python/src/nnabla/utils/converter/onnx/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,14 @@ def onnx_graph_to_nnp_protobuf(pb, graph):
# This input is a variable
v.type = var_type_buffer
in_list.append(v)
del all_vars[v.name]
if v.name in all_vars:
del all_vars[v.name]
else:
# We come here when a buffer (usually a parameter) is included in
# graph.input and graph.initializer,
# but was not actually used as input for any node.
# No one is using this buffer so we show a warning and ignore it.
logger.warning("Input buffer {} is not used as input for any node.".format(v.name))
for o in graph.output:
v = onnx_value_info_proto_to_variable(o, network)
v.type = var_type_buffer
Expand Down
4 changes: 0 additions & 4 deletions python/test/utils/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,6 @@ def test_onnx_nnp_conversion_resnet50(tmpdir, nnp_fixture):
if show_onnx:
print(model)
img = np.random.rand(1, 3, 224, 224).astype(np.float32)
# Remove an unused buffer with the name of
# 'gpu_0/imagenet1k_blobs_queue_f22e83c9-22cd-4a8b-a66d-113af6b832b4_0'
del model.graph.input[-1]
del model.graph.initializer[-1]
# Remove Softmax and Gemm for now.
# This is temporal
nodes = len(model.graph.node)
Expand Down

0 comments on commit c62fd40

Please sign in to comment.