Skip to content
This repository was archived by the owner on Nov 21, 2023. It is now read-only.

Commit 4840552

Browse files
ashwinbfacebook-github-bot
authored andcommitted
Allow printing net even when output blobs are absent
Reviewed By: rbgirshick Differential Revision: D7491769 fbshipit-source-id: 20d8d1f72a773379a3882b697b574b0b0b4f01d3
1 parent 1d67750 commit 4840552

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/utils/net.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,14 @@ def print_net(model, namescope='gpu_0'):
222222
if output_name.find('grad') >= 0 or output_name.find('__m') >= 0:
223223
continue
224224

225-
output_shape = workspace.FetchBlob(output_name).shape
225+
try:
226+
# Under some conditions (e.g., dynamic memory optimization)
227+
# it is possible that the network frees some blobs when they are
228+
# no longer needed. Handle this case...
229+
output_shape = workspace.FetchBlob(output_name).shape
230+
except BaseException:
231+
output_shape = '<unknown>'
232+
226233
first_blob = True
227234
op_label = op_type + (op_name if op_name == '' else ':' + op_name)
228235
suffix = ' ------- (op: {})'.format(op_label)

0 commit comments

Comments
 (0)