From 11e7cbfabb16394e2ac2743e6530f23762b869fd Mon Sep 17 00:00:00 2001 From: Nick Groszewski Date: Tue, 6 Jun 2023 14:49:34 +0000 Subject: [PATCH] Fix graph rendering issue for tensors with zero dimension size 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 to #6418 --- tensorboard/plugins/graph/tf_graph_common/graph.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tensorboard/plugins/graph/tf_graph_common/graph.ts b/tensorboard/plugins/graph/tf_graph_common/graph.ts index 950fb8cdaf..056d35be41 100644 --- a/tensorboard/plugins/graph/tf_graph_common/graph.ts +++ b/tensorboard/plugins/graph/tf_graph_common/graph.ts @@ -879,7 +879,10 @@ function extractOutputShapes( // into a number. return shape.dim.map((dim) => { // Size can be -1 if this particular dimension is unknown. - return dim.size; + // If we actually have a 0-dimension tensor `dim.size` returns null, + // so we default to 0 in this case to avoid upstream null-handling + // issues. + return dim.size || 0; }); }); // Since we already processed it, remove the entry from the attribute