MCPcopy Create free account
hub / github.com/tensorflow/tensorboard / build

Function build

tensorboard/plugins/graph/tf_graph_common/graph.ts:1018–1277  ·  view source on GitHub ↗
(
  graphDef: tf_graph_proto.GraphDef,
  params: BuildParams,
  tracker: ProgressTracker
)

Source from the content-addressed store, hash-verified

1016 },
1017};
1018export function build(
1019 graphDef: tf_graph_proto.GraphDef,
1020 params: BuildParams,
1021 tracker: ProgressTracker
1022): Promise<SlimGraph> {
1023 /**
1024 * A dictionary that maps each in-embedding node name to the node
1025 * object.
1026 */
1027 let inEmbedding: {
1028 [nodeName: string]: OpNode;
1029 } = {};
1030 /**
1031 * A dictionary that maps each out-embedding node name to the node
1032 * object.
1033 */
1034 let outEmbedding: {
1035 [nodeName: string]: OpNode;
1036 } = {};
1037 /**
1038 * A dictionary that maps each node name to an array of the node's
1039 * out-embedding node label objects.
1040 */
1041 let outEmbeddings: {
1042 [inputName: string]: OpNode[];
1043 } = {};
1044 let isInEmbeddedPred = getEmbedPredicate(params.inEmbeddingTypes);
1045 let isOutEmbeddedPred = getEmbedPredicate(params.outEmbeddingTypes);
1046 let embeddingNodeNames: string[] = [];
1047 let rawNodes = graphDef.node;
1048 /**
1049 * A list of all the non-embedding node names which appear in the processed
1050 * list of raw nodes. Here we pre-allocate enough room for all the rawNodes,
1051 * even though there will some number of embeddings. The excess array length
1052 * is spliced off later.
1053 *
1054 * Experimentation shows that around 30% of the array will go unused, and
1055 * even for very large networks that amounts to less than 10k spaces.
1056 */
1057 let nodeNames = new Array<string>(rawNodes.length);
1058 return tf_graph_util
1059 .runAsyncTask(
1060 'Normalizing names',
1061 30,
1062 () => {
1063 let opNodes = new Array<OpNode>(rawNodes.length);
1064 let index = 0;
1065 const processRawNode = (rawNode) => {
1066 let opNode = new OpNodeImpl(rawNode);
1067 if (isInEmbeddedPred(opNode)) {
1068 embeddingNodeNames.push(opNode.name);
1069 inEmbedding[opNode.name] = opNode;
1070 return opNode;
1071 }
1072 if (isOutEmbeddedPred(opNode)) {
1073 embeddingNodeNames.push(opNode.name);
1074 outEmbedding[opNode.name] = opNode;
1075 _.each(opNode.inputs, (input) => {

Callers

nothing calls this directly

Calls 4

getEmbedPredicateFunction · 0.85
mapStrictHierarchyFunction · 0.85
addEdgeToGraphFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…