Skip to content

Commit 39172a9

Browse files
authored
Fix graph rendering issue for tensors with zero dimension size (#6420)
A zero dimension tensor results in a proto with an empty `size` field, as seen below: ``` node { name: "input/b" op: "IO Node" attr { key: "attr" value { s: "" } } attr { key: "_output_shapes" value { list { shape { dim { size: 1 } dim { <<< } } } } } } ``` This results in `dim.size` returning null for these particular cases, breaking graph rendering. We update to default the null case to 0. Fixes #6418
1 parent 7630e53 commit 39172a9

File tree

1 file changed

+4
-1
lines changed
  • tensorboard/plugins/graph/tf_graph_common

1 file changed

+4
-1
lines changed

tensorboard/plugins/graph/tf_graph_common/graph.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,10 @@ function extractOutputShapes(
879879
// into a number.
880880
return shape.dim.map((dim) => {
881881
// Size can be -1 if this particular dimension is unknown.
882-
return dim.size;
882+
// If we actually have a 0-dimension tensor `dim.size` returns null,
883+
// so we default to 0 in this case to avoid upstream null-handling
884+
// issues.
885+
return dim.size || 0;
883886
});
884887
});
885888
// Since we already processed it, remove the entry from the attribute

0 commit comments

Comments
 (0)