-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Graph Visualization: Added the General Chunk algorithm, multiple stacks
to address debug markers, colors for nodes and unit testing. General Chunk Algorithm: This algorithm creates super-nodes to avoid display more than a fix number of nodes in every level. For every level, the nodes are grouped in super-nodes based on command names, then if the numbers of nodes exceed the maximum limit, chunks are created, and if in the new chunks the numbers of nodes exceed the maximum limit, then new chunks are created and so on. Results: Applying the General Chunk Algorithm is possible to visualize graphs containing millions of nodes and edges. The time is reduced from ~20 seconds to ~2 seconds to expand super-nodes in Tensorboard. Note1: All "op" attribute for nodes in pbtxt format must be different, since the find_similar_subgraphs algorithm from Tensorboard computes the similarity between nodes with same "op". Note2: Adding colors to the nodes increase the time for expand super-nodes.
- Loading branch information
1 parent
8488938
commit a59acde
Showing
11 changed files
with
1,065 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright (C) 2018 Google Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package api | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestLabel(t *testing.T) { | ||
|
||
label := &Label{} | ||
label.PushBack("name1", 1) | ||
label.PushBack("name2", 2) | ||
label.PushBack("name3", 3) | ||
label.PushBack("name4", 4) | ||
label.PushFront("name5", 5) | ||
label.PushFront("name6", 6) | ||
|
||
obtainedLabel := label | ||
|
||
wantedLabel := &Label{ | ||
LevelsName: []string{"name6", "name5", "name1", "name2", "name3", "name4"}, | ||
LevelsID: []int{6, 5, 1, 2, 3, 4}, | ||
} | ||
|
||
if !reflect.DeepEqual(wantedLabel, obtainedLabel) { | ||
t.Errorf("The Label is different\n") | ||
t.Errorf("Wanted %v, obtained %v\n", wantedLabel, obtainedLabel) | ||
} | ||
|
||
label.Insert(0, "name10", 10) | ||
label.Insert(5, "name11", 11) | ||
label.Insert(5, "name12", 12) | ||
|
||
wantedLabel = &Label{ | ||
LevelsName: []string{"name10", "name6", "name5", "name1", "name2", "name12", "name11", "name3", "name4"}, | ||
LevelsID: []int{10, 6, 5, 1, 2, 12, 11, 3, 4}, | ||
} | ||
|
||
if !reflect.DeepEqual(wantedLabel, obtainedLabel) { | ||
t.Errorf("The Label is different\n") | ||
t.Errorf("Wanted %v, obtained %v\n", wantedLabel, obtainedLabel) | ||
} | ||
|
||
obtainedLabel.PushBackLabel(obtainedLabel) | ||
wantedLabel = &Label{ | ||
LevelsName: []string{"name10", "name6", "name5", "name1", "name2", "name12", "name11", "name3", "name4", | ||
"name10", "name6", "name5", "name1", "name2", "name12", "name11", "name3", "name4"}, | ||
LevelsID: []int{10, 6, 5, 1, 2, 12, 11, 3, 4, | ||
10, 6, 5, 1, 2, 12, 11, 3, 4}, | ||
} | ||
|
||
if !reflect.DeepEqual(wantedLabel, obtainedLabel) { | ||
t.Errorf("The Label is different\n") | ||
t.Errorf("Wanted %v, obtained %v\n", wantedLabel, obtainedLabel) | ||
} | ||
|
||
if obtainedLabel.GetCommandName() != "name4" { | ||
t.Errorf("The command name is different") | ||
} | ||
if obtainedLabel.GetCommandId() != 4 { | ||
t.Errorf("The command ID is different") | ||
} | ||
if obtainedLabel.GetTopLevelName() != "name10" { | ||
t.Errorf("The top name is different") | ||
} | ||
if obtainedLabel.GetTopLevelID() != 10 { | ||
t.Errorf("The top ID is different") | ||
} | ||
wantedLabelAsAString := "name1010/name66/name55/name11/name22/name1212/name1111/name33/name44/" + | ||
"name1010/name66/name55/name11/name22/name1212/name1111/name33/name44" | ||
if obtainedLabel.GetLabelAsAString() != wantedLabelAsAString { | ||
t.Errorf("The LabelAsAString is different") | ||
t.Errorf("Wanted %v, obtained %v\n", wantedLabelAsAString, obtainedLabel.GetLabelAsAString()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.