mapFunction(functionDef) {
          const tfNodes = functionDef.nodeDef;
          const placeholders = [];
          const weights = [];
          let nodes = {};
          if (tfNodes != null) {
              nodes = tfNodes.reduce((map, node) => {
                  map[node.name] = this.mapNode(node);
                  if (node.op === 'Const') {
                      weights.push(map[node.name]);
                  }
                  return map;
              }, {});
          }
          const inputs = [];
          const outputs = [];
          functionDef.signature.inputArg.forEach(arg => {
              const [nodeName,] = getNodeNameAndIndex(arg.name);
              const node = {
                  name: nodeName,
                  op: 'Placeholder',
                  inputs: [],
                  inputNames: [],
                  category: 'graph',
                  inputParams: {},
                  attrParams: { dtype: { value: parseDtypeParam(arg.type), type: 'dtype' } },
                  children: []
              };
              node.signatureKey = arg.name;
              inputs.push(node);
              nodes[nodeName] = node;
          });
          const allNodes = Object.keys(nodes);
          allNodes.forEach(key => {
              const node = nodes[key];
              node.inputNames.forEach(name => {
                  const [nodeName,] = getNodeNameAndIndex(name);
                  node.inputs.push(nodes[nodeName]);
                  nodes[nodeName].children.push(node);
              });
          });
          const returnNodeMap = functionDef.ret;
          functionDef.signature.outputArg.forEach(output => {
              const [nodeName, index] = getNodeNameAndIndex(returnNodeMap[output.name]);
              const node = nodes[nodeName];
              if (node != null) {
                  node.defaultOutput = index;
                  outputs.push(node);
              }
          });
          const signature = this.mapArgsToSignature(functionDef);
          return { nodes, inputs, outputs, weights, placeholders, signature };
      }
// map the TFunctionDef to TFJS graph object
map the TFunctionDef to TFJS graph object
map the TFunctionDef to TFJS graph object
mapFunction(functionDef) {
          const tfNodes = functionDef.nodeDef;
          const placeholders = [];
          const weights = [];
          let nodes = {};
          if (tfNodes != null) {
              nodes = tfNodes.reduce((map, node) => {
                  map[node.name] = this.mapNode(node);
                  if (node.op === 'Const') {
                      weights.push(map[node.name]);
                  }
                  return map;
              }, {});
          }
          const inputs = [];
          const outputs = [];
          functionDef.signature.inputArg.forEach(arg => {
              const [nodeName,] = getNodeNameAndIndex(arg.name);
              const node = {
                  name: nodeName,
                  op: 'Placeholder',
                  inputs: [],
                  inputNames: [],
                  category: 'graph',
                  inputParams: {},
                  attrParams: { dtype: { value: parseDtypeParam(arg.type), type: 'dtype' } },
                  children: []
              };
              node.signatureKey = arg.name;
              inputs.push(node);
              nodes[nodeName] = node;
          });
          const allNodes = Object.keys(nodes);
          allNodes.forEach(key => {
              const node = nodes[key];
              node.inputNames.forEach(name => {
                  const [nodeName,] = getNodeNameAndIndex(name);
                  node.inputs.push(nodes[nodeName]);
                  nodes[nodeName].children.push(node);
              });
          });
          const returnNodeMap = functionDef.ret;
          functionDef.signature.outputArg.forEach(output => {
              const [nodeName, index] = getNodeNameAndIndex(returnNodeMap[output.name]);
              const node = nodes[nodeName];
              if (node != null) {
                  node.defaultOutput = index;
                  outputs.push(node);
              }
          });
          const signature = this.mapArgsToSignature(functionDef);
          return { nodes, inputs, outputs, weights, placeholders, signature };
      }
mapFunction ( functionDef ) { const tfNodes = functionDef . nodeDef ; const placeholders = [ ] ; const weights = [ ] ; let nodes = { } ; if ( tfNodes != null ) { nodes = tfNodes . reduce ( ( map , node ) => { map [ node . name ] = this . mapNode ( node ) ; if ( node . op === 'Const' ) { weights . push ( map [ node . name ] ) ; } return map ; } , { } ) ; } const inputs = [ ] ; const outputs = [ ] ; functionDef . signature . inputArg . forEach ( arg => { const [ nodeName , ] = getNodeNameAndIndex ( arg . name ) ; const node = { name : nodeName , op : 'Placeholder' , inputs : [ ] , inputNames : [ ] , category : 'graph' , inputParams : { } , attrParams : { dtype : { value : parseDtypeParam ( arg . type ) , type : 'dtype' } } , children : [ ] } ; node . signatureKey = arg . name ; inputs . push ( node ) ; nodes [ nodeName ] = node ; } ) ; const allNodes = Object . keys ( nodes ) ; allNodes . forEach ( key => { const node = nodes [ key ] ; node . inputNames . forEach ( name => { const [ nodeName , ] = getNodeNameAndIndex ( name ) ; node . inputs . push ( nodes [ nodeName ] ) ; nodes [ nodeName ] . children . push ( node ) ; } ) ; } ) ; const returnNodeMap = functionDef . ret ; functionDef . signature . outputArg . forEach ( output => { const [ nodeName , index ] = getNodeNameAndIndex ( returnNodeMap [ output . name ] ) ; const node = nodes [ nodeName ] ; if ( node != null ) { node . defaultOutput = index ; outputs . push ( node ) ; } } ) ; const signature = this . mapArgsToSignature ( functionDef ) ; return { nodes , inputs , outputs , weights , placeholders , signature } ; }
map the TFunctionDef to TFJS graph object
map the TFunctionDef to TFJS graph object