Skip to content

Commit 9b3ae10

Browse files
authored
Merge pull request #331 from onnx/gs/fix-bn
removed train outputs from bn if they are not connected
2 parents 5810313 + 50259c9 commit 9b3ae10

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tf2onnx/tfonnx.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,13 @@ def fused_batchnorm_op7(ctx, node, name, args):
13331333
# a: data_format, epsilon, is_training
13341334
# onnx inputs: X, scale, B, mean, variance, attributes: epsilon, momentum=0.9, spatial : 1
13351335
# output: y, mean, var, savedmean, savedvar,
1336+
1337+
# detach unused outputs. While we could let the unused outputs dangle,
1338+
# some runtimes like pytorch/caffe2 do complain about it.
1339+
consumers = [ctx.find_output_consumers(output_name) for output_name in node.output[1:]]
1340+
if not any(consumers):
1341+
del node.output[1:]
1342+
13361343
nodes = conv_convert_inputs(ctx, node, with_kernel=False)
13371344
scale_shape = ctx.get_shape(node.input[1])
13381345
mean_shape = ctx.get_shape(node.input[3])

0 commit comments

Comments
 (0)